Пример #1
0
    void BreakShell()
    {
        Debug.Log("Shell Broken");
        for (int i = 0; i < entrance.attachedCrabs.Count - 1; i--)
        {
            entrance.DetachCrab(entrance.attachedCrabs[i]);
        }
        entrance.gameObject.SetActive(false);
        Tweener deadAnimaion = transform.DOMove(transform.position + new Vector3(0, 1, 0) * 10, 10f);

        deadAnimaion.Play();
        rigidBody.isKinematic = true;
    }
Пример #2
0
    private void Update()
    {
        if (dood)
        {
            return;
        }

        gamePadState = GamePad.GetState(playerIndex);
        if (gamePadState.IsConnected)
        {
            GetInputs();
            Move(leftStickInput);
        }

        //Check if in shell and button pressed
        if (nearestShell != null)
        {
            if (gamePadState.Triggers.Left > triggerTreshold)
            {
                if (!IsInShell)
                {
                    if (nearestShell.AttachCrab(this))
                    {
                        IsInShell = true;
                    }
                }
            }
            else
            {
                IsInShell = false;
                nearestShell.DetachCrab(this);
            }
        }
        else
        {
            IsInShell = false;
            if (nearestShell != null)
            {
                nearestShell.DetachCrab(this);
            }
        }

        if (IsInShell)
        {
            //SpotLight rotation;
            if (rightStickInput != Vector2.zero)
            {
                nearestShell.shell.SpotLightHolder.transform.rotation =
                    Quaternion.RotateTowards(
                        nearestShell.shell.SpotLightHolder.transform.rotation,
                        Quaternion.Euler(0, Mathf.Atan2(-rightStickInput.y, rightStickInput.x) * Mathf.Rad2Deg + 90, 0), 180f * Time.deltaTime);
            }

            //Add pickup to the shell
            if (pickedUpItem != null)
            {
                pickedUpItem.transform.SetParent(null);
                pickedUpItem.OnAttachToShell();
                nearestShell.shell.AttachPickup(pickedUpItem);
                pickedUpItem = null;
            }
            rigidbody.position = Vector3.Scale(nearestShell.transform.position, new Vector3(1, 0, 1));
        }
        else
        {
            if (nearestPickup != null && pickedUpItem == null)
            {
                if (gamePadState.Triggers.Right > triggerTreshold)
                {
                    pickedUpItem = nearestPickup;
                    pickedUpItem.OnPickup(transform);
                    AudioManager.Instance.PlayAudio(transform.position, "Pickup", is3D: false);
                }
            }
            if (pickedUpItem != null && gamePadState.Triggers.Right < triggerTreshold)
            {
                pickedUpItem.OnRelease();
                pickedUpItem = null;
            }
        }

        if (nearestCrab != null && nearestCrab.dood)
        {
            if (gamePadState.Triggers.Right > triggerTreshold)
            {
                nearestCrab.OnRevive();
            }
        }
    }