public void Respawn(int losePlayer) { if (losePlayer <= 0) { lastPosition = transform.position; lastVelocity = startForce; timeSinceLast = 0; GetComponent <Renderer>().material.color = GlobalGameManager.GetColor(lastPlayerID); Quaternion rotation = PongGameManager.CalculateCircleRotation(0, 0, PhotonNetwork.CurrentRoom.PlayerCount); photonView.RPC("AddForce", RpcTarget.All, lastPosition, rotation * startForce, losePlayer, true); return; } for (int i = 0; i < PhotonNetwork.CurrentRoom.PlayerCount; i++) { if (PhotonNetwork.PlayerList[i].ActorNumber == losePlayer) { float radius = 15f / Mathf.Tan(Mathf.PI / PhotonNetwork.CurrentRoom.PlayerCount); Quaternion rotation = PongGameManager.CalculateCircleRotation(0, i, PhotonNetwork.CurrentRoom.PlayerCount); Vector3 position = PongGameManager.CalculateCirclePosition(0, radius - 3, i, PhotonNetwork.CurrentRoom.PlayerCount); position += Vector3.up; photonView.RPC("AddForce", RpcTarget.All, position, rotation * startForce, losePlayer, true); break; } } }
private void OnTriggerEnter(Collider other) { if (other.name == "Ball") { string wallName = transform.name; PongGameManager.Score(wallName); other.gameObject.SendMessage("RestartGame", 1.0f, SendMessageOptions.RequireReceiver); } }
void Awake() { if (_instance != null && _instance == this) { Destroy(this.gameObject); } else { _instance = this; } }
private void MakeSingleton() { if (Instance != null) { Destroy(Instance); } else { Instance = this; DontDestroyOnLoad(gameObject); } }
private void Start() { rb = GetComponent <Rigidbody2D>(); circle = GetComponent <CircleCollider2D>(); game = FindObjectOfType <PongGameManager>(); sr = GetComponent <SpriteRenderer>(); Vector3 dim = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0)); bound = new Vector2(dim.x - circle.radius, dim.y - circle.radius); //Debug.Log(bound); rb.velocity = Random.insideUnitCircle.normalized * speed; //rb.velocity = new Vector2(speed, 0); }
private void Awake() { if (main != null && main != this) { Destroy(gameObject); return; } main = this; playerScores = new int[2]; manager = World.DefaultGameObjectInjectionWorld.EntityManager; GameObjectConversionSettings settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, null); ballEntityPrefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(ballPrefab, settings); oneSecond = new WaitForSeconds(1f); delay = new WaitForSeconds(respawnDelay); StartCoroutine(CountdownAndSpawnBall()); }
public void Awake() { Instance = this; }