コード例 #1
0
        private void HandleBotCollision(CollisionEnterDispatcherScript collisionDispatcher,
                                        Collider col)
        {
            if (!dispatcherToAvatar.TryGetValue(collisionDispatcher, out var targetAvatar) ||
                !colliderToBot.TryGetValue(col, out var sourceBot))
            {
                return;
            }

            RaycastHit hit;

            if (Physics.Raycast(sourceBot.transform.position, targetAvatar.transform.position - sourceBot.transform.position, out hit, 3, 1 << 8))
            {
                photonView.RPC("playSoundRPC", RpcTarget.AllBuffered, "Collision");

                if (hit.normal == targetAvatar.transform.forward)
                {
                    targetAvatar.Stats.TakeDamage((int)sourceBot.NavMeshAgent.speed * 5, EquipmentType.FrontArmor);
                }
                if (hit.normal == -targetAvatar.transform.forward)
                {
                    targetAvatar.Stats.TakeDamage((int)sourceBot.NavMeshAgent.speed * 5, EquipmentType.RearArmor);
                }
                if (hit.normal == targetAvatar.transform.right)
                {
                    targetAvatar.Stats.TakeDamage((int)sourceBot.NavMeshAgent.speed * 5, EquipmentType.RightArmor);
                }
                if (hit.normal == -targetAvatar.transform.right)
                {
                    targetAvatar.Stats.TakeDamage((int)sourceBot.NavMeshAgent.speed * 5, EquipmentType.LeftArmor);
                }
            }
        }
コード例 #2
0
        private void HandleTrigger(CollisionEnterDispatcherScript collisionDispatcher)
        {
            if (!dispatcherToAvatar.TryGetValue(collisionDispatcher, out var sourceAvatar))
            {
                return;
            }

            for (var i = 0; i < avatars.Length; i++)
            {
                if (sourceAvatar.name == avatars[i].name)
                {
                    photonView.RPC("DeactivateAvatarRPC", RpcTarget.AllBuffered, i, false);
                    break;
                }
            }
        }