private void Start() { startsurface = 0; if (PhotonNetwork.IsMasterClient) { hole = LavaSpawnerv2.Register_Hole(gameObject); GlobalPosition = LavaSpawnerv2.Get_Position(hole); photonView.RPC("SyncHole", RpcTarget.All, hole); } mesh = new Mesh(); //StartCoroutine("WaitforRadia"); Createmesh(); InvokeRepeating("MeshGrowing", 1f, 0.5f); InvokeRepeating("surface_calculator", 1f, 0.5f); InvokeRepeating("CheckHits", 1f, 1f); if (StaticVariables.IsSpectator) { this.gameObject.transform.GetChild(1).gameObject.SetActive(true); this.gameObject.transform.GetChild(1).GetComponent <TextMesh>().text = hole.ToString(); } if (ScoreMenu.Gamecounter == 3) { Players = (PhotonNetwork.CountOfPlayers - 1) / 2; } else { Players = (PhotonNetwork.CountOfPlayers - 1); } }
public void surface_calculator() { theoretical_radius = theoretical_radius + Proportional_increment; //Debug.Log("radius" + radius); //Debug.Log("theorie radius" + theoretical_radius); Track_Surface_old = Track_Surface; Track_Surface = 0; for (int i = 0; i < triangles.Length; i = i + 3) { Vector3 A = vertices[triangles[i]]; Vector3 B = vertices[triangles[i + 1]]; Vector3 C = vertices[triangles[i + 2]]; //Debug.Log(B); Track_Surface += Mathf.Abs((A.x * (B.z - C.z) + B.x * (C.z - A.z) + C.x * (A.z - B.z)) / 2); } if (startsurface == 0) { startsurface = Track_Surface; } //Debug.Log(Track_Surface); Track_null_Surface = 0;//2 * radius * (float)3.14; for (int i = 0; i < triangles.Length; i = i + 3) { Vector3 AA = new Vector3(); AA.x = 0; AA.y = 0.2f; AA.z = 0; Vector3 BB = new Vector3(); BB.x = theoretical_radius * Mathf.Sin(0);; BB.y = 0f; BB.z = theoretical_radius * Mathf.Cos(0); Vector3 CC = new Vector3(); CC.x = theoretical_radius * Mathf.Sin(deltaAngle * val); CC.y = 0f; CC.z = theoretical_radius * Mathf.Cos(deltaAngle * val); Track_null_Surface += Mathf.Abs((AA.x * (BB.z - CC.z) + BB.x * (CC.z - AA.z) + CC.x * (AA.z - BB.z)) / 2); } if (PhotonNetwork.IsMasterClient) { float MaxScore = Track_null_Surface - startsurface; //pass through what they managed to stop LavaSpawnerv2.Update_Score(Track_null_Surface - Track_Surface, MaxScore, BlockerString, hole); } //if (PhotonNetwork.IsMasterClient) //{ // //pass through what they managed to stop // LavaSpawnerv2.Update_Score(Track_null_Surface - Track_Surface, BlockerString, hole); //} }