Example #1
0
 public void showMenu()
 {
     Add(new Background(Assets.BackgroungMenu, false));
     Add(new Cursor());
     var tmp = new Control(Assets.ButtonStart, 350, 300);
     tmp.onClick = delegate()
     {
         GameScene.Instance.RemoveAll();
         startGame();
     };
     Add(tmp);
     tmp = new Control(Assets.ButtonResults, 350, 375);
     tmp.onClick = delegate()
     {
         GameScene.Instance.RemoveAll();
         showResults();
     };
     Add(tmp);
     tmp = new Control(Assets.ButtonExit, 350, 455);
     tmp.onClick = delegate()
     {
         Environment.Exit(0);
     };
     Add(tmp);
 }
Example #2
0
 public void showResults()
 {
     Add(new Background(Assets.BackgroungMenu, false));
     Add(new Cursor());
     var str = new Label(415, 290, "TOP SCORES", Color.White, 0, false, 24);
     str.Graphic.CenterOrigin();
     Add(str);
     var results = Records.Get;
     var counter = 1;
     foreach (var item in results)
     {
         str = new Label(415, 300 + counter * 18, item.ToString(), Color.White, 0, false, 18);
         str.Graphic.CenterOrigin();
         Add(str);
         counter++;
     }
     var tmp = new Control(Assets.ButtonMenu, 350, 300 + counter * 20);
     tmp.onClick = delegate()
     {
         GameScene.Instance.RemoveAll();
         showMenu();
     };
     Add(tmp);
 }
Example #3
0
        private void showResults()
        {
            var entities = GameScene.Instance.GetEntities<Entity>();

            foreach(Entity obj in entities)
            {
                if (obj != this)
                    obj.RemoveSelf();
            }
            Label tmp = null;
            if (_team == Team.Blu)
            {
                tmp = new Label(Game.HalfWidth, 200, "YOU LOSE", Color.Red, 0, false, 24);
            }
            else
            {
                tmp = new Label(Game.HalfWidth, 200, "YOU WIN", Color.Green, 0, false, 24);
            }
            GameScene.Instance.Add(new Cursor());
            tmp.Graphic.CenterOrigin();
            GameScene.Instance.Add(tmp);
            var statsOffset = Game.HalfWidth + 200;
            var exit = new Control("ui/buttonMenu.png", Game.HalfWidth - 65, 600);
            exit.onClick = delegate()
            {
                GameScene.Instance.RemoveAll();
                ((GameScene)GameScene.Instance).showMenu();
            };
            GameScene.Instance.Add(exit);
            var listResults = new List<Label>();
            listResults.Add(new Label(statsOffset, 250, "Units produced: " + StatisticWatcher.unitsProduced.ToString(), Color.White));
            listResults.Add(new Label(statsOffset, 300, "Units killed: " + StatisticWatcher.unitsKilled.ToString(), Color.White));
            listResults.Add(new Label(statsOffset, 350, "Damage done: " + StatisticWatcher.damageDone.ToString(), Color.White));
            listResults.Add(new Label(statsOffset, 400, "Coins earned: " + StatisticWatcher.coinsEarned.ToString(), Color.White));
            listResults.Add(new Label(statsOffset, 450, "HP healed: " + StatisticWatcher.healthHealed.ToString(), Color.White));
            listResults.Add(new Label(statsOffset, 500, "------------------", Color.White));
            listResults.Add(new Label(statsOffset, 550, "Total points: " + StatisticWatcher.totalPoints.ToString(), Color.Cyan));
            foreach (Label label in listResults)
            {
                label.Graphic.CenterOrigin();
                GameScene.Instance.Add(label);
            }

            using(var stream = new StreamWriter("results.dat",true))
            {
                stream.WriteLine(Environment.UserName + ':' + StatisticWatcher.totalPoints.ToString());
            }

            //statistic grafic here, still WIP

            float scaleX = (float)425 / (float)StatisticWatcher.statistic.Count;
            float scaleY = (float)325 / (float)StatisticWatcher.maxPoints;
            Point graphStart = new Point(50, 565);
            Console.WriteLine("Scale: {0}; {1}", scaleX, scaleY);
            var startValue = 0;
            var field = new Entity();
            if (scaleX < 1)
            {
                field.Graphic = Image.CreateRectangle(425, 325, Color.Mix(Color.Gray, Color.Black));
                scaleX = 1;
                startValue = StatisticWatcher.lastRecord - 425 * StatisticWatcher.updatePeriod;
            }
            else
            {
                field.Graphic = Image.CreateRectangle(425, 325, Color.Mix(Color.Gray, Color.Black));
            }

            field.SetPosition(50, 240);
            GameScene.Instance.Add(field);

            for (var time = startValue; time <= StatisticWatcher.lastRecord; time += StatisticWatcher.updatePeriod)
            {
                var temp = new Entity();
                temp.Graphic = Image.CreateRectangle((int)scaleX, (int)((StatisticWatcher.statistic[time]) * scaleY), Color.Cyan);
                temp.SetPosition(graphStart.X + (float)Math.Round(scaleX, 2) * time / StatisticWatcher.updatePeriod, graphStart.Y - StatisticWatcher.statistic[time] * scaleY);
                GameScene.Instance.Add(temp);
            }
        }