예제 #1
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());
        }
    }