Exemplo n.º 1
0
    private void PrimaryClick()
    {
        RaycastHit[] hits = RayClick();

        foreach (RaycastHit hit in hits)
        {
            string hitTag = hit.collider.tag;
            if (hitTag.Equals("Allies") || hitTag.Equals("Ground"))
            {
                if (hit.collider.GetComponent <Troop>() != null) //if clicked a troop
                {
                    selectedObj = hit.collider.gameObject;       //select that troop
                }
                else
                {
                    if (selectedObj && selectedObj.GetComponent <Troop>() != null) //if clicking while troop is selected
                    {
                        selectedObj = null;                                        //deselect troop
                    }
                    else if (!selectedObj)
                    {
                        selectedObj = TroopCreator.CreateTroop(TroopCreator.Find(1), hit.point);
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     TroopCreator.SetUpData();
 }