Organization of Game Files
Created folder for C# files, player, and enemy so it's a little cleaner...
This commit is contained in:
26
Assets/C# Scripts/UI overlay/DistanceIndicator.cs
Normal file
26
Assets/C# Scripts/UI overlay/DistanceIndicator.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class DistanceIndicator : MonoBehaviour
|
||||
{
|
||||
public float multiplier;
|
||||
Teo player;
|
||||
SpriteRenderer sprite;
|
||||
float timeCreated;
|
||||
void Start() {
|
||||
player = GameObject.FindGameObjectWithTag("Player").GetComponent<Teo>();
|
||||
sprite = GetComponent<SpriteRenderer>();
|
||||
timeCreated = Time.fixedTime;
|
||||
transform.localScale = new Vector3 (player.swingDistance*multiplier, player.swingDistance*multiplier, 1);
|
||||
StartCoroutine("KillMyself");
|
||||
}
|
||||
|
||||
void Update() {
|
||||
sprite.color = new Color (0F, 0F, 0F, 0.5F-(Time.fixedTime-timeCreated));
|
||||
}
|
||||
|
||||
IEnumerator KillMyself() {
|
||||
yield return new WaitForSeconds (0.5F);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user