//Hover info.
    void OnMouseEnter()
    {
        if ((BattleInputController.inputState == BattleInputController.eInputState.PLAYER_DEFAULT ||
             BattleInputController.inputState == BattleInputController.eInputState.NPC_DEFAULT) & currentUnit != null)
        {
            BattleInputController.mouseHoverEvent = true;

            if (cellHoverInfoEvent != null)
            {
                cellHoverInfoEvent(currentUnit);
            }
            currentUnit.SetIndicatorEnabled(true);

            if (currentUnit.stats.mp > 0)
            {
                int mpLoss = currentUnit.MovementLockPenalty();
                HashSet <GridCell> remainingMoveRange = Pathfinder.GetMoveRange(this, currentUnit.stats.mp - mpLoss);
                HashSet <GridCell> unitMoveRange      = Pathfinder.GetMoveRange(this, currentUnit.stats.mp);

                if (gridHighlighter == null)
                {
                    gridHighlighter = GameObject.FindGameObjectWithTag("Battle Controller").GetComponent <GridHighlighter> ();
                }
                gridHighlighter.ClearAll();

                if (currentUnit == BattleController.instance.currentUnit)
                {
                    if (input == null)
                    {
                        input = GameObject.FindGameObjectWithTag("Battle Controller").GetComponent <BattleInputController> ();
                    }
                    input.ShowMovementRange();
                }
                else
                {
                    gridHighlighter.HighlightNonVisibleCell(unitMoveRange);
                    gridHighlighter.HighlightMoveRange(remainingMoveRange);
                }
            }
        }
        else if (BattleInputController.inputState == BattleInputController.eInputState.TARGET_SELECT && currentUnit != null)
        {
            if (cellHoverInfoEvent != null)
            {
                cellHoverInfoEvent(currentUnit);
            }
            currentUnit.SetIndicatorEnabled(true);
        }
    }
Exemplo n.º 2
0
    private void BattleStateChanged(BattleController.eBattleState state)
    {
        switch (state)
        {
        case BattleController.eBattleState.INITIALISATION:
            inputState = eInputState.DISABLED;
            highlighter.InitHighlighter();
            mouseHoverEvent = false;
            currentUnit     = null;
            break;

        case BattleController.eBattleState.UNIT_PLACEMENT:
            inputState     = eInputState.UNIT_PLACEMENT;
            playerStartPos = BattleController.instance.playerStartPos;
            enemyStartPos  = BattleController.instance.enemyStartPos;
            highlighter.HighlightPlayerStart(playerStartPos);
            highlighter.HighlightEnemyStart(enemyStartPos);
            currentUnit = null;
            break;

        case BattleController.eBattleState.PLAYER_TURN:
            inputState = eInputState.PLAYER_DEFAULT;
            UpdateUnitState();
            break;

        case BattleController.eBattleState.AI_TURN:
            inputState = eInputState.NPC_DEFAULT;
            highlighter.ClearAll();
            UpdateUnitState();
            break;

        case BattleController.eBattleState.VICTORY:
            inputState  = eInputState.DISABLED;
            currentUnit = null;
            break;

        case BattleController.eBattleState.DEFEAT:
            inputState  = eInputState.DISABLED;
            currentUnit = null;
            break;
        }
    }
 //Debugging
 private void ForceTurnEnd()
 {
     highlighter.ClearAll();
     BattleController.instance.EndTurn();
 }