// initialization void Start() { animator = this.GetComponent <Animator>(); StartCoroutine(StartCountdown()); // viewport tow world point is relative to the camera // getting the distance between the gameObject to camera float distance = Vector3.Distance(transform.position, Camera.main.transform.position); Vector2 bottom = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, distance)); Vector2 top = Camera.main.ViewportToWorldPoint(new Vector3(1, 1, distance)); // min and max values for the size of screen minX = bottom.x; maxX = top.x; minY = bottom.y; maxY = top.y; // get health script getHP = GameObject.Find("GetHealth").GetComponent <GetHealth>(); }
static void Main(string[] args) { var squad = new Squad(); squad.Add(new Unit(10)); squad.Add(new Unit(10)); squad.Add(new Unit(15)); squad.Add(new Squad(new List <ISelectableEntity>() { new Unit(10) })); ISelectableEntity entity = squad; squad.MoveTo(10, 10); var health = new GetHealth(); entity.Accept(health); Console.WriteLine(health.Result); }
public void TakeHealth(float health) => GetHealth?.Invoke(health);