//TODO: Update to use Directions enum public bool Move(Level currentLevel, int dir) { #region Array of positions Vector2[] newPos = new Vector2[10]; newPos[1] = new Vector2(this.pos.X - 1, this.pos.Y + 1); //1 newPos[2] = new Vector2(this.pos.X, this.pos.Y + 1); //2 newPos[3] = new Vector2(this.pos.X + 1, this.pos.Y + 1); //3 newPos[4] = new Vector2(this.pos.X - 1, this.pos.Y); //4 newPos[6] = new Vector2(this.pos.X + 1, this.pos.Y); //6 newPos[7] = new Vector2(this.pos.X - 1, this.pos.Y - 1); //7 newPos[8] = new Vector2(this.pos.X, this.pos.Y - 1); //8 newPos[9] = new Vector2(this.pos.X + 1, this.pos.Y - 1); //9 #endregion if (!currentLevel.IsCreatureAt(newPos[dir]) && //If no creature's there and.. currentLevel.tileArray[(int)newPos[dir].X, (int)newPos[dir].Y].isPassable) //...the tile is passable... { this.pos = newPos[dir]; if (confusion > 0 && rngDie.Roll(2) == 1) //If confused, then half the time... { dir = rng.Next(1,9); //1-8 //Randomize movement if (dir >= 5) dir++; //Skip 5 } if (!String.IsNullOrEmpty(currentLevel.tileArray[newPos[dir].X, newPos[dir].Y].engraving)) { message.Add("Something is written here:"); message.Add(currentLevel.tileArray[newPos[dir].X, newPos[dir].Y].engraving); //Any message here } if (currentLevel.tileArray[pos.X, pos.Y].fixtureLibrary.Count > 0) //Check what's there, if anything { foreach (Fixture f in currentLevel.tileArray[pos.X, pos.Y].fixtureLibrary) { if (f is Trap) //General Ackbar: "IT'S A TRAP!" { Trap t = (Trap)f; //"No, f, you are the traps. And then f was a trap if (t.effect.type == "tripwire" && !(isPlayer && t.visible)) //If it's a tripwire... KEEP WORKING HERE { if (isPlayer || currentLevel.LineOfSight(currentLevel.creatures[0].pos, pos)) { t.visible = true; //We know it's here now } //t.armed = false; //Should this be disarmed when tripped over? message.Add("You trip over a tripwire."); //WHOOPS status_paralyzed += (byte)t.effect.magnitude; } } } } //If there's an item on the tile if (currentLevel.tileArray[pos.X, pos.Y].itemList.Count > 0) { message.Add("There is a " + currentLevel.tileArray[pos.X, pos.Y].itemList[0].name + " here."); } return true; //Moving took a turn } else if (currentLevel.tileArray[(int)newPos[dir].X, (int)newPos[dir].Y].isDoor && isDextrous) { OpenDoor(currentLevel.tileArray[(int)newPos[dir].X, (int)newPos[dir].Y], currentLevel); message.Add("You open a door"); return true; //Door opening took a turn } return false; //Didn't spend a turn }
public Level Eat(Level currentLevel, Item eatItem) { int itemIndex = inventory.IndexOf(eatItem); this.message.Add("You ingest the " + eatItem.name + "."); if (currentLevel.LineOfSight(currentLevel.creatures[0].pos, this.pos) && currentLevel.creatures[0].pos != this.pos) //If the player sees it and it's not the player { currentLevel.creatures[0].message.Add("The " + this.name + " ingests a " + eatItem.name + "."); } currentLevel = inventory[itemIndex].Eat(currentLevel, this); return currentLevel; }