// Use this for initialization
    void Start()
    {
        gameManager = (GameMan)FindObjectOfType(typeof(GameMan));

        restartText = new GameObject("RestartText");
        restartText.AddComponent(typeof(GUIText));
        restartText.guiText.text = "Press R to restar the level";
        restartText.transform.position = new Vector3(0.5f,0.5f,0.5f);
        restartText.guiText.pixelOffset = new Vector2((Screen.width/2)- 5,
                                            (Screen.height/2)-5);
        restartText.guiText.anchor = TextAnchor.UpperRight;
        restartText.guiText.font = font;

        gameManager.actualLevelScore = 0;
        gameManager.actualLevelTime = 0;
        gameManager.actualGameLevel = 1;
        gameManager.nextLevel = nextLevelID;

        scoreText = new GameObject("ScoreText");
        scoreText.AddComponent(typeof(GUIText));
        scoreText.transform.position = new Vector3(0.5f,0.5f,0.5f);
        scoreText.guiText.pixelOffset = new Vector2((Screen.width/-2)+5,
                                            (Screen.height/2)-5);
        scoreText.guiText.font = font;

        timeText = new GameObject("TimeText");
        timeText.AddComponent(typeof(GUIText));
        timeText.transform.position = new Vector3(0.5f,0.5f,0.5f);
        timeText.guiText.pixelOffset = new Vector2((Screen.width/-2)+5,
                                            (Screen.height/2)-15);
        timeText.guiText.font = font;
    }
示例#2
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
示例#3
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        Bonfires   = new List <Bonfire>();
        EnemyRooms = new List <EnemyRoom>();
    }
示例#4
0
    void Start()
    {
        instance = this;

        itemMan    = new ItemMan();
        dataLoader = new DataLoader();
        player     = new Player();

        EventMan.AddGameStartListener(GameStarted);
        EventMan.AddGameEndedListener(GameEnded);

        onDataLoaded();

        guiMan.Init();
    }
示例#5
0
    // Start is called before the first frame update
    protected virtual void Start()
    {
        gameMan  = GameMan.Instance;
        rb       = gameObject.GetComponent <Rigidbody>();
        startPos = transform.position;
        startRot = transform.rotation;
        hp       = hp_max;

        mat = GetComponent <MeshRenderer>().material;

        // for one room level
        introPtc = transform.Find("introPtc").GetComponent <ParticleSystem>();
        outroPtc = transform.Find("outroPtc").GetComponent <ParticleSystem>();
        active   = false;
        StartCoroutine("Intro");
    }
示例#6
0
    void Awake()
    {
        if (Instance != null)
        {
            DestroyImmediate(gameObject);
            return;
        }
        DontDestroyOnLoad(gameObject);
        Instance = this;

        defaultSpawnPoint = new GameObject("Default SpawnPoint");
        defaultSpawnPoint.transform.position = new Vector3(0, 0.5f, 0);
        defaultSpawnPoint.transform.SetParent(transform, false);

        PhotonNetwork.AutomaticallySyncScene = true;
    }
示例#7
0
    public void CreateGrid()
    {
        GameMan objMan = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameMan>();

        for (int x = 0; x < rows; x++)
        {
            for (int y = 0; y < cols; y++)
            {
                Vector3 pos = transform.position + (new Vector3(x, 0.0f, y) * cellSize);
                if (!GenerateObstacle(pos, x, y))
                {
                    GameObject tileObj = Instantiate(tile, pos, Quaternion.identity, transform);
                    tileObj.name = "Tile_" + (x + 1).ToString() + "_" + (y + 1).ToString();
                    tileObj.GetComponent <Tile>().SetCoordinates(x, y);
                }
            }
        }

        //DestroyTileUnderObstacle();
    }
示例#8
0
    private void Awake()
    {
        gm            = FindObjectOfType <GameMan>();
        ai            = GetComponent <SteeringBehavior>();
        model         = gameObject.transform.Find("Cube").gameObject;
        rb            = GetComponent <Rigidbody>();
        pi            = new PlayerInput();
        mat           = model.GetComponent <MeshRenderer>().material;
        wakeParticle  = transform.Find("WakeParticle").GetComponent <ParticleSystem>();
        deathParticle = transform.Find("DeathParticle").GetComponent <ParticleSystem>();
        indicator     = transform.Find("Indicator").gameObject;
        movStk        = gm.movStk;
        shtStk        = gm.shtStk;

        ai.target   = gm.PlayerAgent;
        position    = rb.position;
        orientation = transform.eulerAngles.y;

        if (isPlayer)
        {
            connected = true;
        }
    }
示例#9
0
    // int localScore = 0;
    // int visitorScore = 0;

    private void Awake()
    {
        //Check if instance already exists
        if (instance == null)
        {
            //if not, set instance to this
            instance = this;
            Debug.Log("Instance is null, create instance");
        }

        //If instance already exists and it's not this:
        else if (instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
            Debug.Log("Already have instance, destroying this one");
        }

        //Sets this to not be destroyed when reloading scene
        DontDestroyOnLoad(gameObject);

        gameOverPanel.SetActive(false);
    }
示例#10
0
	// when the program launches, Grid will check that all the needed elements are in place
	// that's exactly what you do in the static constructor here:
	static Grid()
	{
		GameObject g;


		//		g = safeFind("__dimensionManager");
		//		dimensionManager = (DimensionManager)SafeComponent( g, "DimensionManager" );
		//		
		//		g = safeFind("__randomSeed");
		//		randomSeed = (RandomSeed)SafeComponent( g, "RandomSeed" );
		//		
		g = safeFind("__GameMan");
		gameMan = (GameMan)SafeComponent( g, "GameMan" );
		g = safeFind("__InControl");
		icMan = (InControlManager)SafeComponent( g, "InControlManager" );
		g = safeFind("__SoundMan");
		//soundMan = (SoundMan)SafeComponent( g, "SoundMan" );


		// PS. annoying arcane technical note - remember that really, in c# static constructors do not run
		// until the FIRST TIME YOU USE THEM.  almost certainly in any large project like this, Grid
		// would be called zillions of times by all the Awake (etc etc) code everywhere, so it is
		// a non-issue. but if you're just testing or something, it may be confusing that (for example)
		// the wake-up alert only appears just before you happen to use Grid, rather than "when you hit play"
		// you may want to call "SayHello" from the GeneralOperations.cs, just to decisively start this script.
	}
示例#11
0
 // Use this for initialization
 void Awake()
 {
     //player = GameObject.FindGameObjectWithTag("Player").transform;
     gameManager = GameObject.Find("GameManager").GetComponent <GameMan>();
 }
示例#12
0
 void Awake()
 {
     instance = this;
 }
示例#13
0
	void Awake(){
		gameMan = GetComponent<GameMan>();
	}
示例#14
0
 void Awake()
 {
     GameManager = this;
 }
示例#15
0
 void Start()
 {
     gameManager = FindObjectOfType <GameMan>();
 }
示例#16
0
 // Start is called before the first frame update
 protected void Awake()
 {
     gameMan      = GameMan.Instance;
     rb           = GetComponent <Rigidbody>();
     defaultScale = transform.localScale;
 }
示例#17
0
 //On game launch
 private void Awake()
 {
     instance = this;
     ballList = new List <GameObject>();
 }
 // Start is called before the first frame update
 void Start()
 {
     theGM = FindObjectOfType <GameMan>();
 }
 // Start is called before the first frame update
 void Start()
 {
     theRB = GetComponent <Rigidbody2D>();
     theGM = FindObjectOfType <GameMan>();
     //   theRB.velocity = new Vector2(vertSpeed, vertSpeed);
 }