예제 #1
0
    //what happens when clicking on an enemy
    public static void ShowOnEnemyActions(TacticsMove enemy)
    {
        if (selectedUnit != enemy)
        {
            selectedUnit = enemy;
            if (!canSeeEnemiesRange)
            {
                ResetReachableByEnemyTiles();
            }
            //enemy.FindReachableByEnemyTiles();
            enemy.FindSelectableTiles(true);

            if (!currentUnit.actionPhase)
            {
                currentUnit.FindSelectableTiles();
            }
            else
            {
                currentUnit.FindAttackableTiles();
            }

            //reboot to show panelanimation
            //manager.HidePanels();
            manager.StartCoroutine(manager.ShowPanels());

            RaycastHit hit;
            if (Physics.Raycast(enemy.transform.position, Vector3.down, out hit, 1))
            {
                if (hit.transform.GetComponent <Tile>().attackable)
                {
                    actionPanel.transform.Find("AttackButton").gameObject.SetActive(true);
                }
                else
                {
                    actionPanel.transform.Find("AttackButton").gameObject.SetActive(false);
                }
            }
            actionPanel.transform.Find("WaitButton").gameObject.SetActive(false);
        }
        else   //clicking on previously clicked enemy cancels its panels
        {
            manager.CancelAction();
            selectedUnit = currentUnit;
        }
    }