/** * Mouse tries to escape then it loses the fight. It can't escape form Snake. * It escape to nearbyEmptyLocation, if there is no place to escape it dies. */ override public bool Collision(World world, Organism attackingOrganism) { if (this.Strength > attackingOrganism.Strength) { // attacking organism lost MainWindow.logInfo += this.ToString() + "(" + this.Strength + ") and dies to it.\n"; return(false); } else { // attacking organism win int location = world.GenerateNearbyEmptyLocation(this.Location); // Mouse tries to escpae if ((location != -1) && (attackingOrganism.GetType().Name != "Snake")) { // and succeded world.AddToBoard(location, this); world.NullToBoard(this.Location); this.Location = location; MainWindow.logInfo += this.ToString() + "(" + this.Strength + ") and chase it away to (" + location % world.Size + "," + location / world.Size + ").\n"; } else // can't escape, no place to escape or Snake attacking { MainWindow.logInfo += this.ToString() + "(" + this.Strength + ") and kills it because it failed to escape.\n"; world.NullToBoard(this.Location); this.Alive = true; } return(true); } }
/** When a ThornEater attacks Thorn and eats it, it gains 2 Strength */ override public bool Collision(World world, Organism attackingOrganism) { if (this.Strength > attackingOrganism.Strength) { MainWindow.logInfo += this.ToString() + "(" + this.Strength + ") and dies to its thorns.\n"; return(false); } else { MainWindow.logInfo += this.ToString() + "(" + this.Strength + ") and eats it"; if (attackingOrganism.GetType().Name == "ThornEater") { attackingOrganism.AddStrength(2); MainWindow.logInfo += " gaining 2 Strength"; } world.NullToBoard(Location); this.Alive = false; Console.WriteLine("."); return(true); } }