Esempio n. 1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("Crash"))
        {
            if (!p.isResetPlayer)
            {
                sm.LifeContol();
                p.Crash();

                SoundMgr.PlaySound(SoundType.damage);
            }
        }
        else if (other.gameObject.layer == LayerMask.NameToLayer("Falling"))
        {
            if (!p.isResetPlayer)
            {
                p.Falling();
            }
        }
        else if (other.gameObject.layer == LayerMask.NameToLayer("Slide"))
        {
            if (!p.GetSlideState())
            {
                if (!p.isResetPlayer)
                {
                    sm.LifeContol();
                    p.Crash();

                    SoundMgr.PlaySound(SoundType.damage);
                }
            }
        }
        else if (other.gameObject.layer == LayerMask.NameToLayer("Coin"))
        {
            sm.CardGaugeUp();
            other.GetComponent <Renderer>().enabled = false;//gameObject.SetActive(false);
            other.GetComponent <Collider>().enabled = false;
            p.CoinGetEffect();

            SoundMgr.PlaySound(SoundType.coin);
            //Destroy(other.gameObject);
        }
        //else if (other.gameObject.layer == LayerMask.NameToLayer("Card"))
        //{
        //    //other.transform.parent.gameObject.SetActive(false);

        //    other.transform.parent.SetParent(p.transform.Find("Main Camera/CardDest"));
        //    other.transform.GetComponent<CardItem>().MoveCard();

        //    p.PlayerGetCard();
        //    sm.CardCapture();
        //}
    }
Esempio n. 2
0
File: Player.cs Progetto: woosub/TMJ
    // Update is called once per frame
    void Update()
    {
        if (!StageMgr.isStart)
        {
            return;
        }

        if (isFalling)
        {
            control.position += Time.deltaTime * Vector3.up * gravity * 20;

            if (isRight)
            {
                control.position += Time.deltaTime * Vector3.right * 0.4f;
            }
            if (isLeft)
            {
                control.position += Time.deltaTime * Vector3.left * 0.4f;
            }


            fallingTimer += Time.deltaTime;

            if (fallingTimer >= fallingTime)
            {
                //sm.Finish();

                sm.LifeContol();
                if (sm.lifeCount < 3)
                {
                    sm.ResetPlayer();
                }

                //UnityEngine.SceneManagement.SceneManager.LoadScene(1);
            }
        }
        else
        {
            SkyPos();
            CameraPos();
            RunAnimation();
            ShadowAnimation();

            transform.position += Vector3.forward * Time.deltaTime * playSpeed;

            //sm.CalcMeter(Time.deltaTime * playSpeed);

            if (!isMoveline)
            {
                if (Input.GetKeyDown(KeyCode.A))
                {
                    ControlLeft();
                }

                if (Input.GetKeyDown(KeyCode.D))
                {
                    ControlRight();
                }
            }
            else
            {
                sideMoveVal += Time.deltaTime * 6f;
                Vector3 moveVal = Vector3.Lerp(curVal, destVal, sideMoveVal);
                if (1.0f > sideMoveVal)
                {
                    control.localPosition = new Vector3(moveVal.x, control.localPosition.y);
                }
                else
                {
                    isMoveline            = false;
                    isLeft                = false;
                    control.localPosition = new Vector3(destVal.x, control.localPosition.y);
                    camera.localPosition  = camDestPos;
                }
            }

            if (!isDown && !isJump)
            {
                if (Input.GetKeyDown(KeyCode.S))
                {
                    isDown = true;

                    character.sprite = etcSprite[3];


                    Invoke("ReleaseSlide", 0.3f);
                }
            }

            if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.W))
            {
                ControlJump();
            }

            if (isJump)
            {
                JumpAnimtion();

                jumpVal          += gravity * Time.deltaTime;
                control.position += new Vector3(0, jumpPower + jumpVal) * Time.deltaTime * 52;

                if (control.position.y <= flat)
                {
                    control.position = new Vector3(control.position.x, flat, control.position.z);
                    isJump           = false;
                }
            }

            if (isCrash)
            {
                crashTimer += Time.deltaTime;

                if (crashTimer >= crashTime)
                {
                    isCrash       = false;
                    isResetPlayer = false;

                    character.enabled = true;

                    CancelInvoke("CrashEffect");

                    //sm.Finish();
                    playSpeed = sm.currentSpeed;
                }
            }
        }
    }