コード例 #1
0
    private void Start()
    {
        if (!PlayerPrefs.HasKey("highscore"))
        {
            PlayerPrefs.SetInt("highscore", 0);
        }

        HighScore          = PlayerPrefs.GetInt("highscore");
        _gameManagerScript = GameObject
                             .Find("GrandDaddy/Menu Parent/Menu/Game Manager")
                             .GetComponent <GameManagerScript>();
        _timer = _gameManagerScript.Timer;
        _magnetismParticles =
            GameObject.Find("Player Animation Parent/Magnet Particle System")
            .GetComponent <ParticleSystem>();
        _projectilesParticles = GameObject.Find(
            "Projectiles Particle System")
                                .GetComponent <ParticleSystem>();
        _magnetismParticles.Stop(true);
        _projectilesParticles.Stop(true);
        _debrisParticles =
            GameObject.Find("Player Animation Parent/Debris Particle System")
            .GetComponent <ParticleSystem>();
        _debrisParticles.Stop(true);

        _parent = gameObject.transform.parent.gameObject
                  .GetComponentInParent <Transform>();
        Score        = 0.0f;
        _scoreStreak = _gameManagerScript.ScoreStreakObj;
        if (_scoreStreak == null)
        {
            Debug.LogWarning("ScoreStreakObj is null");
        }

        _scoreText = GameObject.Find("ScoreCanvas/Score")
                     .GetComponent <TextMeshProUGUI>();
        _highScoreText = GameObject.Find("ScoreCanvas/High Score")
                         .GetComponent <TextMeshProUGUI>();
        _lastScoreText = GameObject.Find("ScoreCanvas/Last Score")
                         .GetComponent <TextMeshProUGUI>();
        if (!PlayerPrefs.HasKey("lastScore"))
        {
            GameObject.Find("ScoreCanvas/Last Score").GetComponent <Animator>()
            .Play("NoLastScoreAnimation");
            PlayerPrefs.SetInt("lastScore", 0);
        }

        _highScoreText.text = "BEST: " + PlayerPrefs.GetInt("highscore");
        _lastScoreText.text = "LAST: " + PlayerPrefs.GetInt("lastScore");
        _rb        = _parent.gameObject.GetComponentInParent <Rigidbody>();
        _anim      = gameObject.GetComponent <Animator>();
        _boostAnim = GameObject.Find("Boost Stretcher")
                     .GetComponent <Animator>();
        _parentAnim =
            _parent.transform.parent.gameObject.GetComponent <Animator>();
        _magnetismBarAnim = GameObject.Find("Magnetism Bar Parent")
                            .GetComponent <Animator>();
        _destructionBarAnim = GameObject.Find("Destruction Bar Parent")
                              .GetComponent <Animator>();
        _projectilesBarAnim = GameObject.Find("Projectiles Bar Parent")
                              .GetComponent <Animator>();
        _explosionBarAnim = GameObject.Find("Explosion Bar Parent")
                            .GetComponent <Animator>();
        _magnetismLightAnim = GameObject
                              .Find("Player Animation Parent/Magnetism Player Light")
                              .GetComponent <Animator>();

        _coins = GameObject.Find("Coin Manager").GetComponent <CoinManager>()
                 .Coins;
        _platformManager = GameObject.Find("Platform Manager")
                           .GetComponent <PlatformManagerScript>();
        _isJumpKeyReleased  = true;
        IsBoosted           = false;
        IsFirstFrameOfBoost = true;
        IsDestructive       = false;
        IsAboutToExplode    = false;
        IsExploding         = false;
        IsMagnetising       = false;
        IsProjectiles       = false;
        IsRespawning        = false;
        IsFwdBoost          = true;
        IsAddingLosingLife  = false;
        _boostSpeed         = GameObject.Find("Power Up Manager")
                              .GetComponent <PowerUpManager>().BoostSpeed;
        GravityTweak();
    }
コード例 #2
0
    // Use this for initialization
    private void Start()
    {
        var ratio = (float)Screen.width / Screen.height;

//        Debug.Log("Aspect ratio is " + ratio);
        if (closeTo(ratio, 18 / 9f, 0.01f))
        {
            Adjust3dGUIToWideScreen();
        }

        _backgroundParticles = GameObject.Find("Background Particle System")
                               .GetComponent <ParticleSystem>();
        _backgroundParticlesBright = GameObject
                                     .Find("Background Particle System Bright")
                                     .GetComponent <ParticleSystem>();
        _magnetismParticles = GameObject
                              .Find("GrandDaddy/Player Animation Parent/Magnet Particle System")
                              .GetComponent <ParticleSystem>();
        _projectilesParticles = GameObject
                                .Find("GrandDaddy/Projectiles Particle System")
                                .GetComponent <ParticleSystem>();
        _playerExplosionParticles = GameObject
                                    .Find("GrandDaddy/Player Animation Parent/Boost Stretcher/Player")
                                    .GetComponent <ParticleSystem>();
        _playerDebrisParticles = GameObject
                                 .Find("GrandDaddy/Player Animation Parent/Debris Particle System")
                                 .GetComponent <ParticleSystem>();
        _scoreCanvas    = GameObject.Find("ScoreCanvas");
        _powerUpManager = GameObject.Find("Power Up Manager")
                          .GetComponent <PowerUpManager>();
        _livesLeftText = GameObject.Find("ScoreCanvas/Lives Count")
                         .GetComponent <TextMeshProUGUI>();
        _livesLeftTextAnim = GameObject.Find("ScoreCanvas/Lives Count")
                             .GetComponent <Animator>();
        _livesLeftKyoobParentAnim = GameObject
                                    .Find("Lives Count Kyoob Parent").GetComponent <Animator>();
        _pauseMenuAnim = GameObject.Find("GrandDaddy").GetComponent <Animator>();
        _camAnim       = Camera.main.GetComponent <Animator>();
        Timer          = new GameTimer(_powerUpManager.BoostPowerUpDuration,
                                       _powerUpManager.DestructionPowerUpDuration,
                                       _powerUpManager.MagnetPowerUpDuration,
                                       _powerUpManager.ProjectilesPowerUpDuration,
                                       _powerUpManager.ExplosionPowerUpDuration);
        _instructions1 =
            GameObject.Find("instructions1").GetComponent <Renderer>();
        _instructions2 =
            GameObject.Find("instructions2").GetComponent <Renderer>();
        _isEscKeyReleased = true;
        _playerScript     =
            GameObject.Find(
                "GrandDaddy/Player Animation Parent/Boost Stretcher/Player")
            .GetComponent <PlayerScriptWithAnimator>();
        _audioManager = GameObject.Find("Audio Manager")
                        .GetComponent <AudioManager>();
        _audioManager.FirstGameFrame = true;
        Broadcasts     = new List <GameObject>();
        ScoreStreakObj = new ScoreStreak();
        if (_playerScript == null)
        {
            Debug.LogWarning("_scoreStreak is null");
        }
    }