예제 #1
0
        public void Fire(IFireable fireable, int row, int col)
        {
            if (hit == 17 || row < 1 || row > 10 || col < 1 || col > 10)
            {
                return;
            }
            var curpoint = shotHistory[row - 1, col - 1];

            if (curpoint != null)
            {
                return;
            }
            if (fireable.Fire(col, row) == Result.HIT)
            {
                shotHistory[row - 1, col - 1] = "y";
                hit++;
                Fire(fireable, row + 1, col);
                Fire(fireable, row - 1, col);
                Fire(fireable, row, col + 1);
                Fire(fireable, row, col - 1);
            }
            else
            {
                shotHistory[row - 1, col - 1] = "x";
                return;
            }
        }
예제 #2
0
        /// <summary>
        /// Update is called every frame, if the MonoBehaviour is enabled.
        /// </summary>
        void Update()
        {
            if (fireable == null)
            {
                return;
            }
            var deltaTime = Time.deltaTime;

            if (FrameRate > 0)
            {
                deltaTime = 1f / FrameRate;
            }
            timer -= deltaTime;
            if (timer < 0)
            {
                config = new DanmakuConfig {
                    Position     = transform.position,
                    Rotation     = transform.rotation.eulerAngles.z * Mathf.Deg2Rad,
                    Speed        = Speed,
                    AngularSpeed = AngularSpeed,
                    Color        = Color
                };
                fireable.Fire(config);
                timer = 1f / FireRate.GetValue();
            }
        }
예제 #3
0
 public void Play(IFireable fireable)
 {
     var result = fireable.Fire(2, 1);
     Console.WriteLine(result);
     result = fireable.Fire(2, 1);
     Console.WriteLine(result);
     fireable.Fire(2, 1);
     fireable.Fire(2, 1);
     fireable.Fire(2, 1);
     fireable.Fire(2, 1);
     fireable.Fire(2, 1);
     fireable.Fire(4, 3);
     fireable.Fire(6, 7);
 }
예제 #4
0
 public void Fire(bool pressed)
 {
     if (ammo_ != null)
     {
         ammo_.Fire(1f, GlobalPosition, GlobalRotation, Vector2.Up.Rotated(GlobalRotation));
         if (!ammo_.IsLaser())
         {
             GetNode("/root").GetChild(0).AddChild(ammo_ as Node2D);
             ammo_ = (IFireable)ammoScene_.Instance();
         }
     }
 }
예제 #5
0
 protected void Trip()
 {
     cocked = false;
     Debug.Log("Hammer Tripped.");
     if (chamber != null)
     {
         chamber.Fire();
     }
     if (OnHammerStruck != null)
     {
         OnHammerStruck();
     }
 }
예제 #6
0
    public bool Fire()
    {
        if (CanFire())
        {
            UseAmmo();
            projectileFireable.Fire(muzzle, this);

            audioSource.PlayOneShot(fireSound);
            GameObject particle = Instantiate(fireParticle, muzzle.position, muzzle.rotation);
            Destroy(particle, 3f);

            return(true);
        }
        return(false);
    }
예제 #7
0
        public void Play(IFireable fireable)
        {
            var result = Result.MISS;
            while (result != Result.MISSION_COMPLETED)
            {
                var x = RANDOM.Next(1, 11);
                var y = RANDOM.Next(1, 11);

                x--;
                y--;
                if (board[x, y] != "X")
                {
                    board[x, y] = "X";
                    result = fireable.Fire(x+1, y+1);
                }
            }
        }
예제 #8
0
 public void Play(IFireable fireable)
 {
     var isMissionCompleted = false;
     for (int i = 1; i <= 10; i++)
     {
         for (int j = 1; j <= 10; j++)
         {
             var result = fireable.Fire(j, i);
             if (result == Result.MISSION_COMPLETED)
             {
                 isMissionCompleted = true;
                 break;
             }
         }
         if (isMissionCompleted)
             break;
     }
 }
예제 #9
0
 private void FireAround(IFireable fireable, int col, int row)
 {
     if (col > 10 || col < 1 || row > 10 || row < 1)
         return;
     if (IsAvaliableTarget(col - 1, row - 1))
     {
         if (fireable.Fire(col, row) == Result.HIT)
             AddHistory(col, row, "o");
         else
         {
             AddHistory(col, row, "x");
         }
     }
     else
     {
         AddHistory(col, row, "x");
     }
 }
