private bool WasLastPottedBallRed(IShot shot) { return(ShotHistoryProvider.LastShotDetails.ShotResult.HasFlag(ShotResult.ValidShot) && ShotHistoryProvider.LastShotDetails.ShotResult.HasFlag(ShotResult.PlayerContinues) && ShotHistoryProvider.LastShotDetails.Player.Equals(shot.Player) && ShotHistoryProvider.LastShotDetails.Shot.BallsPotted.All(ball => ball.Is(BallTypes.Red))); }
public void AddShotBuilder(ShotName name) { IShot shot = shotFactory.CreateShot(name); if (shot != null) { stateStack.Enqueue(shot); } }
public void RemoveShot(IShot shot) { var enemies = this.Game.Components.OfType<IEnemy>(); foreach (var enemy in enemies.Where(enemy => enemy.Weapon.Shots.Contains(shot))) { enemy.Weapon.Shots.Remove(shot); } }
public void ClearAndDeactivateShotInBuffer() { if (thisShotInBuffer != null) { IArrow arrow = thisShotInBuffer.GetArrow(); arrow.Deactivate(); thisShotInBuffer = null; } }
public void TakeHit(IShot shot) { Debug.Log(name + " takes a hit"); if (health != null) { Debug.Log("And has health"); health.HitPoints -= shot.Damage; } }
public void ReportEnemyHit(IEnemy enemy, IShot shot) { enemy.SubtractHealth(shot.FirePower); // Todo: Ugly.. if (enemy.IsBoss && enemy.Health <= 0) { this.IsBossEliminated = true; } }
private static ShotDetails CreateShotHistory(IShot shot, IGameResult breakResult) { return(new ShotDetails { ShotResult = breakResult.Result, LastPlayedBall = shot.FirstTouchedBall, Player = shot.Player, Shot = shot }); }
public AKM() { var emptyShot = new EmptyShot(); var actionShot = new AfterShotActionDecorator(emptyShot, MakeShot); var delayShot = new AfterShotDelayDecorator(actionShot, beetwenShotsDelay); var trottling = new TrottleUntilShotDecorator(delayShot); var repeatShot = new RepeatShotDecorator(trottling); shot = repeatShot; shot.Subscribe(); }
public override ShotResult ValidateShot(IShot shot) { // 1. He can hit a red. (Both player) // Scenarios // a. Fresh Hit (New Player) // b. Color Followup (Old Player) // 2. He can hit a color (Both Players) // Scenarios // a. Red followup (Old Player) // b. Free Ball (New Player) **** // TODO // c. ColorRundown (Both Players) var shotResult = ShotResult.Undetermined; if (ShouldHitColor(shot)) { shotResult = ValidateColorHit(shot); } else if (shot.FirstTouchedBall.Is(BallTypes.Red)) { shotResult = ShotResult.ValidShot; if (shot.BallsPotted.Length > 0 && shot.BallsPotted.All(ball => ball.Is(BallTypes.Red))) { shotResult |= ShotResult.PlayerContinues; } else if (shot.BallsPotted.Length > 0 && shot.BallsPotted.Any(ball => !ball.Is(BallTypes.Red))) { shotResult |= ShotResult.OpenentContinues; shotResult |= ShotResult.InvalidShot; } else if (shot.BallsPotted.Length == 0) { shotResult |= ShotResult.OpenentContinues; } } else if (shot.FirstTouchedBall.Is(BallTypes.None)) { shotResult = ShotResult.InvalidShot | ShotResult.OpenentCan | ShotResult.AskToPlayAgain | ShotResult.AcceptTable; } else if (!shot.FirstTouchedBall.Is(BallTypes.Red)) { shotResult = ShotResult.InvalidShot | ShotResult.OpenentCan | ShotResult.AskToPlayAgain | ShotResult.CanReRack; } ShotHistoryProvider.PushShotDetails(CreateShotHistory(shot, new GameResult() { IsSuccessful = true, Result = shotResult })); return(shotResult); }
public virtual IGameResult IsValidBreak(IShot shot) { var gameResult = new GameResult(); if (!ArePlayerSet()) { throw new InvalidOperationException("Players are not set yet!"); } gameResult.IsSuccessful = true; return(gameResult); }
public override IGameResult IsValidBreak(IShot shot) { var breakResult = base.IsValidBreak(shot); if (breakResult.IsSuccessful) { breakResult.Result = ValidateShot(shot); ShotHistoryProvider.PushShotDetails(CreateShotHistory(shot, breakResult)); } return(breakResult); }
public virtual void RegisterShot(IArrow arrow) { if (thisShotInBuffer == null) { thisShotInBuffer = new Shot(arrow); if (thisShootingProcess == null) { thisShootingProcess = thisSlickBowShootingProcessFactory.CreateShootingProcess( this, thisFireRate ); thisShootingProcess.Run(); } } }
void ExecuteShot() { IShot shotInBuffer = thisShootingManager.GetShotInBuffer(); if (shotInBuffer != null) { IArrow arrow = shotInBuffer.GetArrow(); arrow.StartFlight(); thisShootingManager.ClearShotBuffer(); } else { this.Expire(); } }
// 메인 코루틴 private IEnumerator MoveMain() { StartCoroutine(_Logic.MoveConstantVelocity(this, new Vector2(0.0f, 0.75f), 30)); yield return new WaitForFrames(100); while (true) { if (stateStack.Count > 0) { IShot shot = stateStack.Dequeue(); Log(shot.ToString()); yield return StartCoroutine(shot.Shot(this)); } yield return new WaitForFrames(30); } }
public override IGameResult IsValidBreak(IShot shot) { var gameResult = base.IsValidBreak(shot); if (gameResult.IsSuccessful) { if (shot.BallsHitOnRails.Length == 4) { gameResult.Result = ShotResult.ValidShot; } if (shot.BallsPotted.Any(ball => ball.Is(BallTypes.Eight))) { gameResult.Result |= ShotResult.CanReRack; } } return(gameResult); }
public void Fire(ShotType type, IShot shot, Vector3 start, Vector3 dir, float speed, float lifeTime, Transform friend) { if (count == shots.Length) { int l = shots.Length; int wl = shots.Length * 2 + 1; IncreseArray(ref shots, wl); IncreseArray(ref verts, wl * 4); IncreseArray(ref uvs, wl * 4); for (int i = l; i < wl; i++) { shots[i] = new Shot(); } } switch (type) { case ShotType.Bluster: shots[count].pos = start; shots[count].type = SizeType.Dynamic; shots[count].uvRect = atlasMap[0]; shots[count].width = .75f; break; case ShotType.Rocket: shots[count].pos = start + dir * 12f; shots[count].type = SizeType.Static; shots[count].length = 6f; shots[count].width = 1f; shots[count].uvRect = atlasMap[1]; break; } shots[count].back = shots[count].pos; shots[count].dir = dir; shots[count].speed = speed; shots[count].dead = Time.time + lifeTime; shots[count].shot = shot; shots[count].friend = friend; count++; }
private ShotResult ValidateColorHit(IShot shot) { var shotResult = ShotResult.Undetermined; if (shot.FirstTouchedBall.IsBallInGroup(BallGroupTypes.Colors)) { if (shot.BallsPotted.Length == 0) { shotResult = ShotResult.ValidShot | ShotResult.OpenentContinues; } else if (shot.BallsPotted.Length == 1 && shot.BallsPotted.All(ball => ball.IsBallInGroup(BallGroupTypes.Colors))) { if (shot.BallsPotted.Any(ball => !ball.Is(shot.FirstTouchedBall.BallType))) { shotResult = ShotResult.InvalidShot | ShotResult.OpenentContinues; } else { shotResult = ShotResult.ValidShot | ShotResult.PlayerContinues; } } else if (shot.BallsPotted.Length > 1) { shotResult = ShotResult.InvalidShot | ShotResult.OpenentContinues | ShotResult.ReSpotColorBalls; } } //This check will cover the scenarion when cue ball did not hit any other ball. else if (!shot.FirstTouchedBall.IsBallInGroup(BallGroupTypes.Colors)) { shotResult = ShotResult.InvalidShot | ShotResult.OpenentContinues; if (!GameInsightProvider.CanCueBallSeeBothSidesOfAnyRed()) { shotResult |= ShotResult.FreeBall; } } return(shotResult); }
public void Fire(IShot shot, Vector3 start, Vector3 dir, float speed, float lifeTime, ShipController friend) { if (count == shots.Length) { int l = shots.Length; int wl = shots.Length * 2 + 1; Algs.IncreseArray(ref shots, wl); Algs.IncreseArray(ref verts, wl * size); Algs.IncreseArray(ref uvs, wl * size); for (int i = l; i < wl; i++) { shots[i] = new SShot(); } } shots[count].pos = start; shots[count].back = shots[count].pos; shots[count].velocity = dir * speed; shots[count].dead = Time.time + lifeTime; shots[count].friend = friend; shots[count].shot = shot; count++; }
public void SetShootingAbility(IShot newShootingType) { this.ShootingType = newShootingType; }
public virtual IGameResult Begine(IShot shot) { var shotResult = _cueBallGameReferee.IsValidBreak(shot); return(shotResult); }
public ShotMovedEventArgs(IShot shot, bool disappeared) { Shot = shot; Disappeared = disappeared; }
public TrottleUntilShotDecorator(IShot shot) { this.shot = shot; }
protected void HitPlayer(IShot s, IUnit unit) { unit.Health -= s.Damage; if (unit is UnitPlayer) (unit as UnitPlayer).UpdateHeader(); }
protected void Shoot(IShot shot) { if (_bullets > 0) { Ammo--; IUnit unit = null; if (shot.Step(out unit)) { if (unit != null) HitPlayer(shot, unit); return; } if (Game.Network != null) Game.Network.NetworkDataHandler.Register(shot); _shots.Add(shot); } }
private void RemoveShot(IShot shot) { GameObjects.Remove(shot); }
public override IGameResult Begine(IShot shot) { throw new System.NotImplementedException(); }
public void ReportPlayerHit(IShot shot) { this.player.SubtractHealth(shot.FirePower); }
public BeforeStartDelayDecorator(IShot shot, TimeSpan delay) { this.shot = shot; delayTimer = new RealTimeTimer(delay); }
public override IGameResult IsValidBreak(IShot shot) { throw new System.NotImplementedException(); }
public AfterShotDelayDecorator(IShot shot, TimeSpan delay) { this.shot = shot; delayTimer = new RealTimeTimer(delay); }
private bool FindCollisions(IShip ship, IShot shot) { var rect1 = ship.Area; var rect2 = new Rect(shot.Location.X, shot.Location.Y, Shot.ShotSize.Width, Shot.ShotSize.Height); return rectsOverlap(rect1, rect2); }
public RepeatShotDecorator(IShot shot) { this.shot = shot; }
public AfterShotActionDecorator(IShot shot, Action action) { this.shot = shot; this.action = action; }
public void RemoveShot(IShot shot) { this.player.Weapon.Shots.Remove(shot); }
public SwitchingMoveLabel(CCLabel label, IShot move) : base(label, move) { }
public virtual ShotResult ValidateShot(IShot shot) { throw new NotImplementedException(); }
public IGameResult Shot(IShot shot) { var shotResult = _cueBallGameReferee.ValidateShot(shot); return(new GameResult(true, shotResult)); }
public override IGameResult Begine(IShot shot) { var gameResult = base.Begine(shot); return(gameResult); }
public void ClearShotBuffer() { thisShotInBuffer = null; }