protected override void PerformNextAction() { Kernel kernel = battle.GetKernelClone(); List <KAction> actions = kernel.getAllValidActions().CastToList <KAction>(); Debug.Assert(actions.Count > 0); if (actions.Count == 1) { Debug.Assert(actions[0].GetType() == typeof(EndTurnAction)); battle.PerformAction(null, null, EndTurnAction.ID); } else { var nonEndTurnActions = actions.Where(x => x.GetType() != typeof(EndTurnAction)).ToList(); int rndIdx = rnd.Next(nonEndTurnActions.Count); KAction randomAction = nonEndTurnActions[rndIdx]; UDebug.Log(Name + ": " + randomAction.toString()); var randomTargetable = randomAction as TargetableAction; if (randomTargetable != null) { battle.PerformAction(randomTargetable.getContext().source, randomTargetable.getContext().target, randomAction.getId()); } else { battle.PerformAction(null, null, randomAction.getId()); } } }
protected void PerformAction(KAction action) { Debug.Log(Name + ": " + action.toString()); var targetableAction = action as TargetableAction; if (targetableAction != null) { battle.PerformAction(targetableAction.getContext().source, targetableAction.getContext().target, action.getId()); } else { battle.PerformAction(null, null, action.getId()); } }