예제 #1
0
 public Room(int roomId,int channelId)
 {
     this._roomId = roomId;
     for (int i = 0; i < this._slots.Length; i++)
     {
         this._slots[i] = new SLOT();
     }
     this._room_state = ROOM_STATE.ROOM_STATE_READY;
     this._channelId  = channelId;
 }
예제 #2
0
 public Room(int roomId,int channelId)
 {
     this.chat    = new Chat();
     this._roomId = roomId;
     for (int index = 0; index < this._slots.Length; ++index)
     {
         this._slots[index] = new SLOT();
     }
     this._room_state = ROOM_STATE.ROOM_STATE_READY;
     this._channelId  = channelId;
 }
예제 #3
0
    /// <summary>
    /// Generates the enemies for the room.
    /// </summary>
    public void GenerateEnemies()
    {
        // Calculate the number of enemies to generate per room.
        int numEnemies = 17 + floor.CurrentFloor;
        int numFast    = Random.Range(0, (numEnemies / 3) - 2);
        // remainingEnemies -= numFast;
        int numTank = Random.Range(0, (numEnemies / 3) - 1);
        // remainingEnemies -= numTank;
        int numBasic = Random.Range(0, (numEnemies / 3));
        // remainingEnemies -= numBasic;

        int totalEnemies = numBasic + numTank + numFast;

        if (totalEnemies > 0)
        {
            state = ROOM_STATE.INCOMPLETE;
        }

        enemies = new BaseEnemy[totalEnemies];
        int index = 0;

        // Bounds for the placement of an enemy.
        float minX = ((-1 * floor.RoomSize.x) / 2) + 2;
        float maxX = (floor.RoomSize.x / 2) - 2;
        float minY = ((-1 * floor.RoomSize.y) / 2) + 2;
        float maxY = (floor.RoomSize.y / 2) - 2;

        for (int i = 0; i < numFast; i++)
        {
            float x = Random.Range(minX, maxX) + this.x;
            float y = Random.Range(minY, maxY) + this.y;
            enemies[index]      = Instantiate(SpeedEnemy, new Vector3(x, y, 0), Quaternion.identity).GetComponent <BaseEnemy>();
            enemies[index].Room = this.GetComponent <Room>();
            index++;
        }
        for (int j = 0; j < numTank; j++)
        {
            float x = Random.Range(minX, maxX) + this.x;
            float y = Random.Range(minY, maxY) + this.y;
            enemies[index]      = Instantiate(TankEnemy, new Vector3(x, y, 0), Quaternion.identity).GetComponent <BaseEnemy>();
            enemies[index].Room = this.GetComponent <Room>();
            index++;
        }
        for (int k = 0; k < numBasic; k++)
        {
            float x = Random.Range(minX, maxX) + this.x;
            float y = Random.Range(minY, maxY) + this.y;
            enemies[index]      = Instantiate(BasicEnemy, new Vector3(x, y, 0), Quaternion.identity).GetComponent <BaseEnemy>();
            enemies[index].Room = this.GetComponent <Room>();
            index++;
        }

        enemiesGenerated = true;
    }
예제 #4
0
    /// <summary>
    /// Destroys all the enemy GameObjects and removes the doors if all the enemies are dead.
    ///
    /// Returns true if all enemies in this room are dead, otherwise returns false.
    /// </summary>
    public bool ClearRoomIfApplicable()
    {
        if (state == ROOM_STATE.COMPLETE)
        {
            return(true);
        }
        // Iterate through the array of enemies checking if each enemy is alive. If any enemy is alive, immediately return false.
        foreach (BaseEnemy b in enemies)
        {
            if (b.IsAlive())
            {
                return(false);
            }
        }
        // Room Clear!
        Debug.Log("Room " + roomID + " cleared successfully!");
        // Destroy all the game objects now that we don't care about their states.
        foreach (BaseEnemy e in enemies)
        {
            Destroy(e);
        }
        // Remove all the non-null doors.
        if (northDoor != null)
        {
            Destroy(northDoor);
        }
        if (southDoor != null)
        {
            Destroy(southDoor);
        }
        if (westDoor != null)
        {
            Destroy(westDoor);
        }
        if (eastDoor != null)
        {
            Destroy(eastDoor);
        }

        // Update the room state.
        state = ROOM_STATE.COMPLETE;
        return(true);
    }
