Пример #1
0
    void Start()
    {
        player = GameObject.Find("Player");                                //Reference to Player Game Object
        playerControllerScript = player.GetComponent <PlayerController>(); // Reference to PlayerController Script
        secondaryController    = player.GetComponent <SecondaryController>();
        primaryController      = player.GetComponent <PrimaryController>();

        soundController       = GameObject.Find("SoundController");
        soundControllerScript = soundController.GetComponent <SoundController>();
        rpController          = GameObject.Find("RPController");
        rpControllerScript    = rpController.GetComponent <RPController>();

        zombieSpawner       = GameObject.Find("ZombieSpawner");
        zombieSpawnerScript = zombieSpawner.GetComponent <ZombieSpawner>();

        storeObject                = GameObject.Find("Store");
        storeControllerScript      = storeObject.GetComponent <StoreController>();
        primaryButtonsController   = storeObject.GetComponent <PrimaryButtonsController>();
        secondaryButtonsController = storeObject.GetComponent <SecondaryButtonsController>();
        survivorButtonsController  = storeObject.GetComponent <SurvivorButtonsController>();

        if (PlayerPrefs.HasKey("PlayerName"))
        {
            playerName = PlayerPrefs.GetString("PlayerName");
        }

        if (PlayerPrefs.HasKey("DisplayFreeRPBubble"))
        {
            displayFreeRPBubble = PlayerPrefs.GetInt("DisplayFreeRPBubble");
        }
        else
        {
            displayFreeRPBubble = 1;
        }
    }
Пример #2
0
    void Start()
    {
        secondaryController = gameObject.GetComponent <SecondaryController>();

        turretIcon.SetActive(false);
        turretOverlay.SetActive(false);
        continueButton.SetActive(false);
    }
Пример #3
0
    void Start()
    {
        // get secondary controller
        secondaryController = gameObject.GetComponent <SecondaryController>();
        powerupUI           = gameObject.GetComponent <PowerupUI>();

        // try to find the player
        try
        {
            playerController = GameObject.FindWithTag("Player").GetComponent <PlayerController>();
        }
        catch (System.NullReferenceException)
        {
            playerController = null;
        }

        // set default cursor for browsers that don't pick up Unity's custom cursor
        CursorManager.instance.SetDefaultCursor();

        // initialize game variables
        hazardSpeed = 1;
        paused      = false;
        gameOver    = false;
        restart     = false;

        // initialize UI variables
        gameOverOverlay.SetActive(false);
        if (DatabaseManager.instance.player1Name != "" && DatabaseManager.instance.player2Name != "")
        {
            player1NameText.text = DatabaseManager.instance.player1Name;
            player2NameText.text = DatabaseManager.instance.player2Name;
        }
        finalScoreText.text = "";
        finalWaveText.text  = "";
        for (int i = 0; i < topScoresRanksText.Length; ++i)
        {
            topScoresRanksText[i].text  = "";
            topScoresNamesText[i].text  = "";
            topScoresScoresText[i].text = "";

            surroundingScoresRanksText[i].text  = "";
            surroundingScoresNamesText[i].text  = "";
            surroundingScoresScoresText[i].text = "";
        } // end for

        // initialize score values
        score             = 0;
        wave              = 0;
        scoreSpecial      = 0;
        baseTargetSpecial = targetSpecial;
        UpdateScore();
        UpdateWave();

        specialBar.rectTransform.anchorMax = new Vector2(scoreSpecial / targetSpecial, 1);

        // start spawning hazards
        StartCoroutine(SpawnWaves());
    }
