GameStateBehaviour.SetUpCups C# (CSharp) Метод

SetUpCups() приватный Метод

private SetUpCups ( ) : void
Результат void
	private void SetUpCups () {

		//Initialize all cups numbered from 0 to 19, where cups 0 to playerCupCount - 1 
		//belong to player 1, and playerCupCount to 2*playerCupCount-1 belong to player 2
		GameObject cup=null;
		//float y_table = TableModel.transform.position.y;
		float tableHeight = tableLocalScale.y + 0.005f;//TableModel.GetComponent<Renderer> ().bounds.size.y;
		float tableWidth = tableLocalScale.x ; //TableModel.GetComponent<Renderer> ().bounds.size.x;
		float tableLength =tableLocalScale.z ; //TableModel.GetComponent<Renderer> ().bounds.size.z;
		float zSpacing = Mathf.Sqrt (3) / 2;
		float xOffset = 0.12f ;
		dictCup = new Dictionary<int,GameObject> ();
		for (int i = 0,l=6; i < playerCupCount; i++,l+=4) {
			
			if (i == 0)
				l = 0;
			if (i == 4)
				l = 3;
			if (i == 7)
				l = 5;
			if (i == 9)
				l = 7;
			
			cup = GameObject.Instantiate<GameObject>(cupPrefab);
			playRoundObject.Add (cup);
			cup.transform.parent = BoardwalkPong.transform;
			
			if (i == 0) {
				defaultCupBounds = cup.GetComponentInChildren<Renderer> ().bounds;
				defaultCupBounds.center = Vector3.zero;
			}
			
			float cupOffset =  cup.transform.position.y - cup.GetComponentInChildren<Renderer> ().bounds.min.y;
			float cupRadius  = defaultCupBounds.extents.x;
			
			if(i<4)
				cup.transform.localPosition = new Vector3(tableWidth/2-cupRadius/2-l*cupRadius/2-xOffset,tableHeight+cupOffset,tableLength/2-zSpacing*cupRadius);
			
			else if(i>=4 && i<7)
				cup.transform.localPosition = new Vector3(tableWidth/2-l*cupRadius/2-xOffset,tableHeight+cupOffset,tableLength/2-3*zSpacing*cupRadius);
			else if(i>=7 && i<9)
				cup.transform.localPosition = new Vector3(tableWidth/2-l*cupRadius/2-xOffset,tableHeight+cupOffset,tableLength/2-5*zSpacing*cupRadius);
			else if(i==9)
				cup.transform.localPosition = new Vector3(tableWidth/2-l*cupRadius/2-xOffset,tableHeight+cupOffset,tableLength/2-7*zSpacing*cupRadius);
			
			cup.GetComponent<BeerPongCup> ().cupNumber = i;
			cup.GetComponent<BeerPongCup> ().ball = Ball;
			cup.GetComponent<BeerPongCup> ().OnHit += OnHitOpponentCup;
			dictCup.Add (i,cup);
			
			//	Debug.Log ("position is  " + magnitude);
		}

		for (int i = playerCupCount,l=6; i < 2*playerCupCount; i++,l+=4) {

			if (i == 10)
				l = 0;
			if (i == 14)
				l = 3;
			if (i == 17)
				l = 5;
			if (i == 19)
				l = 7;

			cup = GameObject.Instantiate<GameObject>(cupPrefab);
			playRoundObject.Add (cup);
			cup.transform.parent = BoardwalkPong.transform;
			
			float cupOffset =  cup.transform.position.y - cup.GetComponentInChildren<Renderer> ().bounds.min.y;
			float cupRadius  = defaultCupBounds.extents.x;

			if(i<14)
				cup.transform.localPosition = new Vector3(tableWidth/2-cupRadius/2-l*cupRadius/2-xOffset,tableHeight+cupOffset,-tableLength/2+zSpacing*cupRadius);
			
			else if(i>=14 && i<17)
				cup.transform.localPosition = new Vector3(tableWidth/2-l*cupRadius/2-xOffset,tableHeight+cupOffset,-tableLength/2+3*zSpacing*cupRadius);
			else if(i>=17 && i<19)
				cup.transform.localPosition = new Vector3(tableWidth/2-l*cupRadius/2-xOffset,tableHeight+cupOffset,-tableLength/2+5*zSpacing*cupRadius);
			else if(i==19)
				cup.transform.localPosition = new Vector3(tableWidth/2-l*cupRadius/2-xOffset,tableHeight+cupOffset,-tableLength/2+7*zSpacing*cupRadius);
			
			cup.GetComponent<BeerPongCup> ().cupNumber = i;
			cup.GetComponent<BeerPongCup> ().ball = Ball;
			cup.GetComponent<BeerPongCup> ().OnHit += OnHitOpponentCup;
			dictCup.Add (i,cup);

			//	Debug.Log ("position is  " + magnitude);
		}
	}