public void Run(Agent.Creature creature, Point chaserPos, OperacjeMapy.Pole[,] mapa) { var ai = new BasicAIDij(); var random = new Random(); var r = creature.currentpossition; var c = chaserPos; var vectorX = r.X - c.X; var vectorY = r.Y - c.Y; var adjPassPoints = GetAdjecentPassablePoints(mapa, r); var escapeTo = new Point(r.X + vectorX, r.Y + vectorY); if (adjPassPoints.Contains(escapeTo)) { ai.GoTo(r, escapeTo, mapa, creature); } else { var rand = random.Next(0, adjPassPoints.Count); ai.GoTo(r, adjPassPoints[rand], mapa, creature); } }
public void AttackMapEntity(Agent.Creature attacker, OperacjeMapy.Pole[,] mapa, Point defender) { BasicAIDij ai = new BasicAIDij(); Random r = new Random(); int damageDone = r.Next(1, 10); var kill = new KillAgent(defender, mapa, CreaturesToDo.FindEntity.KindOfEntity.mapEntity); bool defenderIsAdjacent; int aPX = attacker.currentpossition.X; int aPY = attacker.currentpossition.Y; int dPX = defender.X; int dPY = defender.Y; if (aPX - 1 == dPX && aPY == dPY) { defenderIsAdjacent = true; } else if (aPX + 1 == dPX && aPY == dPY) { defenderIsAdjacent = true; } else if (aPX == dPX && aPY + 1 == dPY) { defenderIsAdjacent = true; } else if (aPX == dPX && aPY - 1 == dPY) { defenderIsAdjacent = true; } else if (aPX - 1 == dPX && aPY - 1 == dPY) { defenderIsAdjacent = true; } else if (aPX - 1 == dPX && aPY + 1 == dPY) { defenderIsAdjacent = true; } else if (aPX + 1 == dPX && aPY - 1 == dPY) { defenderIsAdjacent = true; } else if (aPX + 1 == dPX && aPY + 1 == dPY) { defenderIsAdjacent = true; } else { defenderIsAdjacent = false; } if (defenderIsAdjacent) { Console.WriteLine("DefenderIsAdjacent: {0}", defenderIsAdjacent); Console.WriteLine("Hadzia!"); var dmg = Convert.ToByte(r.Next(attacker.weaponsWielded[0].minDamage, attacker.weaponsWielded[0].maxDamage)); mapa[dPX, dPY].mapEntities.HP -= dmg; if (mapa[dPX, dPY].mapEntities.HP <= 0) { kill.Kill(); } } else { Console.WriteLine("DefenderIsAdjacent: {0}", defenderIsAdjacent); ai.GoTo(attacker.currentpossition, defender, mapa, attacker); } //return mapa; }
public void Roam(Agent.Creature creature, OperacjeMapy.Pole[,] mapa) { Random r = new Random(Guid.NewGuid().GetHashCode()); BasicAIDij ai = new BasicAIDij(); //Point whereTo = new Point(); //whereTo = creature.currentpossition; var adjecent = new List <Point>(); adjecent = GetAdjecentPassablePoints(mapa, creature.currentpossition); int randDir = r.Next(0, adjecent.Count); ai.GoTo(creature.currentpossition, adjecent[randDir], mapa, creature); /*switch (randDir){ * case 1: * { * whereTo.X--; * whereTo.Y++; * ai.GoTo(creature.currentpossition, whereTo, mapa, creature); * break; * } * case 2: * { * whereTo.Y++; * ai.GoTo(creature.currentpossition, whereTo, mapa, creature); * break; * } * case 3: * { * whereTo.X++; * whereTo.Y++; * ai.GoTo(creature.currentpossition, whereTo, mapa, creature); * break; * } * case 4: * { * whereTo.X--; * ai.GoTo(creature.currentpossition, whereTo, mapa, creature); * break; * } * case 5: * { * * break; * } * case 6: * { * whereTo.X++; * ai.GoTo(creature.currentpossition, whereTo, mapa, creature); * break; * } * case 7: * { * whereTo.X--; * whereTo.Y--; * ai.GoTo(creature.currentpossition, whereTo, mapa, creature); * break; * } * case 8: * { * * whereTo.Y--; * ai.GoTo(creature.currentpossition, whereTo, mapa, creature); * break; * } * case 9: * { * whereTo.X++; * whereTo.Y--; * ai.GoTo(creature.currentpossition, whereTo, mapa, creature); * break; * } * } */ }
public void Attack(Agent.Creature attacker, OperacjeMapy.Pole[,] mapa, Agent.Creature defender) { BasicAIDij ai = new BasicAIDij(); Random r = new Random(); int damageDone = r.Next(1, 10); bool defenderIsAdjacent; int aPX = attacker.currentpossition.X; int aPY = attacker.currentpossition.Y; int dPX = defender.currentpossition.X; int dPY = defender.currentpossition.Y; if (aPX - 1 == dPX && aPY == dPY) { defenderIsAdjacent = true; } else if (aPX + 1 == dPX && aPY == dPY) { defenderIsAdjacent = true; } else if (aPX == dPX && aPY + 1 == dPY) { defenderIsAdjacent = true; } else if (aPX == dPX && aPY - 1 == dPY) { defenderIsAdjacent = true; } else if (aPX - 1 == dPX && aPY - 1 == dPY) { defenderIsAdjacent = true; } else if (aPX - 1 == dPX && aPY + 1 == dPY) { defenderIsAdjacent = true; } else if (aPX + 1 == dPX && aPY - 1 == dPY) { defenderIsAdjacent = true; } else if (aPX + 1 == dPX && aPY + 1 == dPY) { defenderIsAdjacent = true; } else { defenderIsAdjacent = false; } if (defenderIsAdjacent) { Console.WriteLine("DefenderIsAdjacent: {0}", defenderIsAdjacent); Console.WriteLine("Hadzia!"); } else { Console.WriteLine("DefenderIsAdjacent: {0}", defenderIsAdjacent); ai.GoTo(attacker.currentpossition, defender.currentpossition, mapa, attacker); } //return mapa; }