Example #1
0
        /*
         * to be used with an UPDATE PATTERN?
         * maybe put a random direction in and update position?
         */
        public void npc_move(string direction)
        {
            //first we need to get the current room
            //the player is in so we can see where to move
            Room room = Non_PLayer.npc_get_room();

            if (!room.has_exit(direction))
            {
                Text_Buffer.Add("NPC can't go that way.");
                return; // return out of the method so another command can be given
            }

            room.remove_enemy(Game_Manager.enemy);
            ;

            switch (direction)
            {
            case Direction._north:
                Game_Manager.enemy._Y_Position--;     //move up one on the grid
                room.add_enemy(Game_Manager.enemy);
                break;

            case Direction._south:
                Game_Manager.enemy._Y_Position++;      //move down one on the grid
                room.add_enemy(Game_Manager.enemy);
                break;

            case Direction._east:
                Game_Manager.enemy._X_Position++;     //move right one on the grid
                room.add_enemy(Game_Manager.enemy);
                break;

            case Direction._west:
                Game_Manager.enemy._X_Position--;      //move left one on the grid
                room.add_enemy(Game_Manager.enemy);
                break;

                //no need for  a default since the direction has
                //already been checked as valid or not.
            }

            //get the description of the current room.
            //Non_PLayer.npc_get_room().describe();
        }
        public static Non_PLayer Generate_NPC()
        {
            Non_PLayer npc = null;

            Array     values     = Enum.GetValues(typeof(NPC_Names));
            Random    random     = new Random();
            NPC_Names randomName =
                (NPC_Names)values.GetValue(random.Next(values.Length));

            Array     rValues     = Enum.GetValues(typeof(NPC_Class));
            Random    cRandom     = new Random();
            NPC_Class randomClass =
                (NPC_Class)rValues.GetValue(cRandom.Next(rValues.Length));

            Array         wValues      = Enum.GetValues(typeof(Player_Weapon));
            Random        wRandom      = new Random();
            Player_Weapon randomWeapon =
                (Player_Weapon)wValues.GetValue(wRandom.Next(wValues.Length));

            switch (randomClass)
            {
            case NPC_Class.Egnor:
                npc = new Egnor(randomName, randomWeapon);
                break;

            case NPC_Class.Erstine:
                npc = new Erstine(randomName, randomWeapon);
                break;

            case NPC_Class.Tyrania:
                npc = new Erstine(randomName, randomWeapon);
                break;

            default:
                Text_Buffer.Add("No Player Detected...");
                break;
            }

            return(npc);
        }