private void Start() { bulletVars = GetComponent <BaseBulletVariables>(); Rigidbody2D rigidBody = GetComponent <Rigidbody2D>(); rigidBody.velocity = rigidBody.velocity * movementSpeed; }
private void OnTriggerStay2D(Collider2D collision) { BaseBulletVariables bulletVars = collision.GetComponent <BaseBulletVariables>(); if (bulletVars != null && bulletVars.ownerPlayerId != vars.playerId) { vars.Energy += energyPerFrame; } }
void OnTriggerEnter2D(Collider2D collidingBullet) { // TODO: Consider making this unit testable by extracting logic to an outside class/method BaseBulletVariables bulletVars = collidingBullet .gameObject .GetComponent(typeof(BaseBulletVariables)) as BaseBulletVariables; // A bullet that isn't owned by the player if (bulletVars != null && bulletVars.ownerPlayerId != hitPlayerId) { GameStats.playerScores.TryGetValue(bulletVars.ownerPlayerId, out int currentScore); currentScore += 1; GameStats.playerScores[bulletVars.ownerPlayerId] = currentScore; // This might be needed since I was testing with an outdated client GameObject[] bullets = GameObject.FindGameObjectsWithTag("Bullet"); foreach (GameObject bullet in bullets) { PhotonNetwork.Destroy(bullet); } // TODO: fix GameObject particleObject = PhotonNetwork.Instantiate( explosionParticles.name, gameObject.transform.position, Quaternion.identity); particleObject.GetComponent <ParticleSystem>().Play(); gameController.UpdateScoreUi(); gameController.CheckGameOver(); PhotonNetwork.Destroy(this.transform.parent.gameObject); gameNetworkManager.photonView.RPC("RPCDie", RpcTarget.All); } }