public MapMole(DrawEnvironment.Field pos, int dir, int ttl, int moleSpawnProb) { this.position = pos; this.direction = dir; this.ttl = ttl; this.moleSpawnProb = moleSpawnProb; alive = true; }
public MapMole dig() { if (!alive) { throw new InvalidOperationException("RIP mole"); } position.type = DrawEnvironment.fieldtype.EMPTY; if (!checkDir(direction) && !changeDir()) { alive = false; return(null); } switch (direction) { case 0: position = board[position.posx, position.posy - 1]; break; case 1: position = board[position.posx + 1, position.posy]; break; case 2: position = board[position.posx, position.posy + 1]; break; case 3: position = board[position.posx - 1, position.posy]; break; default: throw new InvalidOperationException(" mole with invalid digging direction: " + direction); } //position.type = DrawEnvironment.fieldtype.EMPTY; if (--ttl <= 0) // RIP mole { alive = false; return(null); } int diceroll = rnd.Next(1, 100); if (diceroll <= dirChangePrb) { changeDir(); } if (diceroll <= moleSpawnProb) { int spawn = rnd.Next(0, 50); return(new MapMole(position, diceroll % 4, diceroll % maxttl + 1, spawn)); //+1 für Totgeburten } return(null); }
public Ant(DrawEnvironment.Field pos, int direction, int firstDir, int steps) { this.position = pos; this.direction = direction; this.firstDirection = firstDir; this.stepCounter = steps; if (!checkDir(direction)) //raus? { this.alive = false; } else { this.alive = true; } }
public List <Ant> crawl() { if (alive) { List <Ant> newAnts = new List <Ant>(); switch (direction) { case 0: position = board[position.posx, position.posy - 1]; break; case 1: position = board[position.posx + 1, position.posy]; break; case 2: position = board[position.posx, position.posy + 1]; break; case 3: position = board[position.posx - 1, position.posy]; break; default: throw new InvalidOperationException(" Ant with invalid crawling direction: " + direction); } stepCounter++; if (stepCounter > maxSteps) { alive = false; return(newAnts); } if (checkDirRelative(0) && checkDirRelative(1) && checkDirRelative(3)) // wenn vor dir rechts links frei { newAnts.Add(new Ant(position, turn(3), firstDirection, stepCounter)); newAnts.Add(new Ant(position, turn(1), firstDirection, stepCounter)); } else if (checkDirRelative(0) && checkDirRelative(1)) // wenn vor dir und rechts frei { newAnts.Add(new Ant(position, turn(1), firstDirection, stepCounter)); } else if (checkDirRelative(0) && checkDirRelative(3))//wenn vor dir und links { newAnts.Add(new Ant(position, turn(3), firstDirection, stepCounter)); } else if (checkDirRelative(1) && checkDirRelative(3)) //rechts links { direction = turn(1); newAnts.Add(new Ant(position, turn(3), firstDirection, stepCounter)); } else if (checkDirRelative(1)) // rechts { direction = turn(1); } else if (checkDirRelative(3)) //links { direction = turn(3); } else if (checkDirRelative(0)) //vorne { direction = turn(0); } else { alive = false; } return(newAnts); } else { throw new InvalidOperationException("dead ant can't crawl"); } }
public Dungeon.Model model; // protected public Creature(ref DrawEnvironment.Field field, Inventory.Inventory inventory, Color color, int hp, string name, Dungeon.Model m) : base(ref field, inventory, color) { this.hp = hp; this.name = name; this.model = m; }
public Interactable(ref DrawEnvironment.Field field, Inventory.Inventory inventory, Color color) { this.position = field; this.inventory = inventory; this.color = color; }
public Stash(ref DrawEnvironment.Field field, Inventory.Inventory inventory, string name) : base(ref field, inventory, Color.CadetBlue) { this.name = name; }
public Merchant(ref DrawEnvironment.Field field, int hp, Dungeon.Model m) : base(ref field, new Inventory.Inventory(), Color.DarkMagenta, hp, "Merchant", m) { }
public Player(ref DrawEnvironment.Field field, int hp, Dungeon.Model m) : base(ref field, new Inventory.Inventory(100), Color.DarkGreen, hp, "Player", m) { }
public Monster(ref DrawEnvironment.Field field, int hp, Dungeon.Model m) : base(ref field, new Inventory.Inventory(), Color.Crimson, hp, "Monster", m) { }