示例#1
0
    // 트리거에 충돌한 순간만 호출되는 메소드.
    void    OnTriggerEnter(Collider other)
    {
        // 이벤트 박스에 들어간 플레이어를 리스트에 추가한다.
        do
        {
            if (other.tag != "Player")
            {
                break;
            }

            chrController player = other.gameObject.GetComponent <chrController>();

            if (player == null)
            {
                break;
            }

            if (player.local_index < 0)
            {
                break;
            }

            if (this.entered_players.Contains(player.local_index))
            {
                break;
            }

            this.entered_players.Add(player.local_index);

            // 게임 서버에 알림.
            if (this.step.get_current() == STEP.WAIT_ENTER &&
                player.global_index == GlobalParam.get().global_account_id)
            {
                CharDoorState door = new CharDoorState();
                door.globalId    = player.global_index;
                door.keyId       = (this.keyItemName != null)? this.keyItemName : "NONE";
                door.isInTrigger = true;
                door.hasKey      = (this.keyItemName != null)? PartyControl.getInstance().hasKey(player.local_index, door.keyId) : true;

                string log = "DoorId:" + door.keyId + " trigger:" + door.isInTrigger + " hasKey:" + door.hasKey;
                Debug.Log(log);

                DoorPacket packet = new DoorPacket(door);
                if (m_network != null)
                {
                    int server_node = m_network.GetServerNode();
                    m_network.SendReliable <CharDoorState>(server_node, packet);
                }
                else
                {
                    PartyControl.get().cmdMoveRoom(door.keyId);
                }
            }
        } while(false);
    }
示例#2
0
    public void OnReceiveDoorPacket(int node, PacketId id, byte[] data)
    {
        DoorPacket    packet = new DoorPacket(data);
        CharDoorState door   = packet.GetPacket();

        string log = "[SERVER] DoorPacket " +
                     "keyId:" + door.keyId +
                     " globalId:" + door.globalId +
                     " is in:" + door.isInTrigger +
                     " hasKey:" + door.hasKey;

        Debug.Log(log);

        int doorFlag = 0;

        if (m_doors.ContainsKey(door.keyId))
        {
            // 이미 누군가가 올라탄 도어.
            doorFlag = m_doors[door.keyId];
        }
        else
        {
            // 신규 도어.
            m_doors.Add(door.keyId, doorFlag);
        }

        // 수신 패킷 데이터에서 캐릭터의 ID와 열쇠의 소유 상태를 업데이트.
        if (door.isInTrigger)
        {
            doorFlag |= 1 << door.globalId;
            if (door.hasKey)
            {
                doorFlag |= 1 << KEY_MASK;
            }
        }
        else
        {
            doorFlag &= ~(1 << door.globalId);
            if (door.hasKey)
            {
                doorFlag &= ~(1 << KEY_MASK);
            }
        }

        log = "[SERVER] Door flag keyId:" + door.keyId + ":" + Convert.ToString(doorFlag, 2).PadLeft(5, '0');
        Debug.Log(log);

        // 상태 갱신.
        m_doors[door.keyId] = doorFlag;

        // 실제 체크는 checkDoorOpen으로 매 프레임 한다.
    }
示例#3
0
    // 트리거로부터 뭔가가 부딪힌 순간만 호출되는 메소드.
    void    OnTriggerExit(Collider other)
    {
        // 이벤트 박스에서 나온 플레이어를 리스트에서 제거.
        do
        {
            if (other.tag != "Player")
            {
                break;
            }

            chrController player = other.gameObject.GetComponent <chrController>();

            if (player == null)
            {
                break;
            }

            if (!this.entered_players.Contains(player.local_index))
            {
                break;
            }

            this.entered_players.Remove(player.local_index);

            // 게임 서버에 알림.
            if (player.global_index == GlobalParam.get().global_account_id)
            {
                CharDoorState door = new CharDoorState();
                door.globalId    = player.global_index;
                door.keyId       = (this.keyItemName != null)? this.keyItemName : "NONE";
                door.isInTrigger = false;
                door.hasKey      = PartyControl.getInstance().hasKey(player.local_index, door.keyId);

                string log = "DoorId:" + door.keyId + " trigger:" + door.isInTrigger + " hasKey:" + door.hasKey;
                Debug.Log(log);

                DoorPacket packet = new DoorPacket(door);
                if (m_network != null)
                {
                    int serer_node = m_network.GetServerNode();
                    m_network.SendReliable <CharDoorState>(serer_node, packet);
                }
                else
                {
                    PartyControl.get().clearDoorState(door.keyId);
                }
            }
        } while(false);
    }
