Ejemplo n.º 1
0
        /// <summary>
        /// 상대방 플레이어를 리턴한다.
        /// </summary>
        /// <returns></returns>
        public CPlayer get_opponent_player(CPlayer who)
        {
            if (who.player_index == 0)
            {
                return(this.players[1]);
            }

            return(this.players[0]);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 게임을 지속 할 수 있는지 체크한다.
 /// </summary>
 /// <param name="board"></param>
 /// <param name="players"></param>
 /// <param name="current_player_index"></param>
 /// <returns></returns>
 public static bool can_play_more(List <short> board, CPlayer current_player, List <CPlayer> all_player)
 {
     foreach (short cell in current_player.viruses)
     {
         if (CHelper.find_available_cells(cell, board, all_player).Count > 0)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
 void change_playerstate(CPlayer player, PLAYER_STATE state)
 {
     if (this.player_state.ContainsKey(player.player_index))
     {
         this.player_state[player.player_index] = state;
     }
     else
     {
         this.player_state.Add(player.player_index, state);
     }
 }
Ejemplo n.º 4
0
        public void loading_complete(CPlayer player, byte Job)
        {
            change_playerstate(player, PLAYER_STATE.LOADING_COMPLETE);
            player.job = (JOB)Job;
            if (!allplayers_ready(PLAYER_STATE.LOADING_COMPLETE))
            {
                return;
            }

            battle_start();
        }
Ejemplo n.º 5
0
        //--------------------------------------------------------
        // Handler.
        //--------------------------------------------------------
        public void on_receive(CPlayer owner, CPacket msg)
        {
            PROTOCOL protocol = (PROTOCOL)msg.pop_protocol_id();

            if (is_received(owner.player_index, protocol))
            {
                // 플레이어가 이미 해당 프로토콜을 전송했다. 중복 처리 하지 않고 리턴한다.
                return;
            }

            // 프로토콜을 받았다고 기록한다.
            checked_protocol(owner.player_index, protocol);

            // 상태 매니저에 패킷을 보낸 플레이어와 패킷 내용을 전달한다.
            // 이후 게임 로직은 상태 매니저를 통해 현재 수행중인 상태 객체에서 처리된다.
            this.state_manager.send_state_message(protocol, owner, msg);
        }
Ejemplo n.º 6
0
        public void moving_req(CPlayer player, Vector3 vector3, Quaternion quaternion, byte[] anim, byte player_index)
        {
            if (player_position.ContainsKey(player_index))
            {
                player_position[player_index] = vector3;
            }
            else
            {
                player_position.Add(player_index, vector3);
            }

            if (player_rotation.ContainsKey(player_index))
            {
                player_rotation[player_index] = quaternion;
            }
            else
            {
                player_rotation.Add(player_index, quaternion);
            }

            CPacket msg = CPacket.create((short)PROTOCOL.PLAYER_MOVED);

            msg.push(player_index);
            msg.push_single(player.HP);

            msg.push_single(vector3.x);
            msg.push_single(vector3.y);
            msg.push_single(vector3.z);

            msg.push_single(quaternion.x);
            msg.push_single(quaternion.y);
            msg.push_single(quaternion.z);

            msg.push(anim[0]); // idle
            msg.push(anim[1]); // walk
            msg.push(anim[2]); // run
            msg.push(anim[3]); // die

            players.ForEach(player2 =>
            {
                if (player2.player_index != player_index)
                {
                    player2.send(msg);
                }
            });
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 매칭 성공 후 플레이어들을 방에 입장 시킨다.
        /// </summary>
        /// <param name="player1"></param>
        /// <param name="player2"></param>
        public void enter_gameroom(CPlayer player1, CPlayer player2)
        {
            if (player1 == null || player2 == null)
            {
                throw new Exception("Player cannot be null.");
            }

            if (this.players.Count >= 2)
            {
                throw new Exception("This room is not empty.");
            }

            add_player(player1);
            add_player(player2);

            CPacket msg = CPacket.create((short)PROTOCOL.START_LOADING);

            broadcast(msg);
        }
Ejemplo n.º 8
0
 public void enter_room(CGameRoom room, byte player_index)
 {
     this.player      = new CPlayer(this, player_index);
     this.battle_room = room;
     change_state(USER_STATE_TYPE.PLAY);
 }
Ejemplo n.º 9
0
 public void enter_room(CPlayer player, CGameRoom room)
 {
     this.player      = player;
     this.battle_room = room;
 }
Ejemplo n.º 10
0
 void add_player(CPlayer newbie)
 {
     this.players.Add(newbie);
 }
Ejemplo n.º 11
0
 public void error(CPlayer player)
 {
     player.disconnect();
 }
Ejemplo n.º 12
0
 /// <summary>
 /// sender가 현재 턴을 진행중인 플레이어가 맞는지 확인한다.
 /// </summary>
 /// <param name="sender"></param>
 /// <returns></returns>
 public bool is_current_player(CPlayer sender)
 {
     return(this.current_turn_player == sender.player_index);
 }