예제 #5
0
        public void ChangeRoomState(ROOM_STATE room,Account p)
        {
            bool flag = this.getState() == ROOM_STATE.ROOM_STATE_PRE_BATTLE;

            if (flag)
            {
                bool flag2 = p.player_id == this.getLeader().player_id;
                if (flag2)
                {
                    this._timeRoom = ((this.GMTimeOut != -1) ? this.GMTimeOut : (this.getTimeByMask() * 60));
                }
                for (int i = 0; i < 16; i++)
                {
                    Account playerBySlot = this.getPlayerBySlot(i);
                    bool    flag3        = this._slots[i].state == SLOT_STATE.SLOT_STATE_BATTLE_READY && this._slots[i]._playerId > 0 && playerBySlot != null;
                    if (flag3)
                    {
                        this.changeSlotState(i,SLOT_STATE.SLOT_STATE_BATTLE,true);
                        CLogger.getInstance().info("Send: SM_BATTLE_STARTBATTLE | O jogador " + playerBySlot.getPlayerName() + " pede o " + playerBySlot.getPlayerName());
                        playerBySlot.sendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK(playerBySlot));
                        bool flag4 = p.player_id != playerBySlot.player_id;
                        if (flag4)
                        {
                            CLogger.getInstance().info("Send: SM_BATTLE_STARTBATTLE | O jogador " + p.getPlayerName() + " pede o " + playerBySlot.player_name);
                            playerBySlot.sendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK(p));
                            CLogger.getInstance().info("Send: SM_BATTLE_STARTBATTLE | O jogador " + playerBySlot.getPlayerName() + " pede o " + p.player_name);
                            p.sendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK(playerBySlot));
                        }
                        playerBySlot.sendPacket(new PROTOCOL_BATTLE_MISSION_ROUND_START_ACK(this));
                    }
                }
                this.setState(ROOM_STATE.ROOM_STATE_BATTLE);
                this.updateInfo();
            }
            else
            {
                bool flag5 = this.getState() == ROOM_STATE.ROOM_STATE_BATTLE && p.getRoom().getSlotState(p.getSlot()) == SLOT_STATE.SLOT_STATE_BATTLE_READY;
                if (flag5)
                {
                    this.changeSlotState(p.getSlot(),SLOT_STATE.SLOT_STATE_BATTLE,true);
                    CLogger.getInstance().info("Send: SM_BATTLE_STARTBATTLE | O jogador " + p.getPlayerName() + " pede o " + p.getPlayerName());
                    p.sendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK(p));
                    for (int i = 0; i < 16; i++)
                    {
                        Account playerBySlot = this.getPlayerBySlot(i);
                        bool    flag6        = this._slots[i].state == SLOT_STATE.SLOT_STATE_BATTLE_READY && this._slots[i]._playerId > 0;
                        if (flag6)
                        {
                            bool flag7 = p.player_id != playerBySlot.player_id;
                            if (flag7)
                            {
                                CLogger.getInstance().info("Send: SM_BATTLE_STARTBATTLE | O jogador " + p.getPlayerName() + " pede o " + playerBySlot.player_name);
                                playerBySlot.sendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK(p));
                            }
                            CLogger.getInstance().info("Send: SM_BATTLE_STARTBATTLE | O jogador " + playerBySlot.getPlayerName() + " pede o " + p.player_name);
                            p.sendPacket(new PROTOCOL_BATTLE_STARTBATTLE_ACK(playerBySlot));
                        }
                    }
                    this.updateInfo();
                    p.sendPacket(new PROTOCOL_BATTLE_MISSION_ROUND_START_ACK(this));
                }
            }
        }
예제 #6
0
 public void setState(ROOM_STATE _state)
 {
     this._room_state = _state;
 }
