Beispiel #1
0
    // ================================================================ //
    //
    //  보스 관계 조작 명령 패킷 수신.
    //

    public void OnReceiveDirectAttackPacket(int node, PacketId id, byte[] data)
    {
        if (m_isHost)
        {
            // 호스트의 몬스터는 실행 완료.
            return;
        }

        // 패킷에서 파라미터를 추출해서 ↓의 코드 스니펫을 호출한다.
        GameObject go = GameObject.FindGameObjectWithTag("Boss");

        if (go != null)
        {
            chrControllerEnemyBoss bossController = go.GetComponent <chrControllerEnemyBoss>();
            if (bossController != null)
            {
                BossDirectPacket packet = new BossDirectPacket(data);
                BossDirectAttack attack = packet.GetPacket();

                string targetName  = attack.target;
                float  attackPower = attack.power;

                Debug.Log("Receive boss direct attack[Power:" + attackPower + " Target:" + targetName + "]");
                bossController.cmdBossDirectAttack(targetName, attackPower);
            }
        }
    }
Beispiel #2
0
    // ================================================================ //
    //
    //  로컬 오브젝트에서 호출되는 보스 관계 조작 명령.
    //
    public void RequestBossDirectAttack(string targetName, float attackPower)
    {
        // 호스트 측의 보스를 움직인다 : 이 명령을 로컬의 보스 오브젝트에게 바이패스한다.
        GameObject go = GameObject.FindGameObjectWithTag("Boss");

        if (go != null)
        {
            chrControllerEnemyBoss bossController = go.GetComponent <chrControllerEnemyBoss>();
            if (bossController != null)
            {
                bossController.cmdBossDirectAttack(targetName, attackPower);

                // 게스트 측의 보스를 움직인다. 통신 대응(패킷을 만들어 던진다).
                BossDirectAttack attack = new BossDirectAttack();

                attack.power  = attackPower;
                attack.target = targetName;

                BossDirectPacket packet = new BossDirectPacket(attack);

                if (m_network != null)
                {
                    int serverNode = m_network.GetServerNode();
                    m_network.SendReliable <BossDirectAttack>(serverNode, packet);
                    Debug.Log("Sendboss direct attack[Power:" + attackPower + " Target:" + targetName + "]");
                }
            }
        }
    }
Beispiel #3
0
	// ================================================================ //
	//
	//  보스 관계 조작 명령 패킷 수신.
	//
	
	public void OnReceiveDirectAttackPacket(int node, PacketId id, byte[] data)
	{
		if (m_isHost) {
			// 호스트의 몬스터는 실행 완료.
			return;
		}

		// 패킷에서 파라미터를 추출해서 ↓의 코드 스니펫을 호출한다.
		GameObject go = GameObject.FindGameObjectWithTag("Boss");
		if (go != null)
		{
			chrControllerEnemyBoss bossController = go.GetComponent<chrControllerEnemyBoss>();
			if (bossController != null)
			{
				BossDirectPacket packet = new BossDirectPacket(data);
				BossDirectAttack attack = packet.GetPacket();

				string targetName = attack.target;
				float attackPower = attack.power;

				Debug.Log("Receive boss direct attack[Power:" + attackPower + " Target:" + targetName + "]");
				bossController.cmdBossDirectAttack(targetName, attackPower);
			}
		} 
	}
Beispiel #4
0
	// ================================================================ //
	//
	//  로컬 오브젝트에서 호출되는 보스 관계 조작 명령.
	//
	public void RequestBossDirectAttack(string targetName, float attackPower)
	{
		// 호스트 측의 보스를 움직인다 : 이 명령을 로컬의 보스 오브젝트에게 바이패스한다.
		GameObject go = GameObject.FindGameObjectWithTag("Boss");
		if (go != null)
		{
			chrControllerEnemyBoss bossController = go.GetComponent<chrControllerEnemyBoss>();
			if (bossController != null)
			{
				bossController.cmdBossDirectAttack(targetName, attackPower);
				
				// 게스트 측의 보스를 움직인다. 통신 대응(패킷을 만들어 던진다).
				BossDirectAttack attack = new BossDirectAttack();
				
				attack.power = attackPower;
				attack.target = targetName;
				
				BossDirectPacket packet = new BossDirectPacket(attack);

				if (m_network != null)
				{
					int serverNode = m_network.GetServerNode();
					m_network.SendReliable<BossDirectAttack>(serverNode, packet);
					Debug.Log("Sendboss direct attack[Power:" + attackPower + " Target:" + targetName + "]");
				}
			}
		}
	}