Exemplo n.º 1
0
        //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
        }
Exemplo n.º 2
0
 public bool CanAttackMelee(Level currentLevel, Directions dir)
 {
     return currentLevel.IsCreatureAt(pos.AdjacentVector(dir));
 }
Exemplo n.º 3
0
        public bool InMeleeRange(Level currentLevel)
        {
            #region Array of positions
            Vector2[] newPos = new Vector2[9];
            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

            for (int i = 1; i <= 9; i++)
            {
                if (i == 5)
                    i++; //Skip over position 5

                if (currentLevel.IsCreatureAt(newPos[i])) //If there's a creature in any direction
                    return true;
            }

            return false;
        }
Exemplo n.º 4
0
        public int AdjacentToCreatureDir(Level currentLevel)
        {
            #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

            for (int i = 1; i <= 9; i++)
            {
                if (i == 5)
                    i++; //Skip position 5

                if (currentLevel.IsCreatureAt(newPos[i]))
                {
                    return i;
                }
            }

            return -1;
        }