protected void OnShot(object sender, CollisionDetectedEventArgs e) { if (Shot != null) { Shot(sender, e); } }
protected virtual void OnPlayerGetsShot(object sender, CollisionDetectedEventArgs e) { if (PlayerGetsShot != null) { PlayerGetsShot(this, e); } }
void OnTriggerEnter(Collider trigger) { IShootable ammu = trigger.gameObject.GetComponent <IShootable>(); // Ignore if is not a shot if (ammu == null) { return; } if (trigger.gameObject.tag != Tags.SaucerAmmu) { return; } Debug.Log(this.name + " -Trigger in " + trigger.gameObject.name); EnemyUnit sourceEntity = ammu.Source.gameObject.GetComponentInParent <EnemyUnit>(); // Who Shoots? CollisionDetectedEventArgs e = new CollisionDetectedEventArgs(); e.EnemyUnit = sourceEntity; OnPlayerGetsShot(this, e); /*CollisionDetectedEventArgs e = new CollisionDetectedEventArgs(); * e.EnemyUnit = gameObject.GetComponent<EnemyUnit>(); * OnPlayerGetsShot(this, e);*/ }
// Player Shot /*public event EventHandler<CollisionDetectedEventArgs> PlayerShot; * protected virtual void OnPlayerShot(object sender, CollisionDetectedEventArgs e) * { * if (PlayerShot != null) * PlayerShot(this, e); * }*/ // Active or Passive Enemy (Asteroids/Saucer) gets shot void OnTriggerEnter(Collider trigger) { IShootable ammu = trigger.gameObject.GetComponent <IShootable>(); // Ignore if is not a shot if (ammu == null) { return; } Transform ammuSource = ammu.Source; EntityBehaviour sourceEntity = ammuSource.gameObject.GetComponentInParent <EntityBehaviour>(); EnemyUnit targetUnit = gameObject.GetComponentInParent <EnemyUnit>(); if (targetUnit != null && sourceEntity != null) { /*if (targetUnit.tag == "Saucer") * Debug.Log("STOP"); * * if (targetUnit.tag == "Player") * Debug.Log("PLAYER SHOT"); */ // Unit Shot by Player (Asteroid or Saucer) CollisionDetectedEventArgs colisionEvent = new CollisionDetectedEventArgs(); colisionEvent.SourceEntity = sourceEntity; // Player colisionEvent.EnemyUnit = targetUnit; // Enemy Shot - Asteroid/Saucer // Debug.Log(this.name + " -Trigger in " + trigger.gameObject.name); OnUnitShot(this, colisionEvent); } }
protected void OnScored(object sender, CollisionDetectedEventArgs e) { if (Scored != null) { Scored(sender, e); } }
protected virtual void OnUnitShot(object sender, CollisionDetectedEventArgs e) { if (UnitShot != null) { UnitShot(this, e); } }
protected virtual void OnCollided(object sender, CollisionDetectedEventArgs e) { if (Collided != null) { Collided(sender, e); } }
void OnCollisionEnter(Collision colision) { //Debug.Log(this.name + " -Collided with: " + colision.gameObject.name); CollisionDetectedEventArgs e = new CollisionDetectedEventArgs(); e.SourceEntity = gameObject.GetComponent <EntityBehaviour>(); e.EnemyUnit = colision.gameObject.GetComponentInParent <EnemyUnit>(); OnCollided(this, e); }
private void OnScored(object sender, CollisionDetectedEventArgs e) { EnemyUnit unit = e.EnemyUnit; // Todo check points obtained gameState.CurrentScore += e.EnemyUnit.DestructionScore; // Update UI uiController.UpdateScore(gameState.CurrentScore); }
/// <summary> /// A Unit has been shot by the player /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnUnitShot(object sender, CollisionDetectedEventArgs e) { // VFX of PassiveEnemy (Asteroid) / ActiveEnemy (Saucer) EnemyUnit unit = e.EnemyUnit; unit.Collide(); // Player scored OnScored(sender, e); // TODO Add nice animation with the Points Scored }
private void OnPlayerGetsShot(object sender, CollisionDetectedEventArgs e) { EnemyUnit activeEnemy = e.EnemyUnit; // Player Collision if (player == null) { return; } player.Collide(activeEnemy.Damage); // TODO Recicly Unit //m_enemySpawner.Reset(); }
/// <summary> /// An Active/Passive unit has been collided (by the player) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnEntityCollided(object sender, CollisionDetectedEventArgs e) { // VFX of PassiveEnemy (Asteroid) / ActiveEnemy (UFO) EnemyUnit unit = e.EnemyUnit; if (unit == null) { return; // TODO: Recheck, this should not happen... } unit.Collide(); // Player Collision e.SourceEntity.Collide(unit.Damage); }