Exemplo n.º 1
0
	// Use this for initialization
	void Start () {
		anim = GetComponent<GodHandAnimation> ();
	}
Exemplo n.º 2
0
//====================================================================================

	void Start(){
		//audio
		menuMusic = GameObject.Find("MenuMusic").GetComponent<AudioSource> ();
		roundMusic = GameObject.Find("RoundMusic").GetComponent<AudioSource> ();
		roundBreakAudio = GameObject.Find("RoundStart").GetComponent<AudioSource> ();
		endWhistle = GameObject.Find ("Whistle").GetComponent<AudioSource> ();
		scoreAudio = GameObject.Find ("ScoreAudio").GetComponent<AudioSource> ();
		menuMusic.Play ();
		roundMusic.Stop ();
		roundBreakAudio.Stop ();
		endWhistle.Stop ();
		scoreAudio.Stop ();

		//gameplay objects
		GameObject[] totems = GameObject.FindGameObjectsWithTag ("Totem");
		Debug.Assert (totems.Length == 2);
		foreach (GameObject tt in totems) {
			if (tt.transform.position.x < 0) {
				leftTotem = tt.GetComponentInChildren<SpriteRenderer> ();
				leftTotemScore = tt.GetComponentInChildren<TextMesh> ();
			} else {
				rightTotem = tt.GetComponentInChildren<SpriteRenderer> ();
				rightTotemScore = tt.GetComponentInChildren<TextMesh> ();
			}
		}
		PlayerSpawnPoint[] spawns = GameObject.FindObjectsOfType<PlayerSpawnPoint> ();
		Debug.Assert (spawns.Length == 2);
		foreach (PlayerSpawnPoint sp in spawns) {
			if (sp.transform.position.x < 0) {
				leftSpawn = sp;
			} else {
				rightSpawn = sp;
			}
		}
		godPlayer = GameObject.FindObjectOfType<GodHandAnimation> ();
		PlayerMovement[] tribesmen = GameObject.FindObjectsOfType<PlayerMovement> ();
		Debug.Assert (tribesmen.Length == 2);
		foreach (PlayerMovement pl in tribesmen) {
			if (pl.transform.position.x < 0) {
				leftPlayer = pl;
			} else {
				rightPlayer = pl;
			}
		}

		//text
		godScore = GameObject.Find ("GodScore").GetComponent<Text> ();
		idolCount = GameObject.Find ("Pedestal").GetComponentInChildren<TextMesh> ();
		pauseText = GameObject.Find ("PauseText").GetComponent<Text> ();
		pauseText.enabled = false;
		titleText = GameObject.Find ("Image").GetComponent<Image> ();
		roundText = GameObject.Find ("RoundText").GetComponent<Text> ();
		startRoundText = GameObject.Find ("StartRoundButton").GetComponent<Text>();
		endText = GameObject.Find ("EndText").GetComponent<Text> ();
		endText.enabled = false;

		//screen positioning
		cam = Camera.main;
		camHorizView = Mathf.Abs(cam.transform.position.z) * Mathf.Tan (0.5f * Mathf.Deg2Rad * cam.fieldOfView) * Screen.width / Screen.height; //the camera's horizontal view extent
		Debug.Log ("Cam view = " + camHorizView);
        /*
		float totemOffsetFromEdge = leftTotem.sprite.bounds.size.x * percentTotemOffscreen;
//		Debug.Log ("Totem sprite width = " + leftTotem.sprite.bounds.size.x + ", offset from edge = " + totemOffsetFromEdge);
		leftTotem.transform.parent.position = new Vector3(totemOffsetFromEdge - camHorizView, leftTotem.transform.parent.position.y, leftTotem.transform.parent.position.z);
		rightTotem.transform.parent.position = new Vector3(camHorizView - totemOffsetFromEdge, rightTotem.transform.parent.position.y, rightTotem.transform.parent.position.z);
        */

        InitializeNextRound();
	}