Example #1
0
        //AI
        public Turn getBestOption()
        {
            Turn t           = new Turn(new SingleAction[] { new SingleAction(ActionType.Move, 10, actors[actorKey].tsPos, actorKey) });
            int  bestFitness = 0;

            for (int k = 0; k < CurrentActor().skills.Count; k++)
            {
                foreach (Creature c in inRangeActors(pointsInRange(CurrentActor().tsPos, CurrentActor().skills[k].range)))
                {
                    int fitness = 0;
                    fitness = CurrentActor().skills[k].damage;

                    if (fitness > bestFitness)
                    {
                        bestFitness = fitness;

                        SingleAction option = new SingleAction(ActionType.Skill, k, c.tsPos, actorKey);
                        t = new Turn(new SingleAction[] { option });
                    }
                }
            }
            return(t);
        }
Example #2
0
        void UpdateGame(GameTime gt_)
        {
            UpdateTranslation();
            if (GetPressed("unzoom"))
            {
                zoom -= 0.1f;
            }
            if (GetPressed("zoom"))
            {
                zoom += 0.1f;
            }
            if (GetPressed("menu"))
            {
                gm = GameMode.Menus; SetupMenu();
            }

            if (QueueResolved())
            {
                if (CurrentActor().isPlayer)
                {
                    switch (gim)
                    {
                    case (GameInputMode.ActorMenu):
                        break;

                    case (GameInputMode.CastSkill):
                        UpdateSkillCasting();
                        break;

                    case (GameInputMode.MoveActor):
                        Move();
                        break;
                    }
                }
                else
                {
                    Turn t = getBestOption();
                    foreach (SingleAction sa in t.options)
                    {
                        actionQueue.Add(sa);
                        ToggleNextActor();
                    }
                }
                if (CurrentActor().AP == 0)
                {
                    ToggleNextActor();
                }
            }
            else
            {
                UpdateQueue();
            }
            PositionToTile(guy);
            PositionToTile(enemy);

            foreach (Creature c in actors)
            {
                c.Update(gt_);
            }

            CheckButtons();
        }