예제 #10
0
 public void Fire(IFireable fireable, int col, int odd)
 {
     var _tempRow = (col - odd) * -1;
     if (col > 10 || _tempRow == 0 || _tempRow > 10 || _tempRow < 1 || shotHistory[col - 1, _tempRow - 1] != null)
         return;
     if (fireable.Fire(col, _tempRow) == Result.HIT)
     {
         AddHistory(col, _tempRow, "o");
         FireAround(fireable, col - 1, _tempRow);
         FireAround(fireable, col + 1, _tempRow);
         FireAround(fireable, col, _tempRow - 1);
         FireAround(fireable, col, _tempRow + 1);
     }
     else
     {
         AddHistory(col, _tempRow, "x");
     }
     Fire(fireable, col + 1, odd);
 }
예제 #11
0
        private void FireDown(IFireable fireable, int row, int column, int hit)
        {
            if (hit == 17)
            {
                return;
            }

            if (row < 1 || row > 10 || column < 1 || column > 10)
            {
                return;
            }
            var initRow = row - 1;
            var initCol = column - 1;
            var current = shotHistory[initRow, initCol];
            var top     = initRow > 0 ? shotHistory[initRow - 1, initCol] : "";
            var bottom  = initRow < 9 ? shotHistory[initRow + 1, initCol] : "";
            var left    = initCol > 0 ? shotHistory[initRow, initCol - 1] : "";
            var right   = initCol < 9 ? shotHistory[initRow, initCol + 1] : "";

            if (shotHistory[initRow, initCol] == null)
            {
                if (right != "miss")
                {
                    if (fireable.Fire(column, row) == Result.HIT)
                    {
                        hit++;
                        shotHistory[initRow, initCol] = "hit";
                        FindAnyShip(fireable, row, column, hit, shotHistory);
                        //Fire(fireable, row, column - 1, hit, tempShot);
                    }
                    else
                    {
                        shotHistory[initRow, initCol] = "miss";
                    }
                }
                else
                {
                    shotHistory[initRow, initCol] = "miss";
                }
            }
            FireDown(fireable, row + 1, column, hit);
        }
예제 #12
0
        private void FindAnyShip(IFireable fireable, int row, int col, int hitPoint, string[,] historyStrings)
        {
            if (hitPoint == 17)
            {
                return;
            }

            if (row < 1 || row > 10 || col < 1 || col > 10)
            {
                return;
            }
            var initRow = row - 1;
            var initCol = col - 1;
            var current = historyStrings[initRow, initCol];
            var top     = initRow > 0 ? historyStrings[initRow - 1, initCol] : "";
            var bottom  = initRow < 9 ? historyStrings[initRow + 1, initCol] : "";
            var left    = initCol > 0 ? historyStrings[initRow, initCol - 1] : "";
            var right   = initCol < 9 ? historyStrings[initRow, initCol + 1] : "";

            if (historyStrings[initRow, initCol] == null)
            {
                if (right != "miss")
                {
                    if (fireable.Fire(col, row) == Result.HIT)
                    {
                        hitPoint++;
                        historyStrings[initRow, initCol] = "hit";
                        FindAnyShip(fireable, row, col + 1, hitPoint, historyStrings);
                        FindAnyShip(fireable, row, col - 1, hitPoint, historyStrings);
                    }
                    else
                    {
                        historyStrings[initRow, initCol] = "miss";
                    }
                }
                else
                {
                    historyStrings[initRow, initCol] = "miss";
                }
            }
        }
예제 #13
0
        public void Fire(IFireable fireable, int col, int odd)
        {
            var _tempRow = (col - odd) * -1;

            if (col > 10 || _tempRow == 0 || _tempRow > 10 || _tempRow < 1 || shotHistory[col - 1, _tempRow - 1] != null)
            {
                return;
            }
            if (fireable.Fire(col, _tempRow) == Result.HIT)
            {
                AddHistory(col, _tempRow, "o");
                FireAround(fireable, col - 1, _tempRow);
                FireAround(fireable, col + 1, _tempRow);
                FireAround(fireable, col, _tempRow - 1);
                FireAround(fireable, col, _tempRow + 1);
            }
            else
            {
                AddHistory(col, _tempRow, "x");
            }
            Fire(fireable, col + 1, odd);
        }
