Exemplo n.º 1
0
    //Handle object initial actions
    void Awake()
    {
        //Implement this as a singleton to ensure only one instance at any given time
        if (CombatUIManager._instance != null && CombatUIManager._instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            //Set this as the instance of the singleton
            CombatUIManager._instance = this;
            //Get reference for canvas object
            if (CanvasObject == null)
            {
                CanvasObject = GameObject.Find("Canvas");
            }
            if (_uiContainer == null)
            {
                _uiContainer = GameObject.Find("UIContainer");
            }

            //Initialize MenuLevel to unopened at start
            this.MenuLevel = GameConstants.CombatMenuPage.Unopened;

            //Initialize dictionaries and lists
            possibleTargets = new List <CharMgrScript>();
            currTargets     = new List <CharMgrScript>();

            //Grab references to the necessary prefabs
            if (uiEndCombatScreen == null)
            {
                uiEndCombatScreen = (GameObject)Resources.Load("Prefabs/UI/CollectItemEmpty");
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Handles the input.
    /// </summary>
    /// <param name="keyPressed">Key pressed.</param>
    public void HandleInput(KeyCode keyPressed)
    {
//        if (TestScript._instance.TestMode)
//        {
//            Debug.LogWarning("~~~~2. Combat UI Handling Input ~~~~");
//        }
        Debug.Log(CombatMgr._instance.currentTurnChar.stats.CharName + "=>HANDLING INPUT and menu level is" + CombatUIManager._instance.MenuLevel.ToString());

        if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.Action)
        {
            switch (keyPressed)
            {
            case (KeyCode.LeftArrow):
                //Reduce Index by 2 if under the right conditions. If index is over count
                if (actMenuScript.CurrIndex >= (actMenuScript.ActionMenuItems.Count - actMenuScript.ActionMenuItems.Count / 2))
                {
                    actMenuScript.SetSelectedAction(false, -1 * (actMenuScript.ActionMenuItems.Count / 2));
                }
                break;

            case (KeyCode.RightArrow):
                if (actMenuScript.CurrIndex <= (actMenuScript.ActionMenuItems.Count / 2))
                {
                    actMenuScript.SetSelectedAction(false, 2);
                }
                break;

            case (KeyCode.UpArrow):
                actMenuScript.SetSelectedAction(false, -1);
                break;

            case (KeyCode.DownArrow):
                actMenuScript.SetSelectedAction(false, 1);
                break;

            case (KeyCode.Space):
                //Selection key, so set ui active state and start action menu
                actMenuScript.ActionMenuItems[actMenuScript.CurrIndex].Action(CombatMgr._instance.currentTurnChar);

                break;

            case (KeyCode.Escape):
                break;

            default:
                break;
            }
        }
        else if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.Attack)
        {
            switch (keyPressed)
            {
            case (KeyCode.LeftArrow):
                break;

            case (KeyCode.RightArrow):
                break;

            case (KeyCode.UpArrow):
                //Update the selected target
                UpdateSelectionAttackTarget(-1);
                break;

            case (KeyCode.DownArrow):
                //Update the selected target
                UpdateSelectionAttackTarget(1);
                break;

            case (KeyCode.Space):
                //Execute attack
                CombatMgr._instance.PerformAttack(CombatMgr._instance.currentTurnChar.GetBasicAttack(), currTargets);
                break;

            case (KeyCode.Escape):
                /*Exit this menu level and go back to action select*/
                //Revert UI states
                CombatUIManager._instance.actMenuScript.SetSelectedState(GameConstants.ActionOptionIndices.Attack, false);
                //Remove selection arrows and hp text
                foreach (CharMgrScript c in currTargets)
                {
                    c.HighlightArrowStatus(false);
                }
                //reset target lists
                possibleTargets.Clear();
                currTargets.Clear();
                //Set the flag for menu state
                CombatUIManager._instance.MenuLevel = GameConstants.CombatMenuPage.Action;
                break;

            default:
                break;
            }
        }
        else if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.Ability)
        {
            switch (keyPressed)
            {
            case (KeyCode.LeftArrow):
                break;

            case (KeyCode.RightArrow):
                break;

            case (KeyCode.UpArrow):
                break;

            case (KeyCode.DownArrow):
                break;

            case (KeyCode.Space):
                break;

            case (KeyCode.Escape):
                break;

            default:
                break;
            }
        }
        else if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.Flee)
        {
            switch (keyPressed)
            {
            case (KeyCode.LeftArrow):
                break;

            case (KeyCode.RightArrow):
                break;

            case (KeyCode.UpArrow):
                break;

            case (KeyCode.DownArrow):
                break;

            case (KeyCode.Space):
                break;

            case (KeyCode.Escape):
                break;

            default:
                break;
            }
        }
        else if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.Item)
        {
            switch (keyPressed)
            {
            case (KeyCode.LeftArrow):
                break;

            case (KeyCode.RightArrow):
                break;

            case (KeyCode.UpArrow):
                break;

            case (KeyCode.DownArrow):
                break;

            case (KeyCode.Space):
                break;

            case (KeyCode.Escape):
                break;

            default:
                break;
            }
        }
        else if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.AnimationAction)
        {
            switch (keyPressed)
            {
            case (KeyCode.LeftArrow):
                break;

            case (KeyCode.RightArrow):
                break;

            case (KeyCode.UpArrow):
                break;

            case (KeyCode.DownArrow):
                break;

            case (KeyCode.Space):
                break;

            case (KeyCode.Escape):
                break;

            default:
                break;
            }
        }
        else if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.EndScreen)
        {
            switch (keyPressed)
            {
            case (KeyCode.LeftArrow):
                break;

            case (KeyCode.RightArrow):
                break;

            case (KeyCode.UpArrow):
                break;

            case (KeyCode.DownArrow):
                break;

            case (KeyCode.Space):
                //TODO:Clean up combat UI. This can be handled here: Call methods needed to hide or destroy objects.

                //Clean up action menu object and remove from screen
                Destroy(this.actMenuScript.gameObject);
                actMenuScript = null;
                //Clean up end of combat UI
                Destroy(this.endScreenScript.gameObject);
                endScreenScript = null;
                //Reset state flags as needed
                this.MenuLevel = GameConstants.CombatMenuPage.Unopened;
                //Leave combat scene and load overworld scene
                CombatMgr._instance.LeaveCombatScene();

                break;

            case (KeyCode.Escape):
                break;

            default:
                break;
            }
        }
    }