public static int follow(MapObjects.Player player, MapObjects.Monster monster, DrawEnvironment.Field [,] board) { int direction = -1; //sth dsnt work->invalid direction bool found = false; Ant.setBoard(board); List <Ant> ants = new List <Ant>(); ; if (board[monster.position.posx, monster.position.posy - 1].type == DrawEnvironment.fieldtype.EMPTY) { ants.Add(new Ant(board[monster.position.posx, monster.position.posy], 0, 0, 0)); // Ant nach oben } if (board[monster.position.posx + 1, monster.position.posy].type == DrawEnvironment.fieldtype.EMPTY) { ants.Add(new Ant(board[monster.position.posx, monster.position.posy], 1, 1, 0)); //Ant nach rechts } if (board[monster.position.posx, monster.position.posy + 1].type == DrawEnvironment.fieldtype.EMPTY) { ants.Add(new Ant(board[monster.position.posx, monster.position.posy], 2, 2, 0)); //Ant nach unten } if (board[monster.position.posx - 1, monster.position.posy].type == DrawEnvironment.fieldtype.EMPTY) { ants.Add(new Ant(board[monster.position.posx, monster.position.posy], 3, 3, 0)); //Ant nach links } while (ants.Count != 0) { List <Ant> newAnts = new List <Ant>(); List <Ant> deadAnts = new List <Ant>(); foreach (Ant ant in ants) { if (!ant.alive) { deadAnts.Add(ant); continue; } newAnts.AddRange(ant.crawl()); if (ant.position == player.position) { direction = ant.firstDirection; return(direction); } } foreach (Ant a in deadAnts) { ants.Remove(a); } ants.AddRange(newAnts); } return(direction); }
private void interactableEncounter(object sender, EventArgs e) { if (sender.GetType() == typeof(MapObjects.Monster)) { MapObjects.Monster monster = (MapObjects.Monster)sender; interactionWindow = monster.interact(m.player); interactionWindow.Show(); m.timer.Stop(); timer1.Stop(); m.interactables.Remove(monster); m.monster.Remove(monster); monsterDead = true; interactionWindow.FormClosed += interactionForm_Close; } }
private void Timer_Tick(object sender, EventArgs e) { foreach (MapObjects.Interactable i in interactables) { if (player.position == i.position && i.GetType() == typeof(MapObjects.Monster)) //später ändern { MapObjects.Monster mo = (MapObjects.Monster)i; corps = new MapObjects.Stash(ref mo.position, mo.inventory, "corps"); //@todo trade dialog stash player interactables.Add(corps); OnMonsterEncounter(i); return; } } if (player.position.type == DrawEnvironment.fieldtype.EXIT && monster.Count() == 0) { MessageBox.Show("You won!"); } }
public static void combat(MapObjects.Monster monster, MapObjects.Player player) { }