Exemplo n.º 1
0
        private void RemoveCubimal()
        {
            _state = RaceTrackState.Ready;

            _cubimal.OnPickedUp -= HandleCubimalPickedUp;
            _cubimal.OnStopped  -= HandleCubimalStopped;
            _cubimal             = null;

            OnCubimalRemoved?.Invoke();
        }
Exemplo n.º 2
0
        private IEnumerator OpenBoxSequence()
        {
            OnOpened?.Invoke();

            _state = CubimalBoxState.Opening;

            _rigidbody.isKinematic = true;
            _animator.SetTrigger(OpenBool);

            Hand      hand             = _hand;
            GrabTypes?currentGrabTypes = GrabTypes.None;

            Hand.AttachmentFlags?currentAttachmentFlags = Hand.AttachmentFlags.ParentToHand
                                                          | Hand.AttachmentFlags.TurnOnKinematic
                                                          | Hand.AttachmentFlags.DetachFromOtherHand;

            if (hand != null)
            {
                currentGrabTypes       = hand.currentAttachedObjectInfo?.grabbedWithType;
                currentAttachmentFlags = hand.currentAttachedObjectInfo?.attachmentFlags;
            }

            yield return(new WaitForSeconds(0.25f));

            Cubimal cubimal = Instantiate(_cubimalPrefabs[Random.Range(0, _cubimalPrefabs.Length)], transform.position, transform.rotation).GetComponent <Cubimal>();

            cubimal.Spawn(hand != null);

            if (hand != null)
            {
                if (hand.currentAttachedObject == gameObject)
                {
                    hand.DetachObject(gameObject, true);
                }

                hand.AttachObject(cubimal.gameObject, currentGrabTypes.GetValueOrDefault(), currentAttachmentFlags.GetValueOrDefault());
            }

            _particleSystem.transform.SetParent(null, true);
            _particleSystem.Play();
            _particleSystem = null;

            yield return(new WaitForSeconds(0.25f));

            Destroy(gameObject);
        }
Exemplo n.º 3
0
        private void OnTriggerEnter(Collider other)
        {
            if (_cubimal != null || _state != RaceTrackState.Ready)
            {
                return;
            }

            Cubimal cubimal = other.gameObject.GetComponentInParent <Cubimal>();

            if (cubimal != null && cubimal.CanRace())
            {
                _cubimal             = cubimal;
                _cubimal.OnPickedUp += HandleCubimalPickedUp;
                _cubimal.OnStopped  += HandleCubimalStopped;

                _positionSequence = StartCoroutine(PositionCubimalSequence());
            }
        }
Exemplo n.º 4
0
        private void OnTriggerEnter(Collider other)
        {
            if (_state != RaceState.Racing)
            {
                return;
            }

            Cubimal cubimal = other.gameObject.GetComponentInParent <Cubimal>();

            if (cubimal != null)
            {
                foreach (RaceTrack raceTrack in _raceTracks)
                {
                    if (raceTrack.Cubimal == cubimal)
                    {
                        FinishRace(raceTrack);
                        return;
                    }
                }
            }
        }