示例#1
0
    private IEnumerator Push(GridCell target)
    {
        BattleInputController.SetInputState(BattleInputController.eInputState.DISABLED);
        while (transform.position != target.transform.position)
        {
            float sqrRemainingDistance = (transform.position - target.transform.position).sqrMagnitude;

            while (sqrRemainingDistance > float.Epsilon)
            {
                transform.position   = Vector3.MoveTowards(transform.position, target.transform.position, pushSpeed * Time.deltaTime);
                sqrRemainingDistance = (transform.position - target.transform.position).sqrMagnitude;
                yield return(null);
            }
        }

        unit.DisplaceComplete(target);

        if (BattleController.instance.battleState == BattleController.eBattleState.PLAYER_TURN)
        {
            BattleInputController.SetInputState(BattleInputController.eInputState.PLAYER_DEFAULT);
        }
        else
        {
            BattleInputController.SetInputState(BattleInputController.eInputState.NPC_DEFAULT);
        }
    }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (inputController == null)
        {
            inputController = BattleController.instance.GetComponent <BattleInputController> ();
        }
        inputController.AbilityAnimationComplete();
    }
    //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);
        }
    }
 public void SignalHitFrame()
 {
     if (inputController == null)
     {
         inputController = GameObject.FindGameObjectWithTag("Battle Controller").GetComponent <BattleInputController> ();
     }
     if (BattleController.instance.currentUnit.unitType == eUnitType.ALLY)
     {
         inputController.SignalUnits();
     }
     else
     {
         inputController.AiSignalUnits(gameObject.GetComponentInParent <AiController> ().targetCells);
     }
 }
 void Awake()
 {
     GetComponent <BattleController>().stateChange += BattleStateChanged;
     highlighter     = GetComponent <GridHighlighter> ();
     inputController = GetComponent <BattleInputController> ();
 }
示例#6
0
 void Awake()
 {
     sharedInstance = this;
 }
示例#7
0
 private void Awake()
 {
     instance = this;
 }
示例#8
0
 private void Start()
 {
     battleInputController = BattleInputController.instance;
 }
 void Awake()
 {
     sharedInstance = this;
 }
示例#10
0
 public void MoveUnit(GridCell start, Stack <GridCell> path)
 {
     BattleInputController.SetInputState(BattleInputController.eInputState.DISABLED);
     StartCoroutine(Move(path, start, path.Count));
 }