예제 #1
0
    // Start is called before the first frame update
    void Start()
    {
        // Make the game run as fast as possible
        //Application.targetFrameRate = 300;

        Time.timeScale = 1.0f;
        GameSingleton.Instance.SavedCargo        = 0;
        GameSingleton.Instance.BountiesCollected = 0;
        InitDifficulty();// Get stored vars in singleton
        levelRemainingTime            = levelStartTime;
        timePauseToNextSceneRemaining = timePauseToNextScene;

        // GameObject myObject = Instantiate(prefab, position, rotation) as GameObject;
        enemyPrefab      = Resources.Load("EnemyShip");
        checkpointPrefab = Resources.Load("Checkpoint");
        haulerPrefab     = Resources.Load("Hauler3");
        cargoPrefab      = Resources.Load("Cargo");

        spawnTimer     = Time.time + 5.0f;
        spawnBossTimer = Time.time + spawnBossInterval;

        levelTimerText = GameObject.Find("CountdownText").GetComponent <Text>();
        gameUi         = GameObject.Find("UIController").GetComponent <GameUI>();
        overlayUi      = GameObject.Find("UIController").GetComponent <UnitOverlayUi>();
        playerShip     = GameObject.Find("PlayerShip");
        GameObject.Find("PlayerCamera").GetComponent <MySmoothFollow>().target = playerShip.transform;
        explosion = GameObject.Find("Explosion").GetComponent <Explosion>();

        if (testBoss)
        {
            StartListeners();
            wormhole.SetActive(false);

            int        xx       = Random.Range(100, 300);
            int        yy       = Random.Range(100, 300);
            int        zz       = Random.Range(100, 300);
            Vector3    startPos = new Vector3(xx, yy, zz);
            GameObject newBoss  = Instantiate(bossPrefab, startPos, Quaternion.identity) as GameObject;
            overlayUi.RegisterUnit(newBoss);
        }
        else
        {
            SetWormhole();
            StartListeners();
            CreateCheckpoints();
            CreateHaulers();
            LevelStatus();
        }
    }
예제 #2
0
 // Use this for initialization
 void Start()
 {
     overlayUi = GameObject.Find("UIController").GetComponent <UnitOverlayUi>();
     overlayUi.RegisterUnit(this.gameObject);
 }