Beispiel #1
0
        public static void InitWorld()
        {
            GameObjectsPool.Clear();
            Stats.CansEatten = 0;
            creationTime     = DateTime.Now;

            var topWall = new Wall(
                new Vector(0, View.Height + 10),
                new Vector(View.Width, View.Height + 10));

            var bottomWall = new Wall(
                new Vector(0, -10),
                new Vector(View.Width, -10));

            var leftWall = new Wall(
                new Vector(-10, View.Height),
                new Vector(-10, 0));

            var RightWall = new Wall(
                new Vector(View.Width + 10, View.Height),
                new Vector(View.Width + 10, 0));

            GameObjectsPool.Add(topWall);
            GameObjectsPool.Add(bottomWall);
            GameObjectsPool.Add(leftWall);
            GameObjectsPool.Add(RightWall);

            var can = new PetrolCan();

            can.Translate(new Vector(200, 200));
            GameObjectsPool.Add(can);
            SpawnCar();
        }
        private static void LoadSave()
        {
            var save =
                JsonSerializer.Deserialize <GameSave>(File.ReadAllText("save.json"));

            StartNewGame();
            GameObjectsPool.Clear();
            GameObjectsPool.AddRange(save.cans);
            GameObjectsPool.AddRange(save.cars);
            GameObjectsPool.AddRange(save.cones);

            Stats.CansEatten = save.cansEatten;
            creationTime     = save.creation;

            View.InitSlips(new Bitmap(Image.FromFile("slips.bmp")));
        }