public MainWindow()
        {
            _instance = this;
            InitializeComponent();

            ResizeMode = ResizeMode.NoResize;

            WindowXOffset      = 50;
            WindowYOffset      = 50;
            WindowWidthOffset  = 800 - 50;
            WindowHeightOffset = 600 - 60;

            AddedComponents   = new List <IDrawable>();
            RemovedComponents = new List <IDrawable>();
            CommanderList     = new List <ShipCommander>();

            GameProps          = new GameProperties();
            GameProps.NumShips = 2;
            GameProps.GameTime = 5000;

            AddedComponents.Add(new AIChallenge.Background("Data\\Maps\\BigMap\\background.jpg"));

            System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick    += new EventHandler(Tick);
            dispatcherTimer.Interval = new TimeSpan(166666);
            dispatcherTimer.Start();

            String dir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;

            ShipCommander commander  = new ShipCommander(dir + @"\SpaceCommand\bin\Debug\SpaceCommand.dll", 100, 300);
            ShipCommander commander2 = new ShipCommander(dir + @"\AIChallenge\DLLs\TestShip.dll", 400 - 33, 300 - 20);

            CommanderList.Add(commander);
            CommanderList.Add(commander2);

            Hud = new HUD();
            AddedComponents.Add(Hud);

            LoadAllImages();
        }
        public MainWindow()
        {
            _instance = this;
            InitializeComponent();

            ResizeMode = ResizeMode.NoResize;

            WindowXOffset = 50;
            WindowYOffset = 50;
            WindowWidthOffset = 800 - 50;
            WindowHeightOffset = 600 - 60;

            AddedComponents = new List<IDrawable>();
            RemovedComponents = new List<IDrawable>();
            CommanderList = new List<ShipCommander>();

            GameProps = new GameProperties();
            GameProps.NumShips = 2;
            GameProps.GameTime = 5000;

            AddedComponents.Add(new AIChallenge.Background("Data\\Maps\\BigMap\\background.jpg"));

            System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(Tick);
            dispatcherTimer.Interval = new TimeSpan(166666);
            dispatcherTimer.Start();

            String dir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;

            ShipCommander commander = new ShipCommander(dir + @"\SpaceCommand\bin\Debug\SpaceCommand.dll", 100, 300);
            ShipCommander commander2 = new ShipCommander(dir +@"\AIChallenge\DLLs\TestShip.dll", 400 - 33, 300 - 20);

            CommanderList.Add(commander);
            CommanderList.Add(commander2);

            Hud = new HUD();
            AddedComponents.Add(Hud);

            LoadAllImages();
        }
示例#3
0
        public void UpdateResults()
        {
            int bulletMultiplier   = 20;
            int ramMultiplier      = 1;
            int survivalMultiplier = 10;
            int killMultiplier     = 100;

            String        winner       = "";
            int           highestScore = 0;
            ShipCommander shipWinner   = null;

            String results = "Results\n\n";

            results += "Ship\t\t\tBullet Damage\tRam Damage\tSurvival Bonus\tKill Bonus\tTotal\n";
            results += "---------------------------------------------------------------------------------------------------------------------------------------------------------\n";
            foreach (ShipCommander sc in MainWindow._instance.CommanderList)
            {
                int total = (sc.ship.ScoreProps.BulletDamage * bulletMultiplier) + (sc.ship.ScoreProps.RamDamage * ramMultiplier) + (sc.ship.ScoreProps.SurvivalScore * survivalMultiplier) + (sc.ship.ScoreProps.KillBonus * killMultiplier);
                sc.ship.ScoreProps.Total = total;

                if (total >= highestScore)
                {
                    highestScore = total;
                    winner       = sc.ship.GetName();
                    shipWinner   = sc;
                }

                results += sc.ship.GetName() + "\t\t\t" + (sc.ship.ScoreProps.BulletDamage * bulletMultiplier) + "\t\t" + (sc.ship.ScoreProps.RamDamage * ramMultiplier) + "\t\t" + (sc.ship.ScoreProps.SurvivalScore * survivalMultiplier) + "\t\t" + (sc.ship.ScoreProps.KillBonus * killMultiplier) + "\t\t" + sc.ship.ScoreProps.Total + "\n";
                results += "---------------------------------------------------------------------------------------------------------------------------------------------------------\n";
            }
            results   += "\nWinner: " + winner;
            resultText = FormattedTextCreator.Create(results, 15);
            Console.WriteLine(results);

            if (shipWinner != null)
            {
                shipWinner.ExecuteOnWin();
            }
        }