void ApplyAction(SingleAction sa_) { switch (sa_.type) { case (ActionType.Skill): CastSkill(sa_.key, sa_.location, sa_.actorKey); break; case (ActionType.Move): CastMove(sa_.location, sa_.actorKey); break; case (ActionType.TakeDamage): ApplyDamageAction(sa_); break; } }
//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); }
void ApplyDamageAction(SingleAction sa_) { actors[sa_.actorKey].hp -= sa_.damage; actors[sa_.actorKey].currentAction = ActionType.TakeDamage; }