private void GetScore(Collision2D target) { ScoreTextScript scoreTextScript = GameObject.FindGameObjectWithTag("Score").GetComponent <ScoreTextScript>(); switch (target.gameObject.transform.parent.name) { case "Row1": scoreTextScript.SetScoreValue(10); break; case "Row2": scoreTextScript.SetScoreValue(10); break; case "Row3": scoreTextScript.SetScoreValue(20); break; case "Row4": scoreTextScript.SetScoreValue(20); break; case "Row5": scoreTextScript.SetScoreValue(50); break; } }
void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag.Equals("Enemy")) { //killing enemy //dying from enemy Destroy(col.gameObject); Destroy(gameObject); SceneManager.LoadScene("lose"); } if (col.gameObject.tag.Equals("Flag")) { //taking flag to complete the level Destroy(col.gameObject); Destroy(gameObject); SceneManager.LoadScene("LevelComplete"); } if (col.gameObject.tag.Equals("coins")) { //taking coins and getting points Destroy(col.gameObject); ScoreTextScript score = GetComponent <ScoreTextScript>(); ScoreTextScript.scoreValue += 100; FindObjectOfType <AudioManager>().Play("CoinPickUp"); } }
// Use this for initialization void Start() { // Get a reference to the DijkstraManager. GameObject dijkstraManagerGO = GameObject.FindGameObjectWithTag("Dijkstra"); dijkstraManager = dijkstraManagerGO.GetComponent <DijkstraManager>(); // Get a reference to the SoundManager. soundManager = FindObjectOfType <SoundManager>(); // Get a reference to the ScoreTextManager. GameObject scoreTextGO = GameObject.FindGameObjectWithTag("ScoreTextManager"); scoreTexts = scoreTextGO.GetComponent <ScoreTextScript>(); // Get a reference to the MovementScript. movementScript = GameObject.FindGameObjectWithTag("Player").GetComponent <MovementScript>(); scoreBeer = FindObjectOfType <ScoreBeer>(); playerController = FindObjectOfType <PlayerController>(); LevelProperties lp = FindObjectOfType <LevelProperties>(); scoreBeer.SetMaxScore(lp.levelMaxScore); // Set the max score defined in the level properties. // Start the dijkstra algorithm. dijkstraManager.StartDijkstraAlgorithm(startingRouter.GetComponent <RouterScript>()); // Perform pre load move. movementScript.PerformPreLoadMove(startingRouter); movementScript.SubscribeToTargetPositionArrivedEvent(ReachedTargetPoint); // UI text fields for dijkstra routing table information. routingTableUI = GameObject.FindGameObjectWithTag("RoutingTableUI").GetComponent <RoutingTableUI>(); routingTableUI.UpdateRoutingTableUI(); player = FindObjectOfType <MovementScript>().gameObject; if (logToFile) { LevelProperties levelProperties = FindObjectOfType <LevelProperties>(); Debug.Log("Logging to file!"); levelLogging = new LevelLogging(levelProperties.levelName, " MaxScore=" + levelProperties.levelMaxScore + ", Type=" + levelProperties.gameType, PlayerPrefs.GetString("name")); //audio WriteToLog("Sound; Master: " + PlayerPrefs.GetFloat(AudioMenuMain.MASTER_VOL)); WriteToLog("Sound; Game: " + PlayerPrefs.GetFloat(AudioMenuMain.GAME_VOL)); WriteToLog("Sound; UI: " + PlayerPrefs.GetFloat(AudioMenuMain.UI_VOL)); WriteToLog("Sound; Professor: " + PlayerPrefs.GetFloat(AudioMenuMain.PROF_VOL)); WriteToLog("Sound; Background: " + PlayerPrefs.GetFloat(AudioMenuMain.BACKGROUND_VOL)); WriteToLogAppendScore("Start; Starting Game"); } }
// Start is called before the first frame update void Start() { // Ball currentBall; GameObject scoreText = GameObject.Find("ScoreText"); GameObject sphere = GameObject.Find("Sphere"); Ball ball = sphere.GetComponent <Ball>(); ScoreTextScript scoreTextScript = scoreText.GetComponent <ScoreTextScript>(); score = scoreTextScript; currentBall = ball; startFlag = false; }
void Start() { groundScript = GameObject.Find("GroundTriggerCollider").GetComponent <GroundScript> (); scoreText = GameObject.Find("score").GetComponent <ScoreTextScript> (); spawnObject = GameObject.Find("Spawner").GetComponent <SpawnerScript> (); rayCasterScript = gameObject.GetComponent <RayCastScript> (); gameManager = GameObject.Find("GameManager").GetComponent <GameManagerScript> (); scoreManager = GameObject.Find("ScoreManager").GetComponent <ScoreManager> (); cam1 = GameObject.Find("MainCamera").GetComponent <Camera>(); cam2 = GameObject.Find("SecondCamera").GetComponent <Camera>(); // leaderBoardScript = GameObject.Find ("LeaderBoard").GetComponent<LeaderBoardScript> (); }
// Use this for initialization void Start() { ScoreTextScript = GameObject.Find("ScoreText").GetComponent <ScoreTextScript> (); Object1 = (GameObject)Resources.Load("Prefab/Sphere"); Object2 = (GameObject)Resources.Load("Prefab/Cube"); Object3 = (GameObject)Resources.Load("Prefab/Capsule"); Object4 = (GameObject)Resources.Load("Prefab/Cylinder"); Object5 = (GameObject)Resources.Load("Prefab/Quad"); Instantiate(Object1, generateNewPosition(), Quaternion.identity); Instantiate(Object2, generateNewPosition(), Quaternion.identity); Instantiate(Object3, generateNewPosition(), Quaternion.identity); Instantiate(Object4, generateNewPosition(), Quaternion.identity); Instantiate(Object5, generateNewPosition(), Quaternion.identity); }
// Update is called once per frame void Update() { if (Time.time > nextSpawn) { nextSpawn = Time.time + spawnRate; randX = Random.Range(50.0f, 60.0f); WhereToSpawn = new Vector2(randX, transform.position.y); Instantiate(Enemy, WhereToSpawn, Quaternion.identity); } ScoreTextScript score = GetComponent <ScoreTextScript>(); if (ScoreTextScript.scoreValue == 200) { } }
void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "Floor") { MainLoopScript.isGameOver = true; } if (coll.gameObject.tag == "Pipe") { MainLoopScript.isGameOver = true; } if (coll.gameObject.tag == "Bod") { score += 10; ScoreTextScript.setScoreTxt(score); Destroy(coll.gameObject); SpawnPipes.bodRazmaci.Remove(coll.gameObject); } }
void Update() { transform.position = Vector2.MoveTowards(transform.position, target.position, speed * Time.deltaTime); FindObjectOfType <AudioManager>().Play("EnemyWalking"); ScoreTextScript score = GetComponent <ScoreTextScript>(); if (ScoreTextScript.scoreValue == 1000) { speed = 8; health = 150; } if (ScoreTextScript.scoreValue == 2000) { speed = speed * Time.deltaTime + 10; health = 200; } }
void Awake() { anim = GetComponent <Animator> (); cameraTransform = Camera.main.transform; speedFloat = Animator.StringToHash("Speed"); jumpBool = Animator.StringToHash("Jump"); hFloat = Animator.StringToHash("H"); vFloat = Animator.StringToHash("V"); aimBool = Animator.StringToHash("Aim"); // fly flyBool = Animator.StringToHash("Fly"); groundedBool = Animator.StringToHash("Grounded"); distToGround = GetComponent <Collider>().bounds.extents.y; sprintFactor = sprintSpeed / runSpeed; // CoinScore scoreS = scoreText.GetComponent <ScoreTextScript>(); }
// Use this for initialization void Start() { levelProperties = FindObjectOfType <LevelProperties>(); scoreBeer = FindObjectOfType <ScoreBeer>(); // Get reference to the ScoreTextManager. GameObject scoreTextGO = GameObject.FindGameObjectWithTag("ScoreTextManager"); scoreTexts = scoreTextGO.GetComponent <ScoreTextScript>(); professorController = FindObjectOfType <ProfessorController>(); if (!ApplicationState.levelRestarted) { StartCoroutine(ShowProfessorAfterTime()); player.SetActive(false); } gameState = FindObjectOfType <GameState>(); // Calculate max score. int maxScore = determineMaxScore(); FindObjectOfType <ScoreBeer>().SetMaxScore(maxScore); }
public void PlayAgain() { ScoreTextScript.Reset(); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1); }
void Awake() { gameManagerScript = GameObject.Find("GameManager").GetComponent <GameManagerScript> (); scoreText = GameObject.Find("score").GetComponent <ScoreTextScript> (); }
// Start is called before the first frame update void Start() { money = ScoreTextScript.GetInt(); }