public void Fire()
 {
     // Create a missile.
     Missile missile = new Missile(this);
     missile.Space = this.Space;   // must add the missile to our Space, or it won't really get added
 }
Beispiel #2
0
        // Add up the score!
        protected void Score()
        {
            Dictionary <Planet, int> d_PlanetToNumMissiles = new Dictionary <Planet, int>();

            long score   = 0;
            long aiscore = 0;

            foreach (Sprite sprite in this._Sprites)
            {
                Missile missile = sprite as Missile;
                if (null != missile)
                {
                    if (missile.Parent is Missile)
                    {
                        // Assign scores accordingly to fires by which ship.
                        if (missile.firerID == 0)
                        {
                            score += 1;
                        }
                        else
                        {
                            aiscore += 1;
                        }
                    }
                    else if (missile.Parent is Planet && missile.Parent.ImageFileName == "Images/FlatTarget.gif")
                    {
                        if (missile.firerID == 0)
                        {
                            score += 50;
                        }
                        else
                        {
                            aiscore += 1;
                        }

                        Planet target = (Planet)missile.Parent;
                        if (d_PlanetToNumMissiles.ContainsKey(target))
                        {
                            d_PlanetToNumMissiles[target]++;
                        }
                        else
                        {
                            d_PlanetToNumMissiles[target] = 1;
                        }
                    }
                    else if (missile.Parent is Planet)
                    {
                        if (missile.firerID == 0)
                        {
                            score -= 100;
                        }
                        else
                        {
                            aiscore -= 100;
                        }
                    }
                }
            }


            if (d_PlanetToNumMissiles.Count >= NumTargets)
            {
                int min = int.MaxValue;
                foreach (int missiles in d_PlanetToNumMissiles.Values)
                {
                    if (missiles < min)
                    {
                        min = missiles;
                    }
                }

                score += min * 1000;
            }

            labelScore.Text = score.ToString();
            labelAI.Text    = aiscore.ToString();
        }