private static int[,] GetMovesResult(IInputData initialStateMock)
        {
            var executor = new MoveExecutor();
            var result   = executor.MakeMoves(initialStateMock);

            return(result);
        }
예제 #2
0
 public override void Start()
 {
     base.Start();
     moveExecutor        = new MoveExecutor();
     Executor.lockToGrid = lockToGrid;
     Executor.character  = character;
     Executor.map        = map;
 }
예제 #3
0
    public virtual void TemporaryMoveToPathNode(PathNode pn, MoveExecutor.MoveFinished callback = null)
    {
        currentTarget.Path(pn);
        MoveExecutor me = Executor;

        me.TemporaryMoveTo(pn, delegate(Vector3 src, PathNode endNode, bool finishedNicely) {
            scheduler.CharacterMovedTemporary(
                character,
                map.InverseTransformPointWorld(src),
                map.InverseTransformPointWorld(endNode.pos),
                pn
                );
            if (callback != null)
            {
                callback(src, endNode, finishedNicely);
            }
        }, 10.0f, false, remainMounted);
    }
예제 #4
0
    public virtual void IncrementalMoveToPathNode(PathNode pn, MoveExecutor.MoveFinished callback = null)
    {
        currentTarget.Path(pn);
        MoveExecutor me = Executor;

        me.IncrementalMoveTo(pn, delegate(Vector3 src, PathNode endNode, bool finishedNicely) {
/*			Debug.Log("moved from "+src);*/
            scheduler.CharacterMovedIncremental(
                character,
                src,
                endNode.pos,
                pn
                );
            if (callback != null)
            {
                callback(src, endNode, finishedNicely);
            }
        }, 10.0f, false, remainMounted);
    }
예제 #5
0
    public virtual void PerformMoveToPathNode(PathNode pn, MoveExecutor.MoveFinished callback = null)
    {
        currentTarget.Path(pn);
        // Debug.Log("perform move to "+currentTarget);
        MoveExecutor me = Executor;

        // if(!(currentSettings.targetingMode == TargetingMode.Path && currentSettings.immediatelyExecuteDrawnPath)) {
        //  Debug.Log("first, pop back to "+initialTarget.Position);
        //  me.ImmediatelyMoveTo(new PathNode(initialTarget.Position, null, 0));
        // }
        //FIXME: really? what about chained moves?
        if (character.IsMounting && !remainMounted)
        {
            character.Dismount();
        }
        me.MoveTo(pn, delegate(Vector3 src, PathNode endNode, bool finishedNicely) {
            Character c = map.OtherCharacterAt(character, endNode.pos);
            if (c != null &&
                !character.IsMounting && !character.IsMounted &&
                !c.IsMounted && !c.IsMounting)
            {
                if (character.CanMount(c) && c.IsMountableBy(character))
                {
                    character.Mount(c);
                }
                else
                {
                    Debug.LogError("Can't mount character we're standing on!");
                }
            }
            scheduler.CharacterMoved(
                character,
                map.InverseTransformPointWorld(src),
                map.InverseTransformPointWorld(endNode.pos),
                pn
                );
            if (callback != null)
            {
                callback(src, endNode, finishedNicely);
            }
        }, 10.0f, false, remainMounted);
    }
        static void Main()
        {
            var inputReader = new InputOutput.ConsoleInputReader();
            var input       = inputReader.GetInputData();

            var executor = new MoveExecutor();
            var result   = executor.MakeMoves(input.InitialStateArray, input.MoveCounter);

            for (int i = 0; i <= result.GetUpperBound(0); i++)
            {
                for (int j = 0; j <= result.GetUpperBound(1); j++)
                {
                    Console.Write(result[i, j] + " ");
                }

                Console.Write(Environment.NewLine);
            }

            Console.ReadLine();
        }
