-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Getting ready for 1.2 - Better cat and Text
- Loading branch information
Showing
21 changed files
with
509 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using System.Collections; | ||
using UnityEngine; | ||
|
||
namespace ModuleManager | ||
{ | ||
public class CatMover : MonoBehaviour | ||
{ | ||
public Vector3 spos; | ||
|
||
public float vel = 5; | ||
private float offsetY; | ||
|
||
public TrailRenderer trail; | ||
|
||
public Sprite[] frames; | ||
public float secFrame = 0.07f; | ||
|
||
private SpriteRenderer spriteRenderer; | ||
private int spriteIdx; | ||
|
||
private int totalLenth = 100; | ||
private float activePos = 0; | ||
|
||
public float scale = 2; | ||
|
||
|
||
private float time = 5; | ||
private float trailTime = 0.5f; | ||
|
||
|
||
// Use this for initialization | ||
void Start() | ||
{ | ||
trail = this.GetComponent<TrailRenderer>(); | ||
spriteRenderer = this.GetComponent<SpriteRenderer>(); | ||
|
||
spriteRenderer.sortingOrder = 3; | ||
trail.sortingOrder = 2; | ||
|
||
offsetY = Mathf.FloorToInt(0.2f * Screen.height); | ||
|
||
spos.z = -1; | ||
|
||
StartCoroutine(Animate()); | ||
|
||
trailTime = time / 4; | ||
|
||
totalLenth = (int) (Screen.width / time * trail.time) + 150; | ||
trail.time = trailTime; | ||
} | ||
|
||
void Update() | ||
{ | ||
if (trail.time <= 0f) | ||
{ | ||
trail.time = trailTime; | ||
} | ||
|
||
activePos += ((Screen.width / time) * Time.deltaTime); | ||
|
||
if (activePos > (Screen.width + totalLenth)) | ||
{ | ||
activePos = -frames[spriteIdx].textureRect.width; | ||
trail.time = 0;; | ||
} | ||
|
||
float f = 2f * Mathf.PI * (activePos) / (Screen.width * 0.5f); | ||
|
||
float heightOffset = Mathf.Sin(f) * (frames[spriteIdx].textureRect.height * scale); | ||
|
||
spos.x = activePos; | ||
spos.y = offsetY + heightOffset; | ||
|
||
transform.position = KSP.UI.UIMainCamera.Camera.ScreenToWorldPoint(spos); | ||
transform.rotation = Quaternion.Euler(0, 0, Mathf.Cos(f) * 0.25f * Mathf.PI * Mathf.Rad2Deg); | ||
} | ||
|
||
IEnumerator Animate() | ||
{ | ||
if (frames.Length == 0) | ||
yield return null; | ||
|
||
WaitForSeconds yield = new WaitForSeconds(secFrame); | ||
|
||
while (true) | ||
{ | ||
spriteIdx = (spriteIdx+1) % frames.Length; | ||
spriteRenderer.sprite = frames[spriteIdx]; | ||
yield return yield; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Copy Local has been set to false for all dependencies. | ||
Remark by Jan Van der Haegen: This file has been added because Nuget would installs packages to the solution instead of the project if there are only PowerShell scripts... (So yes: it's safe to remove this file!) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.