Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        enemyStatus = ActionStatus.isDone;
        players     = GameObject.FindGameObjectsWithTag("Player");
        speed       = 2f;
        switch (rangeType)//this is attack range
        {
        case RangeType.melee:
            range        = 1;
            enemyRangeHL = enemyRangeHLs[0];
            break;

        case RangeType.shoot:
            range        = 2;
            enemyRangeHL = enemyRangeHLs[1];
            break;
        }
        Instantiate(enemyRangeHL, transform);
        aRangeVB = GetComponentInChildren <Visibility>();
        inCheck  = GetComponentInChildren <InRangeCheck>();
        MoveRangePick();
    }
Esempio n. 2
0
    public void ActiveUI()//active player action UI
    {
        if (!Selected())
        {
            timer = 0;//this timer avoid the UI being active when click
        }
        if (Selected())
        {
            timer += Time.deltaTime;
            if (Input.GetButtonDown("Fire1") && timer >= popTime)
            {
                if (!playerActionUI.activeSelf)
                {
                    GridSpec gSpec;
                    gSpec = targetGrid.GetComponent <GridSpec>();
                    inRC  = selectedGO.GetComponentInChildren <InRangeCheck>();
                    if (gSpec.HighLighted() || gSpec.gStatus == "isEnemy" || gSpec.gStatus == "isFriend") //if the grid is in moveable area
                    {
                        if (gSpec.gStatus == "isNeutral")                                                 //player could move to neutral grid and check player status
                        {
                            playerActionUI.SetActive(true);
                            moveButton.interactable           = true;
                            attactButton.interactable         = false;
                            playerActionUI.transform.position = Input.mousePosition;
                            Moved();
                        }
                        else if (gSpec.gStatus == "isEnemy" && inRC.haveInRange)//player could attack grid have enemy and check player or enemy status
                        {
                            print("This is Enemy");
                            playerActionUI.SetActive(true);
                            moveButton.interactable           = false;
                            attactButton.interactable         = true;
                            playerActionUI.transform.position = Input.mousePosition;
                            enemyPup = targetGrid.transform.Find("Interactable").GetComponent <GridOccupy>().thisUnit;
                        }
                        else if (gSpec.gStatus == "isFriend" && !inRC.haveInRange)
                        {
                            playerActionUI.SetActive(true);
                            moveButton.interactable           = false;
                            attactButton.interactable         = false;
                            restButton.interactable           = true;
                            playerActionUI.transform.position = Input.mousePosition;
                        }
                    }
                    else if (!gSpec.HighLighted() && gSpec.gStatus != "isEnemy")
                    {
                        playerActionUI.SetActive(false);
                    }
                }
            }
        }

        //this condition check make sure when player click the "rest" button , the ui will close;
        //because in the condition check above, when the ui is not disable, if player click the move button/attack button , player status would be set to ohter enum.

        /*if (Selected())
         * {
         *  PlayerAction playerAction;
         *  playerAction = selectedGO.GetComponent<PlayerAction>();
         *  if (playerAction.aStatus == ActionStatus.isDone)
         *  {
         *      playerActionUI.SetActive(false);
         *  }
         * }*/
        //this function could be add to "Rest". when click "Rest" button, disable ui would be better. no need to get reference of "playerAction".
    }