Skip to content

Commit

Permalink
Cats trails fix and better text position
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbian committed Mar 13, 2018
1 parent b8476b8 commit 3c4b8c3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 15 deletions.
4 changes: 3 additions & 1 deletion ModuleManager/Cats/CatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ private static GameObject LaunchCat(int scale)
trail.material.mainTexture = rainbow;
trail.time = 1.5f;
trail.startWidth = 0.6f * scale * rainbow.height;
trail.endWidth = 0.6f * scale * rainbow.height * 0.9f;

trail.endColor = Color.white.A(0.1f);
trail.colorGradient = new Gradient {alphaKeys = new GradientAlphaKey[3] { new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 0.75f), new GradientAlphaKey(0.2f, 1) }};
trail.Clear();
cat.layer = LayerMask.NameToLayer("UI");

catAnimator.frames = catFrames;
Expand Down
4 changes: 3 additions & 1 deletion ModuleManager/Cats/CatMover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ public class CatMover : MonoBehaviour
private float time = 5;
private float trailTime = 0.5f;

private int frames = 1;

// Use this for initialization
void Start()
{
trail = this.GetComponent<TrailRenderer>();
trail.sortingOrder = 2;


spriteRenderer = this.GetComponent<SpriteRenderer>();

offsetY = Mathf.FloorToInt(0.2f * Screen.height);
Expand All @@ -38,6 +39,7 @@ void Start()

totalLenth = (int) (Screen.width / time * trail.time) + 150;
trail.time = trailTime;
trail.widthCurve = new AnimationCurve(new Keyframe(0, trail.startWidth ), new Keyframe(0.7f, trail.startWidth), new Keyframe(1, trail.startWidth * 0.9f));
}

void Update()
Expand Down
4 changes: 3 additions & 1 deletion ModuleManager/Cats/CatOrbiter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ public void Init(CatOrbiter parent, float soi)

transform.localScale *= scale;
TrailRenderer trail = gameObject.GetComponent<TrailRenderer>();
trail.colorGradient = new Gradient() {alphaKeys = new GradientAlphaKey[3] { new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 0.7f), new GradientAlphaKey(0, 1) }};
trail.startWidth *= scale;
trail.endWidth *= scale;
//trail.endWidth *= scale;
trail.widthCurve = new AnimationCurve(new Keyframe(0, trail.startWidth ), new Keyframe(0.7f, trail.startWidth), new Keyframe(1, trail.startWidth * 0.9f));

//Mass = factor * 2E16;

Expand Down
46 changes: 34 additions & 12 deletions ModuleManager/ModuleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ModuleManager : MonoBehaviour
public bool showUI = false;

private Rect windowPos = new Rect(80f, 60f, 240f, 40f);
private float textPos = 0;

private string version = "";

Expand Down Expand Up @@ -63,7 +64,24 @@ internal void Awake()

// Allow loading the background in the laoding screen
Application.runInBackground = true;
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = -1;

// More cool loading screen. Less 4 stoke logo.
for (int i = 0; i < LoadingScreen.Instance.Screens.Count; i++)
{
var state = LoadingScreen.Instance.Screens[i];
state.fadeInTime = i < 3 ? 0.1f : 1;
state.displayTime = i < 3 ? 1 : 3;
state.fadeOutTime = i < 3 ? 0.1f : 1;
}

TextMeshProUGUI[] texts = LoadingScreen.Instance.gameObject.GetComponentsInChildren<TextMeshProUGUI>();
foreach (var text in texts)
{
textPos = Mathf.Min(textPos, text.rectTransform.localPosition.y);
}

// Ensure that only one copy of the service is run per scene change.
if (loadedInScene || !ElectionAndCheck())
{
Expand Down Expand Up @@ -152,12 +170,15 @@ private TextMeshProUGUI CreateTextObject(Canvas canvas, string name)
GameObject statusGameObject = new GameObject(name);
TextMeshProUGUI text = statusGameObject.AddComponent<TextMeshProUGUI>();
text.text = "STATUS";
text.fontSize = 16;
text.fontSize = 18;
text.autoSizeTextContainer = true;
text.font = Resources.Load("Fonts/Calibri SDF", typeof(TMP_FontAsset)) as TMP_FontAsset;
text.alignment = TextAlignmentOptions.Center;
text.enableWordWrapping = false;
text.isOverlay = true;
text.rectTransform.anchorMin = new Vector2(0.5f, 0);
text.rectTransform.anchorMax = new Vector2(0.5f, 0);
text.rectTransform.anchoredPosition = Vector2.zero;
statusGameObject.transform.SetParent(canvas.transform);

return text;
Expand Down Expand Up @@ -224,32 +245,33 @@ internal void Update()
Log("Total loading Time = " + ((float)totalTime.ElapsedMilliseconds / 1000).ToString("F3") + "s");

Application.runInBackground = GameSettings.SIMULATE_IN_BACKGROUND;
QualitySettings.vSyncCount = GameSettings.SYNC_VBL;
Application.targetFrameRate = GameSettings.FRAMERATE_LIMIT;
}

float offsetY = Mathf.FloorToInt(0.23f * Screen.height);
float offsetY = textPos;
float h;
if (warning)
{
warning.transform.localPosition = new Vector3(0, -offsetY);
h = warning.textBounds.size.y;
if (h > 0)
offsetY = offsetY + h + 10;
h = warning.text.Length > 0 ? warning.textBounds.size.y : 0;
offsetY = offsetY + h;
warning.rectTransform.localPosition = new Vector3(0, offsetY);
}

if (status)
{
status.transform.localPosition = new Vector3(0, -offsetY);
status.text = MMPatchLoader.Instance.status;

h = status.textBounds.size.y;
if (h > 0)
offsetY = offsetY + h + 10;
h = status.text.Length > 0 ? status.textBounds.size.y: 0;
offsetY = offsetY + h;
status.transform.localPosition = new Vector3(0, offsetY);
}

if (errors)
{
errors.transform.localPosition = new Vector3(0, -offsetY);
errors.text = MMPatchLoader.Instance.errors;
h = errors.text.Length > 0 ? errors.textBounds.size.y: 0;
offsetY = offsetY + h;
errors.transform.localPosition = new Vector3(0, offsetY);
}

if (reloading)
Expand Down

0 comments on commit 3c4b8c3

Please sign in to comment.