private void shotMade(Event ev) { PlayerShotEvent playerShotEvent = (PlayerShotEvent)ev; if (playerShotEvent.Player == Player) { //I made a shot } else { //other player has made a shot } }
private void OnPlayerShotInput(float _power) { PlayerShotEvent?.Invoke(_power); m_whiteBall.OnPlayerShot(_power, m_shotAimDirection.normalized); //it's already normalized but it's a double check SwitchGameState(GameState.ProcessingShot); SaveLastShotData(_power); }
public override void Awake() { base.Awake(); OnPlayerShot = new PlayerShotEvent(); OnEnemyDeath = new EnemyDeathEvent(); OnEnemyHitPlayer = new UnityEvent(); OnPlayerDeath = new UnityEvent(); OnUpdateHeath = new UpdateHeathEvent(); OnUpdateScore = new UpdateScoreEvent(); OnUpgradeLevel = new UpgradeLevelEvent(); }
/// <summary> /// Use when a player shoots and hits a ship. /// </summary> /// <param name="plr"></param> /// <param name="shot"></param> /// <param name="shipHit"></param> /// <returns></returns> public virtual bool PlayerShot(Player plr, Shot shot, Ship shipHit) { if (!players.Contains(plr)) { PlayerShotEvent ev = new PlayerShotEvent(plr, shot, shipHit); AppendEvent(ev); if (OnPlayerShot != null) { OnPlayerShot(this, ev); } return(true); } return(false); }
private void HandlePlayerShot(Event ev) { PlayerShotEvent evCasted = (PlayerShotEvent)ev; Shot shot = evCasted.Shot; Player plr = evCasted.Player; if (plr != CurrentPlayer) { throw new InvalidEventException(evCasted, REASON_NOT_TURN); } if (plr.ShotsMade.Count(x => x == shot) > 1) { plr.Disqualify(REASON_SHOT); plr.Lose(); waitSignal.Set(); throw new InvalidEventException(evCasted, REASON_SHOT); } waitList.Remove(plr); waitSignal.Set(); }
private void HandlePlayerShot(Event ev) { PlayerShotEvent evCasted = (PlayerShotEvent)ev; Player plr = evCasted.Player; Shot shot = evCasted.Shot; if (plr == myPlayer) { Ship shipHit = ShipList.GetShipAt(shot); if (shipHit == null) { oldController.ShotMiss(shot); } else { oldController.ShotHit(shot, shipHit.IsSunk()); } } else { oldController.OpponentShot(shot); } }
/// <summary> /// Use when a player shoots and hits a ship. /// </summary> /// <param name="plr"></param> /// <param name="shot"></param> /// <param name="shipHit"></param> /// <returns></returns> public virtual bool PlayerShot(Player plr, Shot shot, Ship shipHit) { if (!players.Contains(plr)) { PlayerShotEvent ev = new PlayerShotEvent(plr, shot, shipHit); AppendEvent(ev); if (OnPlayerShot != null) { OnPlayerShot(this, ev); } return true; } return false; }
private void ASCIIUpdateShot(Event ev) { PlayerShotEvent shotEvent = (PlayerShotEvent)ev; ModifyASCII(shotEvent.Shot.ReceiverPlr.ID, shotEvent.Shot.Coordinates.X, shotEvent.Shot.Coordinates.Y, ' ', ConsoleColor.White, ConsoleColor.DarkGray); }