コード例 #1
0
ファイル: Player.cs プロジェクト: robbybecker/TimeyWimey
    void BulletTime()
    {
        if(inputStatus == InputStatus.On)
        {
            if(energy > 0.01f)
            {
                if(bulletTimeStatus == BulletTimeStatus.Off)
                {
                    cam.DoShake(0.1f, 1.3f);
                    bulletTimeGO.BroadcastMessage("BulletTimeOn");
                    bulletTimeStatus = BulletTimeStatus.On;
                    heldDownTime = true;
                }
                if(bulletTimeStatus == BulletTimeStatus.On)
                {
                    energy -= Time.deltaTime * dechargeSpeed;
                    if(energy <= 0.01f)
                    {
                        energy = 0.01f;
                        bulletTimeStatus = BulletTimeStatus.TurningOff;
                    }
                    else
                    {
                        bulletTime -= Time.deltaTime * timeDechargeSpeed;
                        if(bulletTime <= 1f)
                        {
                            bulletTime = 1f;
                        }
                        Time.timeScale = bulletTime;
                    }
                }
            }
        }
        else if(inputStatus == InputStatus.Up)
        {
            bulletTimeStatus = BulletTimeStatus.TurningOff;
        }

        if(bulletTimeStatus == BulletTimeStatus.TurningOff)
        {
            bulletTime += Time.deltaTime * timeRechargeSpeed;
            if(bulletTime >= startBulletTime)
            {
                bulletTime = startBulletTime;
            }
            Time.timeScale = bulletTime;
            if(Time.timeScale >= 2f)
            {
                Time.timeScale = 2f;
                bulletTimeStatus = BulletTimeStatus.Off;
                bulletTimeGO.BroadcastMessage("BulletTimeOff");
            }
        }
        /*if(inputStatus == InputStatus.On && !minnedOut)
        {
            if(!bulletTiming)
            {
                cam.DoShake(0.1f, 1.3f);
                bulletTimeGO.BroadcastMessage("BulletTimeOn");
                bulletTiming = true;
            }
            bulletTime -= Time.deltaTime * dechargeSpeed;
            if(bulletTime <= 1f)
            {
                bulletTime = 1f;
                minnedOut = true;
            }
            Time.timeScale = bulletTime;
        }
        else if(inputStatus == InputStatus.Up && !minnedOut)
        {
            minnedOut = true;
        }
        else if(minnedOut)
        {
            bulletTime += Time.deltaTime * rechargeSpeed;
            if(bulletTime >= startBulletTime)
            {
                bulletTime = startBulletTime;
                minnedOut = false;
            }
            Time.timeScale += Time.deltaTime * dechargeSpeed;
            if(Time.timeScale >= 2f)
            {
                Time.timeScale = 2f;
                if(bulletTiming)
                {
                    bulletTimeGO.BroadcastMessage("BulletTimeOff");
                    bulletTiming = false;
                }
            }
        }*/
    }
コード例 #2
0
ファイル: Player.cs プロジェクト: robbybecker/TimeyWimey
 // Use this for initialization
 void Start()
 {
     myTransform = this.transform;
     energy = maxEnergy;
     speed = playerSpeed;
     bulletTimeStatus = BulletTimeStatus.Off;
     inputStatus = InputStatus.Up;
     bulletTime = startBulletTime;
     Time.timeScale = startBulletTime;
     explosion = (GameObject)Resources.Load("Explosion", typeof(GameObject));
     gameManager = GameObject.FindGameObjectWithTag("GameController");
     bulletTimeGO = GameObject.FindGameObjectWithTag("BulletTime");
     isAlive = true;
     cam = Camera.main.GetComponent<CameraCode>();
     #if !UNITY_STANDALONE && !UNITY_EDITOR
     upSr = GameObject.FindGameObjectWithTag("Up").GetComponent<SpriteRenderer>();
     downSr = GameObject.FindGameObjectWithTag("Down").GetComponent<SpriteRenderer>();
     #endif
     ControlColorOff();
 }