private void CheckLoseConditions() { if (!GameManagerBehaviour.Instance.GameInProgress) { return; } // LOSE CONDITION: fartmeter is filled up, s******g your pants if (FartJuice.health >= FartJuice.maximumHealth) { GameManagerBehaviour.EndGame("You shat yourself! Make sure to fart from time to time. Don't worry, nobody will know it's you."); } // LOSE CONDITION: if you fart too quick if (FartCooldown.health >= FartCooldown.maximumHealth) { GameManagerBehaviour.EndGame("You shat yourself! Don't fart too hard; for once Icarus taught us not to fly too close to the sun."); } //LOSE CONDITION: if you lose balance if (LostBalance()) { Debug.Log("Lost balance!"); GameManagerBehaviour.EndGame("You lost balance! Maybe you should drink less, you boozebag."); } //LOSE CONDITION: if you stop running if (_rb.velocity.sqrMagnitude < .1f) { GameManagerBehaviour.EndGame("You got too tired!"); } }
private void Update() { Vector3 startPosition = waypoints[currentWaypoint].transform.position; Vector3 endPosition = waypoints[currentWaypoint + 1].transform.position; float pathLength = Vector3.Distance(startPosition, endPosition); float totalTimeForPath = pathLength / speed; float currentTimeOnPath = Time.time - lastWaypointSwitchTime; gameObject.transform.position = Vector3.Lerp(startPosition, endPosition, currentTimeOnPath / totalTimeForPath); if (gameObject.transform.position.Equals(endPosition)) { if (currentWaypoint < waypoints.Length - 2) { currentWaypoint++; lastWaypointSwitchTime = Time.time; } else { Destroy(gameObject); GameManagerBehaviour gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour>(); gameManager.Health -= 1; } } }
// Update is called once per frame void Update() { Vector3 startPosition = waypoints [currentWaypoint].transform.position; Vector3 endPosition = waypoints [currentWaypoint + 1].transform.position; float pathLength = Vector3.Distance(startPosition, endPosition); float totalTimeForPath = pathLength / speed; float currentTimeOnPath = Time.time - lastWaypointSwitchTime; gameObject.transform.position = Vector3.Lerp(startPosition, endPosition, currentTimeOnPath / totalTimeForPath); if (gameObject.transform.position.Equals(endPosition)) { int lastWaypointIndex = waypoints.Length - 1; if (currentWaypoint < lastWaypointIndex - 1) { currentWaypoint++; lastWaypointSwitchTime = Time.time; } else { Destroy(gameObject); AudioSource audioSource = gameObject.GetComponent <AudioSource> (); AudioSource.PlayClipAtPoint(audioSource.clip, transform.position); GameManagerBehaviour gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour> (); gameManager.Health -= 1; } } RotateIntoMoveDirection(); }
// Update is called once per frame void Update() { // retrieve the waypoint segments from start to finish Vector3 startPosition = waypoints[currentWaypoint].transform.position; Vector3 endPosition = waypoints[currentWaypoint + 1].transform.position; //calculating total time needed to finish path float pathLength = Vector3.Distance(startPosition, endPosition); float totalTimeForPath = pathLength / speed; float currentTimeOnPath = Time.time - lastWaypointSwitchTime; gameObject.transform.position = Vector3.Lerp(startPosition, endPosition, currentTimeOnPath / totalTimeForPath); //Check whether the enemy has reached the endPosition. - Yes = add waypoint - desroy and trigger sound effect if (gameObject.transform.position.Equals(endPosition)) { if (currentWaypoint < waypoints.Length - 2) { // add waypoint currentWaypoint++; lastWaypointSwitchTime = Time.time; RotateIntoMoveDirection(); } else { // desroy and trigger sound effect Destroy(gameObject); AudioSource audioSource = gameObject.GetComponent <AudioSource>(); AudioSource.PlayClipAtPoint(audioSource.clip, transform.position); GameManagerBehaviour gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour>(); gameManager.Health -= 1; } } }
void Start() { inBetweenWaves = true; lastSpawnTime = Time.time; gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour>(); Invoke("playSound", timeBetweenWaves - 3); }
public override void NetworkStart() { // Get refs body = GetComponent <Rigidbody2D>(); manager = FindObjectOfType <GameManagerBehaviour>(); launchBall(); }
private void Start() { startTime = Time.time; distance = Vector2.Distance(startPosition, targetPosition); GameObject gm = GameObject.Find("GameManager"); gameManager = gm.GetComponent <GameManagerBehaviour>(); }
// Use this for initialization void Start() { //You set startTime to the current time and calculate the distance between the start and target positions startTime = Time.time; distance = Vector3.Distance(startPosition, targetPosition); GameObject gm = GameObject.Find("GameManager"); gameManager = gm.GetComponent <GameManagerBehaviour>(); }
void Start() { gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour>(); if (SceneManager.GetActiveScene().name == "TutorialLevel") { tutorialManager = GameObject.Find("TutorialManager").GetComponent <TutorialManager>(); } }
void Start() { gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour> (); PosX = gameObject.transform.position.x; PosY = gameObject.transform.position.y; TowerMenu = transform.Find("TowerMenu").gameObject; TowerMenu.SetActive(false); switch (GetTowerType()) { case 1: CreateButton(1, PrefabButtonBlue1, Pos1, PrefabTowerBlue1); CreateButton(2, PrefabButtonGreen1, Pos3, PrefabTowerGreen1); CreateButton(3, PrefabButtonRed1, Pos5, PrefabTowerRed1); break; case 2: CreateButton(1, PrefabButtonBlue2, Pos2, PrefabTowerBlue2a); CreateButton(2, PrefabButtonBlue2, Pos4, PrefabTowerBlue2b); break; case 3: CreateButton(1, PrefabButtonGreen2, Pos2, PrefabTowerGreen2a); CreateButton(2, PrefabButtonGreen2, Pos4, PrefabTowerGreen2b); break; case 4: CreateButton(1, PrefabButtonRed2, Pos3, PrefabTowerRed2); break; case 5: CreateButton(1, PrefabButtonBlue3, Pos3, PrefabTowerBlue3a); break; case 6: CreateButton(1, PrefabButtonBlue3, Pos3, PrefabTowerBlue3b); break; case 7: CreateButton(1, PrefabButtonGreen3, Pos3, PrefabTowerGreen3a); break; case 8: CreateButton(1, PrefabButtonGreen3, Pos3, PrefabTowerGreen3b); break; case 9: CreateButton(1, PrefabButtonRed3, Pos3, PrefabTowerRed3); break; default: break; } }
// Start is called before the first frame update void Start() { gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour>(); monsterData = GetComponent <MonsterData>(); Vector3 a = transform.position; Vector3 b = bulletSpawnOffset; spawnLocation = new Vector3(a.x + b.x, a.y + b.y, a.z + b.z); }
void Start() { gameManager = FindObjectOfType <GameManagerBehaviour> (); lastWaypointSwitchTime = Time.time; //define que esta variavel vai recerbe um tempo. if (speed == 0) { speed = 2; } }
private GameManagerBehaviour gameManager; //este Objeto vai tratar de alterar os dados do player na classe gameObject void Start() { MoveEnemy andador = this.gameObject.GetComponent <MoveEnemy> (); //cria-se um objeto do tipo move enemy, andador.Speed = velocidade; //para definir sua velocidade de acordo com o valor da variavel velocidade barraVida = this.gameObject.transform.Find("HealthBar") //2- GameObject filho deste gameObject na hierarchy com o nome de "HealthBar" .GetComponent <HealthBar> (); //1- a barra de vida recebe o componente healthbar presente no gameManager = GameObject.FindGameObjectWithTag("GameManager") //2- GameObject na hierarchy com o nome GameManager .GetComponent <GameManagerBehaviour>(); //1- o gameManager o componente GameManagerBehaviour presente no }
// Start is called before the first frame update new void Start() { goalHit = gameObject.AddComponent <AudioSource>(); AudioClip goalClip; goalClip = (AudioClip)Resources.Load("Sound/GoalHit"); goalHit.clip = goalClip; onLeft = transform.position.x < 0; manager = FindObjectOfType <GameManagerBehaviour>(); base.Start(); }
private void Awake() { if (instance = null) { instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
// Start is called before the first frame update void Start() { gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour>(); monsterData = GetComponent <MonsterData>(); Vector3 a = transform.position; Vector3 b = bulletSpawnOffset; //adds the bullet spawn offset to the position of the tower to create the //bullet spawnpoint, as some tower's bullets spawn in different locations spawnLocation = new Vector3(a.x + b.x, a.y + b.y, a.z + b.z); }
public void Start() { if (Instance != null) { Debug.LogError($"New instance of singleton behaviour: {nameof(GameManagerBehaviour)}. Destroying old instances gameobject."); if (Instance.gameObject != this.gameObject) { Destroy(Instance.gameObject); } } Instance = this; StartGame(); }
private void Start() { startTime = Time.time; distance = Vector2.Distance(startPosition, targetPosition); gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour>(); Vector3 direction = startPosition - targetPosition; gameManager.transform.rotation = Quaternion.AngleAxis( Mathf.Atan2(direction.x, direction.y) * 180 / Mathf.PI, new Vector3(0, 0, 1) ); }
void Start() { placesTower = GameOver.FindObjectsOfType <PlaceTower> (); gameManager = FindObjectOfType <GameManagerBehaviour> (); //o gamemanager vai procurar o gameobject que tiver o componente gamemanagerbehaiour Canvas[] canvases = Resources.FindObjectsOfTypeAll <Canvas> (); foreach (Canvas canv in canvases) { if (canv.CompareTag("LevelUI")) { canvas = canv; } } }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } DontDestroyOnLoad(gameObject); updatingHighScore = true; // Começa em true para impedir de entrar antes do player ter entrado }
// Use this for initialization void Start() { tileList = TileManagerScript.Instance.goTileList; gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour>(); enemySpawner = GameObject.Find("Lv1Spawner").GetComponent <SpawnEnemy1>(); tileManager = GameObject.Find("TileManagerPrefab").GetComponent <TileManagerScript>(); coreHealth = GameObject.Find("Core").GetComponent <CoreHealth>(); if (SceneManager.GetActiveScene().name == "TutorialLevel") { tutorialManager = GameObject.Find("TutorialManager").GetComponent <TutorialManager>(); } StartCoroutine(HideProgressIndicator(1.5f)); SoundManagerScript.Instance.PlaySFX(AudioClipID.SFX_PrepareforbattleStartBattle); }
// Start is called before the first frame update void Start() { HP = 80.0f; loadWaypoints(); currentWaypoint = 0; waypoint = getNextWaypoint(); speedCounter += 2; speedCounter = speedCounter > 8 ? 0 : speedCounter; //set speed = speedCounter to have some enemies get faster than their previous enemies //use to check that towers prioritise targets correctly Speed = 3; //2-3 is normal, use 80-ish for quick debugging gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour>(); }
private void Start() { // Singleton // If there is no Instance, make this the new Instance if (!Instance) { Instance = this; } // If there is an Instance and it is not this object, delete this object else if (Instance != this) { Destroy(this.gameObject); } // Ensure Victory Screen is disabled if (_victoryScreen.gameObject.activeInHierarchy) { _victoryScreen.gameObject.SetActive(false); } }
// Start is called before the first frame update void Start() { enemyPrefabs = new GameObject[] { (GameObject)Resources.Load("Prefabs/Enemy", typeof(GameObject)), (GameObject)Resources.Load("Prefabs/Enemy1", typeof(GameObject)), (GameObject)Resources.Load("Prefabs/Enemy2", typeof(GameObject)) }; enemyPicker = new System.Random(); gameManager = gameObject.GetComponent <GameManagerBehaviour>(); //just left of current map start spawnPosition = new Vector3(-11.0f, 4.1f); //script starts at the same time as gameManager, so values have to be manually initalised gameManager.Wave = 1; gameManager.EnemiesLeft = 2; spawnSpeed = .5f; StartCoroutine("spawnEnemies"); }
// Use this for initialization void Start() { gameManagerCoin = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour>(); Invoke("PickUp", stayDuration); }
void Start() { gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour> (); }
private void Awake() { instance = this; }
void Start() { tempoInicio = Time.time; //a variavel tempoInicio vai receber o tempo de inicio da bala distancia = Vector3.Distance(posicaoInicial, posicaoAlvo); //esta variavel vai receber a distancia entre a posição inicial da bala e do alvo gameManager = FindObjectOfType <GameManagerBehaviour>(); //o objeto gameManager vai receber o GameObject gm, passando o seu componente GameManagerBehaviour }
void OnEnable() { CurrentLevel = levels[0]; monster = this.gameObject; gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehaviour>(); }
private void OnDestroy() { instance = null; }