Пример #1
0
        protected override void Awake()
        {
            base.Awake();

            BEventsCollection.DZ_DroneBallSpawned.Event += On_DZ_DroneBallSpawned;

            ballDronePrefab = Resources.Load <BallDroneBAnchor>(BConsts.PATH_DZ_DroneBall);
        }
Пример #2
0
 private void OnTriggerEnter(Collider other)
 {
     // Should only be called on locally owned objects
     if (dZPlayer &&
         owner == BEventManager.Instance.LocalNetworkID)
     {
         BallDroneBAnchor ballDrone = BUtils.GetComponentInHierarchy <BallDroneBAnchor>(other.gameObject);
         if (ballDrone)
         {
             CatchBallDrone(ballDrone);
         }
     }
 }
Пример #3
0
        private void CatchBallDrone(BallDroneBAnchor ballDrone)
        {
            if (IS_NOT_NULL(ballDrone) &&
                ballDrone.OnCatch(playerID))
            {
                caughtBallDrone       = ballDrone;
                caughtBallDrone.Owner = owner;

                if (myRenderer)
                {
                    myRenderer.material.color = Color.red;
                }

                BEventsCollection.DZ_BallDroneCaught.Invoke(new BEHandle <EPlayerID>(playerID), BEventReplicationType.TO_ALL_OTHERS);
            }
        }
Пример #4
0
        private void On_DZ_BallDroneReleased(BEHandle <EPlayerID> handle)
        {
            // On not locally owned instances
            if (handle.Arg1 == playerID &&
                ARE_NOT_EQUAL(handle.InvokingNetworkID, BEventManager.Instance.LocalNetworkID) &&
                IS_NOT_NULL(caughtBallDrone))
            {
                caughtBallDrone.Release(transform.position, Vector3.zero, 0.0f);

                caughtBallDrone = null;

                if (myRenderer)
                {
                    myRenderer.material.color = Color.white;
                }
            }
        }
Пример #5
0
        private void ReleaseBall(Vector3 velocity)
        {
            if (IS_NOT_NULL(caughtBallDrone) &&
                ARE_EQUAL(owner, BEventManager.Instance.LocalNetworkID))
            {
                StartCoroutine(DisableColliderCoroutine());

                caughtBallDrone.Release(transform.position, velocity.normalized, releaseForceIntensity);

                caughtBallDrone = null;

                if (myRenderer)
                {
                    myRenderer.material.color = Color.white;
                }

                BEventsCollection.DZ_BallDroneReleased.Invoke(new BEHandle <EPlayerID>(playerID), BEventReplicationType.TO_ALL_OTHERS);
            }
        }
Пример #6
0
        private void On_DZ_DroneBallSpawned(BEHandle <BAnchorInformation> handle)
        {
            if (BEventManager.Instance.LocalNetworkID != handle.InvokingNetworkID &&
                IS_NOT_NULL(ballDronePrefab))
            {
                // Destroy exsiting Ball Drone
                BallDroneBAnchor existingBallDrone = FindObjectOfType <BallDroneBAnchor>();
                if (existingBallDrone)
                {
                    Destroy(existingBallDrone.gameObject);
                }

                // Spawn new
                BAnchorInformation bAnchorInformation = handle.Arg1;
                BallDroneBAnchor   ballDrone          = Instantiate(ballDronePrefab);
                ballDrone.Owner = handle.InvokingNetworkID;
                ballDrone.SetTransformedPosition(bAnchorInformation.TransformedPosition);
                ballDrone.SetTransformedRotation(bAnchorInformation.TransformedRotation);
            }
        }
Пример #7
0
        private void On_DZ_BallDroneCaught(BEHandle <EPlayerID> handle)
        {
            // TODO : Feels like a hack
            BallDroneBAnchor ballDrone = FindObjectOfType <BallDroneBAnchor>();

            // On not locally owned instances
            if (handle.Arg1 == playerID &&
                ARE_NOT_EQUAL(handle.InvokingNetworkID, BEventManager.Instance.LocalNetworkID) &&
                IS_NOT_NULL(ballDrone))
            {
                caughtBallDrone       = ballDrone;
                caughtBallDrone.Owner = handle.InvokingNetworkID;

                IS_TRUE(caughtBallDrone.OnCatch(playerID));

                if (myRenderer)
                {
                    myRenderer.material.color = Color.red;
                }
            }
        }
Пример #8
0
        public void SpawnDroneBall()
        {
            // Destroy exsiting Ball Drone
            BallDroneBAnchor existingBallDrone = FindObjectOfType <BallDroneBAnchor>();

            if (existingBallDrone)
            {
                Destroy(existingBallDrone.gameObject);
            }

            if (IS_NOT_NULL(ballDronePrefab))
            {
                ballDrone = (BallDroneBAnchor)ARManager.Instance.SpawnBAnchorAtCursorPosition(ballDronePrefab);
            }

            if (ballDrone != null)
            {
                BEventsCollection.DZ_DroneBallSpawned.Invoke(new BEHandle <BAnchorInformation>(ballDrone.GetBAnchorInformation()), BEventReplicationType.TO_ALL);
            }
            else
            {
                LogConsoleWarning("Spawning Ball Drone didn't succeed!");
            }
        }