// 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; }
void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); } Bonfires = new List <Bonfire>(); EnemyRooms = new List <EnemyRoom>(); }
void Start() { instance = this; itemMan = new ItemMan(); dataLoader = new DataLoader(); player = new Player(); EventMan.AddGameStartListener(GameStarted); EventMan.AddGameEndedListener(GameEnded); onDataLoaded(); guiMan.Init(); }
// 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"); }
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; }
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(); }
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; } }
// 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); }
// 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. }
// Use this for initialization void Awake() { //player = GameObject.FindGameObjectWithTag("Player").transform; gameManager = GameObject.Find("GameManager").GetComponent <GameMan>(); }
void Awake() { instance = this; }
void Awake(){ gameMan = GetComponent<GameMan>(); }
void Awake() { GameManager = this; }
void Start() { gameManager = FindObjectOfType <GameMan>(); }
// Start is called before the first frame update protected void Awake() { gameMan = GameMan.Instance; rb = GetComponent <Rigidbody>(); defaultScale = transform.localScale; }
//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); }