示例#4
0
	public void OnReceiveDoorPacket(int node, PacketId id, byte[] data)
	{
		DoorPacket packet = new DoorPacket(data);
		CharDoorState door = packet.GetPacket();

		string log = "[SERVER] DoorPacket " +
				"keyId:" + door.keyId +
				" globalId:" + door.globalId +
				" is in:" + door.isInTrigger +
				" hasKey:" + door.hasKey;
		Debug.Log(log);

		int doorFlag = 0;
		if (m_doors.ContainsKey(door.keyId)) {
			// 이미 누군가가 올라탄 도어.
			doorFlag = m_doors[door.keyId];
		}
		else {
			// 신규 도어.
			m_doors.Add(door.keyId, doorFlag);
		}

		// 수신 패킷 데이터에서 캐릭터의 ID와 열쇠의 소유 상태를 업데이트.
		if (door.isInTrigger) {
			doorFlag |= 1 << door.globalId;
			if (door.hasKey) {
				doorFlag |= 1 << KEY_MASK;
			}
		}
		else {
			doorFlag &= ~(1 << door.globalId);
			if (door.hasKey) {
				doorFlag &= ~(1 << KEY_MASK);
			}
		}

		log = "[SERVER] Door flag keyId:" + door.keyId + ":" + Convert.ToString(doorFlag, 2).PadLeft(5,'0');
		Debug.Log(log);

		// 상태 갱신.
		m_doors[door.keyId] = doorFlag;
		
		// 실제 체크는 checkDoorOpen으로 매 프레임 한다.
	}
示例#5
0
	// 트리거로부터 뭔가가 부딪힌 순간만 호출되는 메소드.
	void	OnTriggerExit(Collider other)
	{
		// 이벤트 박스에서 나온 플레이어를 리스트에서 제거.
		do {

			if(other.tag != "Player") {

				break;
			}

			chrController	player = other.gameObject.GetComponent<chrController>();

			if(player == null) {

				break;
			}

			if(!this.entered_players.Contains(player.local_index)) {

				break;
			}

			this.entered_players.Remove(player.local_index);

			// 게임 서버에 알림.
			if (player.global_index == GlobalParam.get().global_account_id) {
				CharDoorState door = new CharDoorState();
				door.globalId = player.global_index;
				door.keyId = (this.keyItemName != null)? this.keyItemName : "NONE";
				door.isInTrigger = false;
				door.hasKey = PartyControl.getInstance().hasKey(player.local_index, door.keyId);

				string log = "DoorId:" + door.keyId + " trigger:" + door.isInTrigger + " hasKey:" + door.hasKey;
				Debug.Log(log);

				DoorPacket packet = new DoorPacket(door);
				if (m_network != null) {
					int serer_node = m_network.GetServerNode();
					m_network.SendReliable<CharDoorState>(serer_node, packet);
				} else {
					PartyControl.get().clearDoorState(door.keyId);
				}
			}

		} while(false);
	}
示例#6
0
	// 트리거에 충돌한 순간만 호출되는 메소드.
	void	OnTriggerEnter(Collider other)
	{
		// 이벤트 박스에 들어간 플레이어를 리스트에 추가한다.
		do {

			if(other.tag != "Player") {

				break;
			}

			chrController	player = other.gameObject.GetComponent<chrController>();

			if(player == null) {

				break;
			}

			if(player.local_index < 0) {

				break;
			}

			if(this.entered_players.Contains(player.local_index)) {

				break;
			}

			this.entered_players.Add(player.local_index);

			// 게임 서버에 알림.
			if (this.step.get_current() == STEP.WAIT_ENTER &&
				player.global_index == GlobalParam.get().global_account_id) {

				CharDoorState door = new CharDoorState();
				door.globalId = player.global_index;
				door.keyId = (this.keyItemName != null)? this.keyItemName : "NONE";
				door.isInTrigger = true;
				door.hasKey = (this.keyItemName != null)? PartyControl.getInstance().hasKey(player.local_index, door.keyId) : true;

				string log = "DoorId:" + door.keyId + " trigger:" + door.isInTrigger + " hasKey:" + door.hasKey;
				Debug.Log(log);

				DoorPacket packet = new DoorPacket(door);
				if (m_network != null) {
					int server_node = m_network.GetServerNode();
					m_network.SendReliable<CharDoorState>(server_node, packet);
				} else {
					PartyControl.get().cmdMoveRoom(door.keyId);
				}
			}

		} while(false);
	}