// This method destroys the player's ship void Die() { LevelManager1 levelManager = GameObject.Find("LevelManager").GetComponent <LevelManager1> (); levelManager.LoadLevel("Win Screen"); Destroy(gameObject); }
// Use this for initialization void Start() { //Get the position of the parent. //This is the correct position to place the object. xParent = transform.root.position.x; yParent = transform.root.position.y; //Find the Sprite Renderer for fading/recoloring purposes. spriteRenderer = GetComponent <SpriteRenderer> (); //Find the box collider so it can be removed when object is placed. polyCol = GetComponent <PolygonCollider2D> (); //Sets a range of + or - the Offset within the correct position. xRangeHigh = xParent + OFFSET; xRangeLow = xParent - OFFSET; yRangeHigh = yParent + OFFSET; yRangeLow = yParent - OFFSET; //Find the Level Manager. levelManager = FindObjectOfType <LevelManager1> (); //Find the Array Shuffer arrayShuffler = FindObjectOfType <ArrayShuffler>(); //Make sure that myAttempt starts at 0 guesses = 0; }
void Awake() { if (lManager == null) { DontDestroyOnLoad(gameObject); lManager = this; } else if (lManager != this) { Destroy(gameObject); } }
void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
private LevelManager1 levelmanager; //Setting up LevelManager script access // Use this for initialization void Start() { //The 'Fisher Yates Shuffle' for (int i = States.Length - 1; i > 0; i--) { int r = Random.Range(0, i); GameObject temp = States[i]; States[i] = States[r]; States[r] = temp; } //Makes the first State active for the Player to place States [0].SetActive(true); levelmanager = GameObject.FindObjectOfType <LevelManager1>(); //To add objects to the level manager script levelmanager.startObjCount(States.Length); //Number of states that player will have to complete } //End Start
// Checks if all of the enemy ships are destroyed. bool AllMembersDead() { // The method iterates througouth all the transform's children. If there is at least one // enemy ship still alive, it returns false. foreach (Transform childPositionGameObject in transform) { if (childPositionGameObject.childCount > 0) { return(false); } } // If none of the enemy's ships is alive, it returns true. x++; if (x >= waves) { LevelManager1 levelManager = new LevelManager1(); levelManager.LoadNextLevel(); } return(true); }
// Use this for initialization void Start() { mylevel = FindObjectOfType <LevelManager1>(); firstInteraction = true; }