예제 #7
0
    public void OnGUI()
    {
        Scheduler s = GetComponent <Scheduler>();
        Arbiter   a = GetComponent <Arbiter>();

        if (pendingTargetedSkill != null)
        {
            if (targetingChoices == null || targetingChoices.Length == 0)
            {
                targetingChoices = new string[] {
                    "Tile",
                    "Character",
                    "Cancel"
                };
            }
            int choice = OnGUIChoices("Target tile or character?", targetingChoices);
            if (choice != -1)
            {
                if (choice == 0)
                {
                    pendingTargetedSkill.ConfirmDelayedSkillTarget(TargetOption.Path);
                }
                else if (choice == 1)
                {
                    pendingTargetedSkill.ConfirmDelayedSkillTarget(TargetOption.Character);
                }
                else if (choice == 2)
                {
                    pendingTargetedSkill.IncrementalCancel();
                }
                pendingTargetedSkill = null;
            }
            return;
        }
        bool      showAnySchedulerButtons = true;
        bool      showCancelButton        = true;
        Character ac     = s.activeCharacter;
        var       skills = ac == null ? new SkillDef[0] : ac.Skills;

        if (ac != null)
        {
            if (map == null)
            {
                map = transform.parent.GetComponent <Map>();
            }
            MoveSkillDef ms = ac.moveSkill;
            if (ms != null && ms.isActive)
            {
                if (a.IsLocalTeam(ac.EffectiveTeamID))
                {
                    MoveExecutor me = ms.Executor;
                    if (!me.IsMoving)
                    {
                        if (ms.RequireConfirmation &&
                            ms.AwaitingConfirmation)
                        {
                            bool yesButton = false, noButton = false;
                            OnGUIConfirmation("Move here?", out yesButton, out noButton);
                            if (yesButton)
                            {
                                ms.ApplyCurrentTarget();
                                ms.AwaitingConfirmation = false;
                            }
                            if (noButton)
                            {
                                ms.AwaitingConfirmation = false;
                                ms.TemporaryMove(map.InverseTransformPointWorld(me.position));
                            }
                            showCancelButton = false;
                        }
                        else
                        {
                            showCancelButton = false;
                        }
                        showAnySchedulerButtons = false;
                    }
                    else
                    {
                        showAnySchedulerButtons = false;
                        showCancelButton        = false;
                    }
                }
            }

            foreach (SkillDef skill in skills)
            {
                if (!skill.isPassive && skill.isActive && skill is ActionSkillDef && !(skill is MoveSkillDef || skill is WaitSkillDef))
                {
                    ActionSkillDef ask = skill as ActionSkillDef;
                    if (a.IsLocalTeam(ac.EffectiveTeamID))
                    {
                        if (ask.RequireConfirmation &&
                            ask.AwaitingConfirmation)
                        {
                            bool yesButton = false, noButton = false;
                            OnGUIConfirmation("Confirm?", out yesButton, out noButton);
                            if (yesButton)
                            {
                                ask.ApplyCurrentTarget();
                            }
                            if (noButton)
                            {
                                ask.AwaitingConfirmation = false;
                            }
                        }
                        showAnySchedulerButtons = false;
                    }
                }
            }
            WaitSkillDef ws = ac.waitSkill;
            if (ws != null && ws.isActive)
            {
                if (a.IsLocalTeam(ac.EffectiveTeamID))
                {
                    if (ws.RequireConfirmation &&
                        ws.AwaitingConfirmation)
                    {
                        bool yesButton = false, noButton = false;
                        OnGUIConfirmation("Wait here?", out yesButton, out noButton);
                        if (yesButton)
                        {
                            ws.ApplyCurrentTarget();
                        }
                        if (noButton)
                        {
                            ws.AwaitingConfirmation = false;
                        }
                    }
                    else
                    {
                        showCancelButton = permitMultipleMoves || permitMultipleActions || !(activeCharacterHasMoved && activeCharacterHasActed);
                    }
                    showAnySchedulerButtons = false;
                }
            }
        }
        if (s is CTScheduler)
        {
            if (ac != null && a.IsLocalTeam(ac.EffectiveTeamID))
            {
                GUILayout.BeginArea(new Rect(
                                        8, 8,
                                        128, 240
                                        ));
                GUILayout.Label("Character:" + ac.gameObject.name);
                GUILayout.Label("HP: " + Mathf.Ceil(ac.GetStat("health", ac.GetStat("HP"))));
                GUILayout.Label("CT: " + Mathf.Floor(ac.GetStat((s as CTScheduler).ctStat)));

                //TODO:0: support skills
                //show list of skills
                SkillDef activeSkill = null;
                foreach (SkillDef sk in skills)
                {
                    if (sk.isActive)
                    {
                        activeSkill = sk;
                        break;
                    }
                }
                if (activeSkill == null)
                {
                    //root: move, act group, wait
                    var nextSel = OnGUISkillGroup(ac, skills, selectedGroup);
                    selectedGroup = nextSel == null ? null : nextSel.ToList();
                }
                else if (showCancelButton)
                {
                    if (GUILayout.Button("Cancel " + activeSkill.skillName))
                    {
                        activeSkill.Cancel();
                    }
                }
                GUILayout.EndArea();
            }
        }
        else if (s is TeamRoundsPickAnyOnceScheduler)
        {
            TeamRoundsPickAnyOnceScheduler tps = s as TeamRoundsPickAnyOnceScheduler;
            GUILayout.BeginArea(new Rect(
                                    8, 8,
                                    110, 240
                                    ));
            GUILayout.Label("Current Team:" + tps.currentTeam);
            if (ac != null)
            {
                GUILayout.Label("Character:" + ac.gameObject.name);
                GUILayout.Label("Health: " + Mathf.Ceil(ac.GetStat("health")));
                //show list of skills
                SkillDef activeSkill = null;
                foreach (SkillDef sk in skills)
                {
                    if (sk.isActive)
                    {
                        activeSkill = sk;
                        break;
                    }
                }
                if (activeSkill == null)
                {
                    //root: move, act group, wait
                    var nextSel = OnGUISkillGroup(ac, skills, selectedGroup);
                    selectedGroup = nextSel == null ? null : nextSel.ToList();
                }
                else if (showCancelButton)
                {
                    if (GUILayout.Button("Cancel " + activeSkill.skillName))
                    {
                        activeSkill.Cancel();
                    }
                }
            }
            else
            {
                GUILayout.Label("Click any team member");
            }
            if (a.IsLocalTeam(tps.currentTeam))
            {
                if (showAnySchedulerButtons &&
                    !(ac != null && ac.moveSkill.Executor.IsMoving) &&
                    GUILayout.Button("End Round"))
                {
                    tps.EndRound();
                }
            }
            GUILayout.EndArea();
        }
        else if (s is TeamRoundsPointsScheduler)
        {
            TeamRoundsPointsScheduler tps = s as TeamRoundsPointsScheduler;
            if (a.IsLocalTeam(tps.currentTeam))
            {
                GUILayout.BeginArea(new Rect(
                                        8, 8,
                                        110, 240
                                        ));
                GUILayout.Label("Current Team: " + tps.currentTeam);
                GUILayout.Label("Points Left: " + tps.pointsRemaining);
                if (ac != null)
                {
                    GUILayout.Label("Character:" + ac.gameObject.name);
                    GUILayout.Label("Health: " + Mathf.Ceil(ac.GetStat("health")));
                    RoundPointsCharacter rpc = ac.GetComponent <RoundPointsCharacter>();
                    GUILayout.Label("AP: " + Mathf.Floor(rpc.Limiter));

                    //show list of skills
                    SkillDef activeSkill = null;
                    foreach (SkillDef sk in skills)
                    {
                        if (sk.isActive)
                        {
                            activeSkill = sk;
                            break;
                        }
                    }
                    if (activeSkill == null)
                    {
                        //root: move, act group, wait
                        var nextSel = OnGUISkillGroup(ac, skills, selectedGroup);
                        selectedGroup = nextSel == null ? null : nextSel.ToList();
                    }
                    else if (showCancelButton)
                    {
                        if (GUILayout.Button("Cancel " + activeSkill.skillName))
                        {
                            activeSkill.Cancel();
                        }
                        if (showAnySchedulerButtons &&
                            activeSkill is MoveSkillDef &&
                            !(activeSkill as MoveSkillDef).Executor.IsMoving)
                        {
                            if (GUILayout.Button("End Move"))
                            {
                                //??
                                activeSkill.ApplySkill();
                            }
                        }
                    }
                }
                else
                {
                    if (showAnySchedulerButtons &&
                        !(ac != null && ac.moveSkill.Executor.IsMoving) &&
                        GUILayout.Button("End Round"))
                    {
                        tps.EndRound();
                    }
                }
                GUILayout.EndArea();
            }
        }
        else if (s is TeamRoundsInitiativeScheduler || s is RoundsInitiativeScheduler)
        {
            GUILayout.BeginArea(new Rect(
                                    8, 8,
                                    110, 240
                                    ));
            TeamRoundsInitiativeScheduler tis = s as TeamRoundsInitiativeScheduler;
            if (tis != null)
            {
                GUILayout.Label("Current Team:" + tis.currentTeam);
            }
            if (ac != null)
            {
                GUILayout.Label("Character:" + ac.gameObject.name);
                GUILayout.Label("Health: " + Mathf.Ceil(ac.GetStat("health")));
                //show list of skills
                SkillDef activeSkill = null;
                foreach (SkillDef sk in skills)
                {
                    if (sk.isActive)
                    {
                        activeSkill = sk;
                        break;
                    }
                }
                if (activeSkill == null)
                {
                    //root: move, act group, wait
                    var nextSel = OnGUISkillGroup(ac, skills, selectedGroup);
                    selectedGroup = nextSel == null ? null : nextSel.ToList();
                }
                else if (showCancelButton)
                {
                    if (GUILayout.Button("Cancel " + activeSkill.skillName))
                    {
                        activeSkill.Cancel();
                    }
                }
            }
            GUILayout.EndArea();
        }
    }
예제 #8
0
 private static bool Move(UnitOrder order)
 {
     return(MoveExecutor.Execute(order));
 }