Пример #4
0
    void Start()
    {
        // Find the Game Controller
        GameObject gameControllerObject = GameObject.FindWithTag("GameController");

        if (gameControllerObject != null)
        {
            //gameController = gameControllerObject.GetComponent<GameController>();
            powerupUI = gameControllerObject.GetComponent <PowerupUI>();
        }
        //if (gameController == null)
        //{
        //    Debug.Log("Cannot find 'GameController' Script");
        //}
        if (powerupUI == null)
        {
            Debug.Log("Cannot find 'PowerupUI' Script");
        }

        // Find the Secondary Controller
        GameObject secondaryControllerObject = GameObject.FindWithTag("SecondaryController");

        if (secondaryControllerObject != null)
        {
            secondaryController = secondaryControllerObject.GetComponent <SecondaryController>();
        }
        if (secondaryController == null)
        {
            Debug.Log("Cannot find 'SecondaryController' Script");
        }

        // get objects
        rb = GetComponent <Rigidbody>();
        //audioSource = GetComponent<AudioSource>();
        collider = GetComponent <MeshCollider>();
        camera   = GameObject.FindWithTag("MainCamera").GetComponent <Camera>();

        // set up power up data
        fireRatePower  = false;
        shield         = GameObject.FindWithTag("Shield");
        shotSpawn      = new int[] { 0 };
        turretFireRate = fireRate;
        turret         = GameObject.FindWithTag("Turret");

        if (!startShield)
        {
            shield.SetActive(false);
        }
        else
        {
            collider.enabled = false;
        }
    }
    void Start()
    {
        player              = GameObject.Find("Player");
        ZombieSpawner       = GameObject.Find("ZombieSpawner");
        soundController     = GameObject.Find("SoundController");
        playerScript        = player.GetComponent <PlayerController> ();
        secondaryController = player.GetComponent <SecondaryController> ();

        storeControllerScript     = storeObject.GetComponent <StoreController>();
        survivorButtonsController = storeObject.GetComponent <SurvivorButtonsController>();
        //spawnerScript = ZombieSpawner.GetComponent<Spawner> ();
        zombieSpawnerScript   = ZombieSpawner.GetComponent <ZombieSpawner> ();
        soundControllerScript = soundController.GetComponent <SoundController>();
    }
Пример #6
0
    void Start()
    {
        Time.timeScale = 1f;         // Death Scene Pauses game. This ensures it is not paused when the game starts

        floodingControllerObject = GameObject.Find("FloodingController");
        floodingControllerScript = floodingControllerObject.GetComponent <FloodingController>();
        body = this.GetComponent <Rigidbody2D>();
        //milestoneControllerScript = this.GetComponent<MilestoneController>();
        bulletSpawnPoint          = transform.Find("BulletSpawnPoint").gameObject;
        gatlingSpawnPoint         = transform.Find("GatlingGunBulletSpawnPoint").gameObject;
        storeControllerScript     = storeObject.GetComponent <StoreController>();
        spriteRenderer            = this.GetComponent <SpriteRenderer>();
        survivorSpawner           = GameObject.Find("SurvivorSpawner");
        survivorSpawnerScript     = survivorSpawner.GetComponent <SurvivorSpawner>();
        secondaryController       = this.GetComponent <SecondaryController>();
        primaryController         = this.GetComponent <PrimaryController>();
        survivorButtonsController = storeObject.GetComponent <SurvivorButtonsController>();
        zombieSpawnerScript       = ZombieSpawner.GetComponent <ZombieSpawner>();

        soundController       = GameObject.Find("SoundController");
        soundControllerScript = soundController.GetComponent <SoundController>();

        hud             = this.GetComponent <PlayerHUD>();
        displayHUDCheck = true;
        shotGunSpawn1   = GameObject.Find("ShotGunSpawnPoint1");
        shotGunSpawn2   = GameObject.Find("ShotGunSpawnPoint2");
        shotGunSpawn3   = GameObject.Find("ShotGunSpawnPoint3");
        shotGunSpawn4   = GameObject.Find("ShotGunSpawnPoint4");

        if (PlayerPrefs.HasKey("JumpScare"))
        {
            jumpScareToggle = PlayerPrefs.GetInt("JumpScare");
        }

        if (PlayerPrefs.HasKey("PlayerName"))
        {
            playerName = PlayerPrefs.GetString("PlayerName");
        }
        else
        {
            playerName = "Player";
        }

        setPlayerSprite();

        int spawnLocation = (int)Random.Range(0f, 4f);

        if (spawnLocation == 0)
        {
            this.transform.position = new Vector3(-12, -12, 0);
        }
        else if (spawnLocation == 1)
        {
            this.transform.position = new Vector3(-12, 12, 0);
        }
        else if (spawnLocation == 2)
        {
            this.transform.position = new Vector3(12, 12, 0);
        }
        else if (spawnLocation == 3)
        {
            this.transform.position = new Vector3(12, -12, 0);
        }

        currentHealth   = maxHealth;
        currentScraps   = 100;      //500;
        jumpScareToggle = 0;        //Set JumpScare to off, because I'm removing it.
    }
 private void Start()
 {
     guns = GameObject.FindWithTag("Player").GetComponent <SecondaryController>();
 }