예제 #14
0
 private void FireAround(IFireable fireable, int col, int row)
 {
     if (col > 10 || col < 1 || row > 10 || row < 1)
     {
         return;
     }
     if (IsAvaliableTarget(col - 1, row - 1))
     {
         if (fireable.Fire(col, row) == Result.HIT)
         {
             AddHistory(col, row, "o");
         }
         else
         {
             AddHistory(col, row, "x");
         }
     }
     else
     {
         AddHistory(col, row, "x");
     }
 }
예제 #15
0
        public static bool NonInteractableClick <T>(CompositeDisposable cd, IEngine engine,
                                                    Clickable src, IFireable <T> dst,
                                                    Func <T> valueGetter, Func <bool> checker = null)
        {
            if (!src)
            {
                return(NotBinded());
            }

            UnityAction action = () =>
            {
                if (checker != null && !checker())
                {
                    return;
                }
                dst.Fire(valueGetter());
            };

            src.onNonInteractableClick.AddListener(action);
            cd.Add(new DisposableAction(() => src.onNonInteractableClick.RemoveListener(action)));
            return(true);
        }
예제 #16
0
        private void FindAnyShip(IFireable fireable, int row, int col, int hitPoint, string[,] historyStrings)
        {
            if (hitPoint == 17)
                return;

            if (row < 1 || row > 10 || col < 1 || col > 10)
                return;
            var initRow = row - 1;
            var initCol = col - 1;
            var current = historyStrings[initRow, initCol];
            var top = initRow > 0 ? historyStrings[initRow - 1, initCol] : "";
            var bottom = initRow < 9 ? historyStrings[initRow + 1, initCol] : "";
            var left = initCol > 0 ? historyStrings[initRow, initCol - 1] : "";
            var right = initCol < 9 ? historyStrings[initRow, initCol + 1] : "";
            if (historyStrings[initRow, initCol] == null)
            {
                if (right != "miss")
                {
                    if (fireable.Fire(col, row) == Result.HIT)
                    {
                        hitPoint++;
                        historyStrings[initRow, initCol] = "hit";
                        FindAnyShip(fireable, row, col + 1, hitPoint, historyStrings);
                        FindAnyShip(fireable, row, col - 1, hitPoint, historyStrings);
                    }
                    else
                    {
                        historyStrings[initRow, initCol] = "miss";
                    }
                }
                else
                {
                    historyStrings[initRow, initCol] = "miss";
                }
            }
        }
예제 #17
0
    void FireBullet()
    {
        IFireable bullet = BulletFactory.Instance.Create(m_type);

        bullet.Fire(this.transform.position, this.transform.rotation * m_bulletVelocity);
    }
예제 #18
0
        private void FireDown(IFireable fireable, int row, int column, int hit)
        {
            if (hit == 17)
                return;

            if (row < 1 || row > 10 || column < 1 || column > 10)
                return;
            var initRow = row - 1;
            var initCol = column - 1;
            var current = shotHistory[initRow, initCol];
            var top = initRow > 0 ? shotHistory[initRow - 1, initCol] : "";
            var bottom = initRow < 9 ? shotHistory[initRow + 1, initCol] : "";
            var left = initCol > 0 ? shotHistory[initRow, initCol - 1] : "";
            var right = initCol < 9 ? shotHistory[initRow, initCol + 1] : "";
            if (shotHistory[initRow, initCol] == null)
            {
                if (right != "miss")
                {
                    if (fireable.Fire(column, row) == Result.HIT)
                    {
                        hit++;
                        shotHistory[initRow, initCol] = "hit";
                        FindAnyShip(fireable, row, column, hit, shotHistory);
                        //Fire(fireable, row, column - 1, hit, tempShot);
                    }
                    else
                    {
                        shotHistory[initRow, initCol] = "miss";
                    }
                }
                else
                {
                    shotHistory[initRow, initCol] = "miss";
                }
            }
            FireDown(fireable, row + 1, column, hit);
        }
 public void Fire()
 {
     TankFire.Fire();
 }