public Character CreateEnemy(string name) { var ch = new Character() { Name = name, Faction = Faction.Foe, Position = new Vector2(rand.NextFloat(0, 600), rand.NextFloat(0, 600)), IsAlive = true }; var stats = ch.Stats; var hp = stats.AddBaseStat("hp_now", 50, 3); stats.AddBaseStat("hp_max", hp); var mp = stats.AddBaseStat("mp_now", 25, 3); stats.AddBaseStat("mp_max", mp); stats.AddBaseStat("attack_damage", 3, 3); stats.AddBaseStat("strength", 5, 3); stats.AddBaseStat("vitality", 5, 3); stats.AddBaseStat("intellect", 5, 3); stats.AddBaseStat("mind", 5, 3); stats.AddBaseStat("speed", 3, 2); return ch; }
public static Character CreatePlayer(string name) { var ch = new Character() { Name = name, Faction = Faction.Ally, Distance = rand.Next(10, 100), IsAlive = true }; var stats = ch.Stats; var hp = stats.AddBaseStat("hp_now", 70, 3); stats.AddBaseStat("hp_max", hp); var mp = stats.AddBaseStat("mp_now", 35, 3); stats.AddBaseStat("mp_max", mp); stats.AddBaseStat("attack_damage", 4, 3); stats.AddBaseStat("strength", 5, 3); stats.AddBaseStat("vitality", 5, 3); stats.AddBaseStat("intellect", 5, 3); stats.AddBaseStat("mind", 5, 3); stats.AddBaseStat("speed", 3, 2); return ch; }
public void Turn(Level level, float dt) { //check if ability is still valid if (currentAction > -1 && !ActionList[currentAction].Ability.CanUse(level, this, currentTarget)) { //cancel currentAction = -1; AP = 0; currentTarget = null; } //will check all actions or the 1 up to the currentAction (for canceling) var maxAction = currentAction == -1 ? ActionList.Count : currentAction; for (var i = 0; i < maxAction; i++) { //found either a new action to run or higher priority action if (ActionList[i].Check(level, this)) { if (currentAction > -1) { //cancel (don't clear target because Check set the new one) } currentAction = i; AP = 0; break; } } if (currentAction > -1) { var action = ActionList[currentAction]; var ability = action.Ability; LastAction = ability.Name; var distance = Vector2.Distance(Position, currentTarget.Position); if (distance > ability.MaxDistance) { //move closer var dir = (currentTarget.Position - Position); dir.Normalize(); dir *= (dt * 100); Position += dir; } else { AP += ability.ChargeRate * APRechargeRate * dt; if (AP >= 100) { ability.Use(level, this, currentTarget); AP = 0; currentTarget = null; currentAction = -1; Turn(level, dt); } } } else { LastAction = "Idle"; } }
public bool IsAlly(Character other) { return !Faction.IsHostile(other.Faction); }
public bool Check(Level level, Character actor) { return Condition(level, actor, Ability); }
public IEnumerable<Character> IsFoe(Character actor) { return Characters.Where(x => x.Faction.IsHostile(actor.Faction)); }