Esempio n. 1
0
    private void Awake()
    {
        if (_cubeInfoSO == null)
        {
            Debug.LogError("Need to add a CubeInfoScriptableObject to this controller!");
            enabled = false;
        }

        _controller  = GetComponent <CubeController>();
        rb           = _controller.GetRigidbody();
        targetHeight = _cubeInfoSO.jumpHeight;

        //particle effects on player

        GameObject tempObj;

        //consistant names needed for sanity. fix all of them later
        tempObj = Instantiate(_cubeInfoSO.slidingEffects[0]);
        tempObj.transform.parent        = transform;
        tempObj.transform.localPosition = Vector3.down * 0.4f;
        _movingEffect = tempObj.GetComponent <ParticleSystem>();

        tempObj = Instantiate(_cubeInfoSO.poppedEffects[0]);
        tempObj.transform.parent        = transform;
        tempObj.transform.localPosition = Vector3.zero;
        tempObj.transform.rotation      = transform.rotation;
        _poppedEffect = tempObj.GetComponent <ParticleSystem>();

        _controller.onRespawn.AddListener(OnRespawn);
    }
Esempio n. 2
0
    private void OnTriggerEnter(Collider other)
    {
        //death stuffs
        if (other.tag == "Enemy")
        {
            _poppedEffect.Play();
            _controller.Dead(_cubeInfoSO.deathTime);
            print("dead");
        }
        if (other.tag == "TheVoid")
        {
            _controller.Dead(_cubeInfoSO.deathTime, false, false);
            print("dead");
        }
        if (other.tag == "Blaster")
        {
            _controller.Dead(_cubeInfoSO.deathTime);
            Instantiate(_cubeInfoSO.burnedEffectsA[0], transform.position, transform.rotation);
            print("dead");
        }

        if (other.tag == "Pusher")
        {
            _controller.Dead(_cubeInfoSO.deathTime, false, false);
            print("dead");
        }

        if (other.tag == "Hammer")
        {
            _controller.Dead(_cubeInfoSO.deathTime, false, false);
            print("dead");
        }

        if (other.tag == "Smasher")
        {
            _controller.Dead(_cubeInfoSO.deathTime, false, false, false);
            if (!_ground)
            {
                _controller.GetRigidbody().AddForce(Vector3.down * 10, ForceMode.Impulse);
            }

            TheCubeGameManager.playerMesh.transform.localPosition = Vector3.down * 0.5f;
            TheCubeGameManager.playerMesh.transform.localScale    = new Vector3(TheCubeGameManager.playerMesh.transform.localScale.x, TheCubeGameManager.playerMesh.transform.localScale.x / 2, TheCubeGameManager.playerMesh.transform.localScale.z / 10);
            print("dead");
        }

        //other
        if (other.tag == "Launcher")
        {
            print("inLaucher!");
            Launcher launch = other.GetComponent <Launcher>();
            if (launch != null)
            {
                _currentLauncher = launch;
            }

            _inLauncher = true;
        }

        if (other.tag == "Bouncer")
        {
            print("inBouncer!");
            Bouncer bouncer = other.GetComponent <Bouncer>();
            if (bouncer != null)
            {
                _currentBouncer = bouncer;
            }
            _groundJumpActive = false;
            _inBouncer        = true;
        }

        if (other.tag == "Booster")
        {
            print("SPEEDBOOST!");
            _inBooster = true;
        }

        if (other.tag == "Moving")
        {
            print("inMovingObject");
            _onMovingObject = true;
            Rigidbody movingRb = other.GetComponent <Rigidbody>();
            if (movingRb != null)
            {
                _movingRb = movingRb;
            }
        }
        if (other.tag == "CameraEdit")
        {
            _currentCameraEdit = other.GetComponent <CameraEditSettings>();
            if (_currentCameraEdit != null)
            {
                print("moving camera..");
                cameraFollow.SetOffset(_currentCameraEdit.newCameraOffset);
            }
        }
    }