コード例 #1
0
        //Fires on Eater if its within range
        public void FireOnEaters(IEater[] eaters)
        {
            foreach (IEater eater in eaters)
            {
                if (eater.IsActive && _location.InRangeOf(eater.Location, Range))
                {
                    if (IsShotSuccessful())
                    {
                        eater.DecreaseHealth(Power);

                        if (eater.IsDead)
                        {
                            _score.setInvadersKilled(1);
                            Console.WriteLine("Killed an eater at: " + eater.Location + "! " + "Kills: " +
                                              _score.InvadersKilled);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Shot missed at: " + eater.Location);
                    }

                    _score.IncreaseScore(10);
                    break;
                }
            }
        }