private void OnTriggerEnter(Collider other)
    {
        if (other.name.Equals("Sphere"))
        {
            int otherPlayerId = other.GetComponentInParent <Player>().id;

            if (otherPlayerId != id)
            {
                bool isOnShip = GameServer.clients[otherPlayerId].player.data.is_on_ship;

                /*if (isOnShip)
                 * {
                 *  ServerSend.DestroyPlayerCharacter(id, otherPlayerId);
                 * }*/
                ServerSend.ActivateShip(id, otherPlayerId);
                ServerSend.Stats(otherPlayerId, id);
                ServerSend.Buffs(otherPlayerId, id);
            }
        }
        else if (other.name.Equals("PlayerSphere"))
        {
            int otherPlayerId = other.GetComponentInParent <PlayerCharacter>().id;

            if (otherPlayerId != id)
            {
                ServerSend.ActivatePlayerCharacter(id, otherPlayerId);
                ServerSend.Stats(otherPlayerId, id);
                ServerSend.Buffs(otherPlayerId, id);
                Player player = GameServer.clients[otherPlayerId].player;
                if (player.playerMovement.agent.enabled)
                {
                    ServerSend.DeactivatePlayerMovement(otherPlayerId, player.playerInstance.transform.position);
                }
                else
                {
                    ServerSend.ActivatePlayerMovement(otherPlayerId, player.playerInstance.transform.position);
                }
            }
        }
        else if (other.tag.Equals("Resource"))
        {
            gatheringEnabled = true;
            currentResource  = other.gameObject;
        }
        else if (other.tag.Equals("Dock"))
        {
            dock     = other.gameObject;
            isOnDock = true;
        }
        else if (other.tag.Equals("CraftingSpot"))
        {
            craftingEnabled = true;
            craftingSpot    = other.GetComponent <CraftingSpot>();
        }
        else if (other.tag == "Trader")
        {
            tradingEnabled = true;
            trader         = other.gameObject.GetComponent <Trader>();
        }
        else if (other.tag == "TradeBroker")
        {
            tradeBrokerEnabled = true;
        }
        else if (other.tag == "Weapon")
        {
            PlayerAttack.OnPlayerAttack(this, other);
        }
        else if (other.name.Equals("NPCSphere"))
        {
            int npcId = other.GetComponentInParent <NPC>().id;
            ServerSend.NPCStats(npcId, id);
            ServerSend.ActivateNPC(id, npcId);
        }
        else if (other.name.Equals("DamageCollider"))
        {
            NPC npc = other.GetComponentInParent <NPC>();
            DamageColliderInfo info = other.GetComponent <DamageColliderInfo>();
            NPCAttack.OnNPCAttack(info, npc, this);
        }
    }
Exemple #2
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag.Equals("CannonBall"))
        {
            Player  player = other.gameObject.GetComponent <CannonBall>().player;
            ShipNPC npc    = other.gameObject.GetComponent <CannonBall>().npc;

            Vector3 tempPos = other.transform.position - new Vector3(0f, 0.5f, 0f);

            if (player == null)
            {
                TakeDamage(npc);
            }
            else
            {
                TakeDamage(player);
            }

            Debug.Log("Hit by " + other.name);
            other.gameObject.SetActive(false);
        }
        else if (other.name.Equals("Sphere"))
        {
            int otherPlayerId = other.GetComponentInParent <Player>().id;

            if (otherPlayerId != id)
            {
                ServerSend.Stats(otherPlayerId, id);
                ServerSend.Buffs(otherPlayerId, id);

                CannonController cannonController = other.GetComponentInParent <CannonController>();
                Quaternion       leftRotation     = cannonController.L_Cannon_1.transform.localRotation;
                Quaternion       rightRotation    = cannonController.R_Cannon_1.transform.localRotation;
                ServerSend.CannonRotate(otherPlayerId, id, leftRotation, "Left");
                ServerSend.CannonRotate(otherPlayerId, id, rightRotation, "Right");

                if (data.is_on_ship)
                {
                    ServerSend.ActivateShip(id, otherPlayerId);
                }

                /*bool isOnShip = GameServer.clients[otherPlayerId].player.data.is_on_ship;
                 * if (isOnShip)
                 *  ServerSend.DestroyPlayerCharacter(id, otherPlayerId);*/
            }
        }
        else if (other.name.Equals("PlayerSphere"))
        {
            int otherPlayerId = other.GetComponentInParent <PlayerCharacter>().id;

            if (otherPlayerId != id)
            {
                /*GameObject playerCharacter = GameServer.clients[otherPlayerId].player.playerInstance;
                 *
                 * Vector3 position = playerCharacter.transform.position;*/

                /*bool isOnShip = GameServer.clients[otherPlayerId].player.data.is_on_ship;
                 * if (!isOnShip)
                 * {*/
                //ServerSend.InstantiatePlayerCharacter(id, otherPlayerId, position, playerCharacter.transform.eulerAngles.y);
                //}*/
                if (data.is_on_ship)
                {
                    ServerSend.ActivatePlayerCharacter(id, otherPlayerId);
                    Player player = GameServer.clients[otherPlayerId].player;
                    if (player.playerMovement.agent.enabled)
                    {
                        ServerSend.DeactivatePlayerMovement(otherPlayerId, player.playerInstance.transform.position);
                    }
                    else
                    {
                        ServerSend.ActivatePlayerMovement(otherPlayerId, player.playerInstance.transform.position);
                    }
                }
                ServerSend.Stats(otherPlayerId, id);
                ServerSend.Buffs(otherPlayerId, id);
            }
        }
        else if (other.name.Equals("NPCSphere"))
        {
            if (data.is_on_ship)
            {
                int npcId = other.GetComponentInParent <NPC>().id;
                ServerSend.NPCStats(npcId, id);
                ServerSend.ActivateNPC(id, npcId);
            }
        }
        else if (other.tag.Equals("Dock"))
        {
            dock     = other.gameObject;
            isOnDock = true;
        }
    }