Ejemplo n.º 1
0
 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)));
 }
Ejemplo n.º 2
0
 public void AddShotBuilder(ShotName name)
 {
     IShot shot = shotFactory.CreateShot(name);
     if (shot != null)
     {
         stateStack.Enqueue(shot);
     }
 }
Ejemplo n.º 3
0
 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;
     }
 }
Ejemplo n.º 5
0
 public void TakeHit(IShot shot)
 {
     Debug.Log(name + " takes a hit");
     if (health != null)
     {
         Debug.Log("And has health");
         health.HitPoints -= shot.Damage;
     }
 }
Ejemplo n.º 6
0
        public void ReportEnemyHit(IEnemy enemy, IShot shot)
        {
            enemy.SubtractHealth(shot.FirePower);

            // Todo: Ugly..
            if (enemy.IsBoss && enemy.Health <= 0)
            {
                this.IsBossEliminated = true;
            }
        }
Ejemplo n.º 7
0
 private static ShotDetails CreateShotHistory(IShot shot, IGameResult breakResult)
 {
     return(new ShotDetails
     {
         ShotResult = breakResult.Result,
         LastPlayedBall = shot.FirstTouchedBall,
         Player = shot.Player,
         Shot = shot
     });
 }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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();
         }
     }
 }
Ejemplo n.º 13
0
        void ExecuteShot()
        {
            IShot shotInBuffer = thisShootingManager.GetShotInBuffer();

            if (shotInBuffer != null)
            {
                IArrow arrow = shotInBuffer.GetArrow();
                arrow.StartFlight();
                thisShootingManager.ClearShotBuffer();
            }
            else
            {
                this.Expire();
            }
        }
Ejemplo n.º 14
0
            // 메인 코루틴
            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);
                }
            }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
    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++;
    }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
    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++;
    }
Ejemplo n.º 19
0
 public void SetShootingAbility(IShot newShootingType)
 {
     this.ShootingType = newShootingType;
 }
Ejemplo n.º 20
0
        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;
 }
Ejemplo n.º 23
0
 protected void HitPlayer(IShot s, IUnit unit)
 {
     unit.Health -= s.Damage;
     if (unit is UnitPlayer)
         (unit as UnitPlayer).UpdateHeader();
 }
Ejemplo n.º 24
0
 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);
		}
Ejemplo n.º 26
0
 public override IGameResult Begine(IShot shot)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 27
0
 public void ReportPlayerHit(IShot shot)
 {
     this.player.SubtractHealth(shot.FirePower);
 }
Ejemplo n.º 28
0
        public BeforeStartDelayDecorator(IShot shot, TimeSpan delay)
        {
            this.shot = shot;

            delayTimer = new RealTimeTimer(delay);
        }
Ejemplo n.º 29
0
 public override IGameResult IsValidBreak(IShot shot)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 30
0
        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);
        }
Ejemplo n.º 32
0
 public RepeatShotDecorator(IShot shot)
 {
     this.shot = shot;
 }
Ejemplo n.º 33
0
 public AfterShotActionDecorator(IShot shot, Action action)
 {
     this.shot   = shot;
     this.action = action;
 }
Ejemplo n.º 34
0
 public void RemoveShot(IShot shot)
 {
     this.player.Weapon.Shots.Remove(shot);
 }
Ejemplo n.º 35
0
 public SwitchingMoveLabel(CCLabel label, IShot move) : base(label, move)
 {
 }
Ejemplo n.º 36
0
 public virtual ShotResult ValidateShot(IShot shot)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 37
0
        public IGameResult Shot(IShot shot)
        {
            var shotResult = _cueBallGameReferee.ValidateShot(shot);

            return(new GameResult(true, shotResult));
        }
Ejemplo n.º 38
0
        public override IGameResult Begine(IShot shot)
        {
            var gameResult = base.Begine(shot);

            return(gameResult);
        }
 public void ClearShotBuffer()
 {
     thisShotInBuffer = null;
 }