12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- 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<Renderer>().enabled)
- GetComponent<Renderer>().enabled = false;
- }
- else if(battleController.GetCtrlCraft().target != null && battleController.GetCtrlCraft().target.CanShoot())
- {
- if(!GetComponent<Renderer>().enabled)
- GetComponent<Renderer>().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<Renderer>().enabled)
- GetComponent<Renderer>().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<Renderer>().enabled)
- GetComponent<Renderer>().enabled = false;
- }
- }
- }
|