void Update()
 {
     duration += ps.duration * Time.deltaTime;
     if (duration >= ps.duration + 1)
     {
         transform.parent.gameObject.SetActive(false);
         GameObject.FindGameObjectWithTag("GameController").GetComponent <ButtonHolder>().Recreate(transform.parent.gameObject);
         parentScript.Deselected();
         Destroy(gameObject);
     }
 }
Beispiel #2
0
    public void DeselectAll()
    {
        if (selected != null)
        {
            Selectable s = selected.GetComponent <Selectable> ();
            s.Deselected();
            selected = null;
        }

        if (enemySelected != null)
        {
            Selectable s = enemySelected.GetComponent <Selectable> ();
            s.Deselected();
            enemySelected = null;
        }

        attackButton.gameObject.SetActive(false);
        cancelButton.gameObject.SetActive(false);
    }
Beispiel #3
0
    void DoSelectMagicLogic(Vector3 pos)
    {
        if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        var bothSelected = selected != null && enemySelected != null;

        if (!bothSelected && isMyTurn)
        {
            RaycastHit hit;
            var        ray = Camera.main.ScreenPointToRay(pos);
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.transform.gameObject.CompareTag("Player"))
                {
                    Selectable a = hit.transform.GetComponent <Selectable> ();
                    if (a.isSelected())
                    {
                        a.Deselected();
                        if (selected == hit.transform.gameObject)
                        {
                            selected = null;
                        }
                        else if (enemySelected == hit.transform.gameObject)
                        {
                            enemySelected = null;
                        }
                    }
                    else
                    {
                        if (selected == null)
                        {
                            selected = hit.transform.gameObject;
                            a.Selected("green");
                        }
                        else if (enemySelected == null)
                        {
                            enemySelected = hit.transform.gameObject;
                            a.Selected("red");
                        }
                    }
                }
            }
            else
            {
                DeselectAll();
            }
        }

        bothSelected = selected != null && enemySelected != null;
        var eitherSelected = selected != null || enemySelected != null;

        if (eitherSelected)
        {
            cancelButton.gameObject.SetActive(true);
        }
        else
        {
            cancelButton.gameObject.SetActive(false);
        }

        if (bothSelected)
        {
            attackButton.gameObject.SetActive(true);
        }
        else
        {
            attackButton.gameObject.SetActive(false);
        }
    }
 private void DeselectCurrentSelection()
 {
     if (currentSelection != null)
         currentSelection.Deselected();
 }