public bool Handle(IEvent evt) { if (evt is GoalEvent) { GoalEvent goalEvent = evt as GoalEvent; DecreaseLifeCount(goalEvent.Goal.GetComponent <GoalComponent>().For); } return(false); }
void HandleGoal(GoalEvent goalEvent) { GoalComponent goalComp = goalEvent.Goal.GetComponent <GoalComponent>(); _owner.Engine.DestroyEntity(goalEvent.Ball); if (goalComp.For.Index == 0) { if (--player1Lives <= 0) { EventManager.Instance.QueueEvent(new PlayerLostEvent(_owner.Player1, _owner.Player2)); return; } } if (goalComp.For.Index == 1) { if (--player2Lives <= 0) { EventManager.Instance.QueueEvent(new PlayerLostEvent(_owner.Player2, _owner.Player1)); return; } } // Queue processes for next ball serve Process ballPlayProcess = new DelegateCommand(() => { if (goalComp.For.Index == 0) { PlayNewBall(_owner.Player1, true); } if (goalComp.For.Index == 1) { PlayNewBall(_owner.Player2, true); } }); // If there is a fluctuation, attach the serve to the fluctuation's end if (_fluctuationActive) { WaitForEvent fluctuationEnd = new WaitForEvent(typeof(FluctuationEndEvent)); fluctuationEnd.SetNext(ballPlayProcess); _processManager.Attach(fluctuationEnd); return; } // Attach the serve _processManager.Attach(ballPlayProcess); }
private void OnTriggerExit(Collider other) { if (other.CompareTag("Goal") && !goalMet) { rb.useGravity = false; rb.drag = 1f; rb.angularDrag = 1f; StartCoroutine(FlyAway()); goalMet = true; GoalEvent?.Invoke(); } if (other.CompareTag("Falloff") && goalMet == false && !isFallOut) { GameManager.Instance.ManageFalloff(); PlayerFalloutEvent?.Invoke(); isFallOut = true; } }
public void Apply(GoalEvent @event) { Goals = @event.Home ? Goals.HomeIncrement() : Goals.AwayIncrement(); MatchEvents.Add(@event); }
// HANDLERS! void HandleGoal(GoalEvent goalEvent) { // Create an explosion CreateExplosion(goalEvent.Position); }