예제 #7
0
 public void ChangeRoomState(ROOM_STATE room,Account p)
 {
     if (this.getState() == ROOM_STATE.ROOM_STATE_PRE_BATTLE)
     {
         if (p.player_id == this.getLeader().player_id)
         {
             this._aiLevel    = 1;
             this._redKills   = 0;
             this._redDeaths  = 0;
             this._blueKills  = 0;
             this._blueDeaths = 0;
             this._timeRoom   = this.GMTimeOut != -1 ? this.GMTimeOut : this.getTimeByMask() * 60;
         }
         for (int slot = 0; slot < 15; ++slot)
         {
             Account playerBySlot = this.getPlayerBySlot(slot);
             if (this._slots[slot].state == SLOT_STATE.SLOT_STATE_BATTLE_READY && this._slots[slot]._playerId > 0 && playerBySlot != null)
             {
                 this.changeSlotState(slot,SLOT_STATE.SLOT_STATE_BATTLE,true);
                 p.sendPacket((SendBaseGamePacket) new opcode_3879_ACK(this));
                 CLogger.getInstance().info("Send: PROTOCOL_BATTLE_STARTBATTLE_ACK info_player=" + playerBySlot.getPlayerName() + " send=" + playerBySlot.getPlayerName());
                 playerBySlot.sendPacket((SendBaseGamePacket) new S_BATTLE_STARTBATTLE(playerBySlot));
                 if (p.player_id != playerBySlot.player_id)
                 {
                     CLogger.getInstance().info("Send: PROTOCOL_BATTLE_STARTBATTLE_ACK info_player=" + p.getPlayerName() + " send=" + playerBySlot.player_name);
                     playerBySlot.sendPacket((SendBaseGamePacket) new S_BATTLE_STARTBATTLE(p));
                     CLogger.getInstance().info("Send: PROTOCOL_BATTLE_STARTBATTLE_ACK info_player=" + playerBySlot.getPlayerName() + " send=" + p.player_name);
                     p.sendPacket((SendBaseGamePacket) new S_BATTLE_STARTBATTLE(playerBySlot));
                 }
                 playerBySlot.sendPacket((SendBaseGamePacket) new S_STOP_BATTLE());
                 playerBySlot.sendPacket((SendBaseGamePacket) new S_START_BATTLE(this));
             }
         }
         this.setState(ROOM_STATE.ROOM_STATE_BATTLE);
         this.updateInfo();
     }
     else
     {
         if (this.getState() != ROOM_STATE.ROOM_STATE_BATTLE || p.getRoom().getSlotState(p.getSlot()) != SLOT_STATE.SLOT_STATE_BATTLE_READY)
         {
             return;
         }
         this.changeSlotState(p.getSlot(),SLOT_STATE.SLOT_STATE_BATTLE,true);
         CLogger.getInstance().info("Send: PROTOCOL_BATTLE_STARTBATTLE_ACK info_player=" + p.getPlayerName() + " send=" + p.getPlayerName());
         p.sendPacket((SendBaseGamePacket) new S_BATTLE_STARTBATTLE(p));
         for (int slot = 0; slot < 15; ++slot)
         {
             Account playerBySlot = this.getPlayerBySlot(slot);
             if (this._slots[slot].state == SLOT_STATE.SLOT_STATE_BATTLE_READY && this._slots[slot]._playerId > 0)
             {
                 if (p.player_id != playerBySlot.player_id)
                 {
                     CLogger.getInstance().info("Send: PROTOCOL_BATTLE_STARTBATTLE_ACK info_player=" + p.getPlayerName() + " send=" + playerBySlot.player_name);
                     playerBySlot.sendPacket((SendBaseGamePacket) new S_BATTLE_STARTBATTLE(p));
                 }
                 CLogger.getInstance().info("Send: PROTOCOL_BATTLE_STARTBATTLE_ACK info_player=" + playerBySlot.getPlayerName() + " send=" + p.player_name);
                 p.sendPacket((SendBaseGamePacket) new S_BATTLE_STARTBATTLE(playerBySlot));
             }
         }
         this.updateInfo();
         p.sendPacket((SendBaseGamePacket) new S_STOP_BATTLE());
         p.sendPacket((SendBaseGamePacket) new S_START_BATTLE(this));
     }
 }