void Awake() { PlayerManager = GameObject.Find("PlayerManager"); InvaderManager = GameObject.Find("InvaderManager"); IM = (Invader_Manager)InvaderManager.GetComponent(typeof(Invader_Manager)); PM = (Player_Manager)PlayerManager.GetComponent(typeof(Player_Manager)); LevelManager = GameObject.Find("LevelManager"); LM = (Level_Manager)LevelManager.GetComponent(typeof(Level_Manager)); randomNumber = Random.Range(0, IM.explosions.Length); barrierSound = GetComponent <AudioSource> (); barrierSound.clip = LM.invadermarchSound [2]; }
private void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
private void Awake() { if (!instance) { instance = this; } else { Destroy(this); } playerController = player.GetComponent <Controller> (); }
public void Die() { if (levelTimer < 0.0f) { levelTimer = 0.0f; } gameObject.SetActive(false); GameObject temp = Instantiate(playerCorpsePrefab, transform.position, transform.rotation) as GameObject; temp.GetComponent <Player_Corpse> ().InitVelocity(movement); Level_Manager.OnPlayerDied(); }
void Awake() { gm = GameObject.Find("GameManager").GetComponent <GameManager> (); PlayerManager = GameObject.Find("PlayerManager"); PM = (Player_Manager)PlayerManager.GetComponent(typeof(Player_Manager)); InvaderManager = GameObject.Find("InvaderManager"); IM = (Invader_Manager)InvaderManager.GetComponent(typeof(Invader_Manager)); LevelManager = GameObject.Find("LevelManager"); LM = (Level_Manager)LevelManager.GetComponent(typeof(Level_Manager)); isLeft = false; isRight = false; randomNumber = Random.Range(0, IM.explosions.Length); playerSounds = GetComponent <AudioSource> (); }
void Awake() { gm = GameObject.Find("GameManager").GetComponent <GameManager>(); InvaderManager = GameObject.Find("InvaderManager"); IM = (Invader_Manager)InvaderManager.GetComponent(typeof(Invader_Manager)); PlayerManager = GameObject.Find("PlayerManager"); PM = (Player_Manager)PlayerManager.GetComponent(typeof(Player_Manager)); LevelManager = GameObject.Find("LevelManager"); LM = (Level_Manager)LevelManager.GetComponent(typeof(Level_Manager)); rb2d = GetComponent <Rigidbody2D> (); randomNumber = Random.Range(0, IM.explosions.Length); topInvaderSound = GetComponent <AudioSource> (); topInvaderSound.clip = LM.invadermarchSound [12]; topInvaderSound.Play(); }
void Start() { bus = GameObject.FindGameObjectsWithTag("Player")[0].GetComponent <Bus>(); levelManager = GameObject.Find("Level_Manager").GetComponent <Level_Manager>(); doTimer = levelManager.levelDoTimer; timerTime = levelManager.levelTime; doScore = levelManager.levelDoScore; threeStarScore = levelManager.levelThreeStarScore; UpdateDockStatusText(false); // initialize endPanel.SetActive(false); // initialize timerText.text = string.Format("Timer: {0}", timerTime.ToString("000")); UpdateScoreBoard(); }
public void ButtonNextLevel() { if (AudioManager.Instance != null) { AudioManager.Instance.ReloadForSceneChange(); } if (Level_Manager.LevelID < Constants.s_nNumLevels) { Level_Manager.LoadLevel(Level_Manager.LevelID + 1); } else { Level_Manager.LoadLevel(Level_Manager.LevelID); } SceneManager.LoadScene(Application.loadedLevel); }
void Awake() { enemyObject = GameObject.FindGameObjectsWithTag("Invaders"); gm = GameObject.Find("GameManager").GetComponent <GameManager> (); topInvaderDirection = "Left"; LevelManager = GameObject.Find("LevelManager"); LM = (Level_Manager)LevelManager.GetComponent(typeof(Level_Manager)); invaderSounds = GetComponent <AudioSource> (); invaderDieSound = GameObject.Find("InvaderDieSound"); invaderDie = invaderDieSound.GetComponent <AudioSource> (); invaderDie.clip = LM.invadermarchSound [2]; invaderDie.pitch = 0.5f; bulletExplosion = GameObject.Find("BulletExplosion"); bulletExp = bulletExplosion.GetComponent <AudioSource> (); bulletExp.clip = LM.invadermarchSound [2]; bulletExp.pitch = 0.3f; }
public void Start() { if (hasStarted) { return; } LevelManager = Managers[0].GetComponent <Level_Manager>(); PlayerManager = Managers[1].GetComponent <Player_Manager>(); EnemyManager = Managers[2].GetComponent <Enemy_Manager>(); FetchName(); LevelManager.Initialize(); EnemyManager.Initialize(); PlayerManager.Initialize(); PrepareNextLvl(); }
public void Instantiate(Transform parent, GameObject[] Designs) //IMPORTANT: Scale of Platform has to be (1,1,1) { parent.rotation = Quaternion.identity; //Checkpoints foreach (Vector3 CP in Path) { Transform Checkpoint = GameObject.Instantiate(Designs[0], CP, Quaternion.LookRotation(Vector3.forward, Vector3.up), parent).transform; Checkpoint.localScale = Vector3.Scale(Checkpoint.localScale, new Vector3(Level_Manager.GetWidth(), 1, Level_Manager.GetWidth())); } //Platforms for (int i = 1; i < Path.Count; i++) { //position between this CHeckpoint and the last one Vector3 Pos = (Path[i] + Path[i - 1]) / 2; //Rotation so that z-axis points form last to this Checkpoint Quaternion Rot = Quaternion.LookRotation(Path[i] - Path[i - 1], Vector3.up); Transform Current = GameObject.Instantiate(Designs[1], Pos, Rot, parent).transform; //scaling foreach (Transform Child in Current) { if (Child.GetSiblingIndex() == 0) { Child.localScale = new Vector3(Level_Manager.GetWidth(), Current.GetChild(0).localScale.y, Vector3.Magnitude(Path[i] - Path[i - 1]) - Level_Manager.GetWidth()); //changing scale Child.GetComponent <MeshRenderer>().material = new Material(Child.GetComponent <MeshRenderer>().material); Child.GetComponent <MeshRenderer>().material.mainTextureScale = new Vector2(1, Child.localScale.z / Child.localScale.x); } else { Child.localScale = new Vector3(Level_Manager.GetWidth(), Child.localScale.y, Level_Manager.GetWidth()); //changing scale Child.GetChild(0).GetComponent <MeshRenderer>().material = new Material(Child.GetChild(0).GetComponent <MeshRenderer>().material); Child.GetChild(0).GetComponent <MeshRenderer>().material.mainTextureScale = Vector2.one * Child.localScale.x / 18; } } Current.GetChild(1).localPosition = new Vector3(0, 0, Current.GetChild(0).localScale.z / 2); Current.GetChild(2).localPosition = new Vector3(0, 0, -Current.GetChild(0).localScale.z / 2); } Debug.Log("Level Instantiated", parent); parent.Rotate(Vector3.up, LvlRotation); }
void Awake() { for (int a = 0; a < challengeList.Length; a++) { challengeList[a].text = challengeCondition[a]; } for (int a = 0; a < challengeList.Length; a++) { challengeListStart[a].text = challengeCondition[a]; } //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } //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); } index = Random.Range(0, civilList.Count); target = civilList[index]; target.gameObject.tag = "Target"; for (int i = 0; i < civilList.Count;) { randomIdx = Random.Range(0, civilList.Count); civilList[i].gameObject.GetComponent <Civil_New>().civilComponents = civilType[randomIdx]; civilType.Remove(civilType[randomIdx]); civilList.Remove(civilList[i]); } }
//constructor public Level(int EnemyAmount, int DesignNum, float PathLength, Vector2 AngleRange, bool Clockwise) //Angle in Radiant { //notice that "generating is referring to saving Vector3 values in Path[] not actual Instatiation/Spawning this.EnemyAmount = EnemyAmount; Design = DesignNum; LvlRotation = UnityEngine.Random.Range(-180, 180); //used when loading the Level so not every level finishes at (X=0, Y=0, Z=MinRadius) this is rotation around y-axis Path.Add(Vector3.forward * Level_Manager.GetMinRadius()); //Goal Checkpoint float Angle = UnityEngine.Random.Range(AngleRange.x, AngleRange.y); if (!Clockwise) { Angle *= -1; //negative Angle = counterclockwise generation of checkpoints } float CurrentPathLength = 0; //Lebgth of Path already generated while (CurrentPathLength < PathLength) { //Generating starts inside and moves outwards however the outermost checkpoint is saved at Path[0] Vector3 Next = Vector3.zero; //Next ist the next outer Checkpoint position Next.x = (float)Math.Sin(Angle * Path.Count) * (Level_Manager.GetMinRadius() + Path.Count * Level_Manager.GetWidth()); Next.z = (float)Math.Cos(Angle * Path.Count) * (Level_Manager.GetMinRadius() + Path.Count * Level_Manager.GetWidth()); float AdditionalLength = Vector3.Magnitude(Next - Path[0]); //Distance between LastCheckpoint and Next //normal case: Next is added to Path at Position 0 if (CurrentPathLength + AdditionalLength <= PathLength) { Path.Insert(0, Next); } else //should only be called once at the end of the process { //if PathLength is overshot Next becomes Last Position + missing Distance and the LastPos is overwritten by Next AdditionalLength = PathLength - CurrentPathLength; //missing length Next = Path[0] + AdditionalLength * Vector3.Normalize(Path[0] - Path[1]); Path[0] = Next; } CurrentPathLength += AdditionalLength; } }
// Start is called before the first frame update void Start() { levelManager_script = Level_Manager.GetComponent <Level_Manager>(); redDanger = new Color(1f, 0.1f, 0.0f, 1.0f); }
void Start() { GM = GameManager.Instance; LM = Level_Manager.Instance; livesText.text = "Lives: " + GM.lives; }
private void Awake() { _instance = this; }
void OnTriggerEnter2D(Collider2D col) { levelmanager = GameObject.FindObjectOfType <Level_Manager> (); levelmanager.LossScreen(); }
void Awake() { instance = this; }
// Use this for initialization void Start() { score = 0; scoreGoal = 100; _level_Manager = GameObject.FindObjectOfType <Level_Manager>(); }
// Use this for initialization void Start() { _level_Manager = GameObject.FindObjectOfType <Level_Manager>(); }
void OnTriggerEnter2D(Collider2D trigger) { levelManager = GameObject.FindObjectOfType <Level_Manager>(); levelManager.LoadLevel("Lose"); }
void Start() { level = FindObjectOfType <Level_Manager>(); }
void Start() { LevelManager_script = Level_Manager.GetComponent <Level_Manager>(); hoverPosition = new Vector3(0.0f, 15.08f, 0f); }
void OnTriggerEnter2D(Collider2D collision) { level_manager = GameObject.FindObjectOfType <Level_Manager>(); print("Trigger"); level_manager.LoadLevel("Lose"); }
void Start() { Player1 = GameObject.Find("Player1"); GameObject[] tempPoints = GameObject.FindGameObjectsWithTag("CheckPoint"); checkPoints = new CheckPoint[tempPoints.Length]; for (int i = 0; i < tempPoints.Length; i++) { checkPoints[i] = tempPoints[i].GetComponent<CheckPoint>(); } if (Player2 = GameObject.Find("Player2")) { NumberOfPlayers++; mTheSegments = new Segment_Script[4]; mTheSegments[0] = GameObject.Find("Stage1").GetComponent<Segment_Script>(); mTheSegments[1] = GameObject.Find("Stage2").GetComponent<Segment_Script>(); mTheSegments[2] = GameObject.Find("Stage3").GetComponent<Segment_Script>(); mTheSegments[3] = GameObject.Find("Stage4").GetComponent<Segment_Script>(); } else { mTheSegments = new Segment_Script[4]; mTheSegments[0] = GameObject.Find("Stage1").GetComponent<Segment_Script>(); mTheSegments[1] = GameObject.Find("Stage2").GetComponent<Segment_Script>(); mTheSegments[2] = GameObject.Find("Stage3").GetComponent<Segment_Script>(); mTheSegments[3] = GameObject.Find("Stage4").GetComponent<Segment_Script>(); } Instance = this; spawnPosition = mTheSegments[0].defaultSpawn; mTheSegments[0].ResetSegments(); // StartCoroutine("BeginLevelPause"); }