Пример #1
0
        private PassCode pc; //passcode for case

        #endregion Fields

        #region Constructors

        /*
         * Gives each place in the Floor a Tile class
         *
         * See Tile for more information
         */
        public Floor(int number, PassCode pc, bool[] have, Coordinate[] elevators, GameState gs)
        {
            this.number = number;
            this.floor = new Tile[Globals.FLOOR_LENGTH, Globals.FLOOR_WIDTH];
            this.doorPC = null;
            this.elevators = new Coordinate[Constants.NUM_ELEVATORS];
            this.coordinates = new ArrayList();

            //Prevent certain items from overlapping on the same tile

            for (int i = 0; i < Globals.FLOOR_LENGTH; i++)
                for (int j = 0; j < Globals.FLOOR_WIDTH; j++)
                {
                    floor[i, j] = new Tile();
                    Constants.taken[i, j] = false;
                }

            for (int i = 0; i < Constants.NUM_ELEVATORS; i++)
            {
                Constants.taken[elevators[i].x, elevators[i].y] = true;
            }

            //Call a random architect function
            int x = Constants.randGen.Next(0, architect.GetUpperBound(0) + 1);
            architect[x](this, Constants.taken);

            if (number == 1) firstFloorSetup(Constants.taken);

            storeElevatorCoords(Constants.taken, elevators);
            setUpPassCode(pc);

            putItems(Constants.taken, have);
            putHourglasses(Constants.taken);
        }
        public bool matchCode(PassCode pc)
        {
            for (int i = 0; i < Constants.CODE_LENGTH; i++)
                if (this.pc.code[i] != pc.code[i]) return false;

            this.locked = false;
            return true;
        }
        private PassCode pc; //passcode

        #endregion Fields

        #region Constructors

        //call base class constructor
        public Case(String name, String hint, PassCode pc, bool locked)
            : base(name, hint)
        {
            this.pc = pc;
            this.locked = locked;
        }
        //default constructor with an inital state
        public GameState(int difficulty, String playerName)
        {
            this.playerName = playerName;
            this.difficulty = difficulty;
            switch (difficulty)
            {
                case 0: //easy
                    floorNumber = Constants.EASY_NUM_FLOORS;
                    break;
                case 1: //medium
                    floorNumber = Constants.MED_NUM_FLOORS;
                    break;
                default: //hard
                    floorNumber = Constants.HARD_NUM_FLOORS;
                    break;
            }
            pc = null;
            coord = new Coordinate(0, 0);
            caseLocked = true;

            this.have = new bool[Constants.NUM_ITEMS];

            //set all too false, player doesn't have anything
            for (int i = 0; i < Constants.NUM_ITEMS; i++)
                this.have[i] = false;
        }
        public GameState(int difficulty, String playerName, int floorNumber,
                         PassCode pc, Coordinate coord, bool caseLocked,
                         bool[] have, String caseHint)
        {
            this.playerName = playerName;
            this.difficulty = difficulty;
            this.floorNumber = floorNumber;
            this.pc = pc;
            this.coord = coord;
            this.caseLocked = caseLocked;
            this.caseHint = caseHint;

            this.have = new bool[Constants.NUM_ITEMS];

            for(int i = 0; i < Constants.NUM_ITEMS; i++)
                this.have[i] = have[i];
        }
        private PassCode pc; //passcode

        #endregion Fields

        #region Constructors

        //can't pickup, is not a barrier
        public Door(PassCode pc, bool locked)
            : base("Door", false, false)
        {
            this.pc = new PassCode(pc.code[0], pc.code[1], pc.code[2]);
            this.locked = locked;
        }
Пример #7
0
        public DoorState tryUnlockDoor(PassCode pc)
        {
            Door door;
            if ((door = floor.refDoor(coord)) == null) return DoorState.NOTNEAR;

            if (!door.isLocked()) return DoorState.STALL;

            if (door.matchCode(pc)) return DoorState.UNLOCKED;

            return DoorState.LOCKED;
        }
Пример #8
0
        public CaseState tryUnlock(PassCode pc)
        {
            foreach (Item item in inventory)
                if (item.name() == Constants.ITEMS[(int)iName.SECRETCASE])
                {
                    if (!((Case)item).isLocked())
                        return CaseState.STALL; //case already unlocked

                    if (((Case)item).matchCode(pc) == true)
                        return CaseState.UNLOCKED; //case unlocked!

                    return CaseState.LOCKED; //bad pass code attempt
                }

            return CaseState.NOTHAVE;//player does not have case
        }
Пример #9
0
 private void setUpPassCode(PassCode pc)
 {
     //Random decimal pass code
     if (pc == null)
     {
         this.pc = new PassCode(Constants.randGen.Next(0, 10),
                                Constants.randGen.Next(0, 10),
                                Constants.randGen.Next(0, 10));
     }
     else this.pc = pc;
 }
Пример #10
0
        private void firstFloorSetup(bool[,] taken)
        {
            //Only needed on floor 1
            //May need to pass a doorPC from database
            this.doorPC = new PassCode(Constants.randGen.Next(0, 10),
                                       Constants.randGen.Next(0, 10),
                                       Constants.randGen.Next(0, 10));

            int x, y;

            do
            {
                x = Constants.randGen.Next(0, Globals.FLOOR_LENGTH);
                y = Constants.randGen.Next(0, Globals.FLOOR_WIDTH);
            } while (taken[x, y]);

            floor[x, y].Obj = new Door(this.doorPC, true);

            taken[x, y] = true;

            this.coordinates.Add(new NamedCoord("Door", new Coordinate(x, y), floor[x, y].Obj.getID()));
        }