using UnityEngine; using System.Collections; public class TargetMark : MonoBehaviour { private BattleController battleController; // Use this for initialization public void init(BattleController battleController) { this.battleController = battleController; } // Update is called once per frame void Update () { if(battleController == null) return; if(battleController.GetCtrlCraft() == null) { if(GetComponent().enabled) GetComponent().enabled = false; } else if(battleController.GetCtrlCraft().target != null && battleController.GetCtrlCraft().target.CanShoot()) { if(!GetComponent().enabled) GetComponent().enabled = true; Vector3 position = battleController.GetCtrlCraft().target.position; position.y = 0.01f; this.transform.position = position; this.transform.localRotation = Quaternion.Euler(270, GameTime.time*180f, 0); float scale = 1.8f+0.2f*Mathf.Sin(GameTime.time*5f); this.transform.localScale = new Vector3(scale, scale, scale); } else if(battleController.GetCtrlCraft().target != null && battleController.GetCtrlCraft().target.CanShoot()) { if(!GetComponent().enabled) GetComponent().enabled = true; Vector3 position = battleController.GetCtrlCraft().target.position; position.y = 0.01f; this.transform.position = position; this.transform.localRotation = Quaternion.Euler(270, GameTime.time*180f, 0); float scale = 1.8f+0.2f*Mathf.Sin(GameTime.time*5f); this.transform.localScale = new Vector3(scale, scale, scale); } else { if(GetComponent().enabled) GetComponent().enabled = false; } } }