public override IEnumerator ExecuteAction(Actor source, BoardManager bm)
    {
        bm.Selector.MoveTo(moveTarget.data.posX, moveTarget.data.posY);
        //move to the target tile
        int pathLeng = MoveToTarget(source, bm, moveTarget.data.posX, moveTarget.data.posY);

        // use skill
        Combat c = new Combat(source);

        yield return(new WaitForSeconds(waitTime * pathLeng));

        AnimationData data = AnimationData.NewAntionData(skillToUse,
                                                         Globals.GetBoardManager().pathfinding.GetTileNode(source),
                                                         skillTarget);


        bm.tileSelection.ClearAllRange();
        //AttackRange(bm, source);

        bm.tileSelection.PopulateMovementRange(
            bm.pathfinding.GetSkillRange(skillToUse, source, source.GetPosX(), source.GetPosY()));
        bm.ui.SkillInUseName.InitLabel(skillToUse.GetName());


        bm.Selector.MoveTo(skillTarget.data.posX, skillTarget.data.posY);
        yield return(new WaitForSeconds(.75f));

        bm.tileSelection.ClearAllRange();

        //targeted tiles
        List <TileNode> nodesInRange = skillToUse.GetTargetedTiles(source, skillTarget);

        bm.tileSelection.PopulateAttackRange(nodesInRange);
        yield return(new WaitForSeconds(.75f));

        //targeted tiles cleared
        bm.tileSelection.ClearAllRange();

        bm.ui.SkillInUseName.ToggleOff();
        c.animationDatas.Add(data);

        ///HACK
        ///This is hacked as f**k

        source.Wait();
        bm.inputFSM.SwitchState(new PlayingAnimationInputState(bm, c));
        bm.turnManager.CalculateFastest();

        /*
         * c.animationDatas.Add(data);
         *
         * c.UseSkill();
         * c.PayCostsCDAttack();
         * source.Wait();
         *
         *
         * bm.turnManager.CalculateFastest(); //this is when the state machine changes
         */
    }
Exemple #2
0
    public override void ProcessInput()
    {
        //display current skill range;

        if (range[selector.mapPosX, selector.mapPosY])
        {
            if (selector.ChangedPosition())
            {
                List <TileNode> nodes = currentSkill.GetTargetedTiles(currentActor, pathfinding.GetTileNode(selector.mapPosX, selector.mapPosY));

                if (nodes == null)
                {
                    return;
                }

                selection.PopulateSkillEffect(nodes);
                previewManager.ClearPreview();

                TileNode node = pathfinding.GetTileNode(selector.mapPosX, selector.mapPosY);

                if (combat == null)
                {
                    combat = new Combat(currentActor);
                }
                else
                {
                    combat.source = currentActor;
                }

                AnimationData data = AnimationData.NewAntionData(currentSkill, boardManager.pathfinding.GetTileNode(currentActor), node);

                previewManager.InitPreview(combat.DisplayCombatPreview(data));

                selector.posChanged = false;
            }
        }

        selector.ProccessInput(inputHandler);



        if (inputHandler.IsKeyPressed(KeyBindingNames.Select) || Input.GetMouseButtonDown(0))
        {
            if (range[selector.mapPosX, selector.mapPosY])
            {
                // We could move this stuff to the animation state to make sure that the
                // animations line up with the animations
                //
                TileNode      node = pathfinding.GetTileNode(selector.mapPosX, selector.mapPosY);
                AnimationData data = new AnimationData();
                data.skillUsed  = currentSkill;
                data.DestNode   = node;
                data.sourceNode = startNode;
                combat.animationDatas.Add(data);

                //combat.PoopulateCombat(data);

                if (currentSkill is Skill)
                {
                    Skill temp = currentSkill as Skill;

                    if (temp.nextSkill != null)
                    {
                        selection.ClearMovementRange();

                        if (temp.nextSkill.useActorSource)
                        {
                            node = pathfinding.GetTileNode(currentActor);
                        }
                        temp = Globals.campaign.contentLibrary.skillDatabase.GetData(temp.nextSkill.skillKey);

                        inputFSM.SwitchState(new AbilityInUseState(boardManager, currentActor, node, temp, combat));
                    }
                    else
                    {
                        PlayAnimations();
                    }
                }
                else
                {
                    PlayAnimations();
                }
            }
        }
        else if (Input.GetKeyDown(KeyCode.Q))
        {
            previewManager.ShiftUp();
        }
        else if (Input.GetKeyDown(KeyCode.E))
        {
            previewManager.ShfitDown();
        }
        else if (inputHandler.IsKeyPressed(KeyBindingNames.Cancel) || Input.GetMouseButtonDown(1))
        {
            inputFSM.SwitchState(new UsersTurnState(boardManager));

            // selector.MoveTo(currentActor.GetPosX(), currentActor.GetPosY());
        }
    }