Esempio n. 1
0
        public Controller()
            : base()
        {
            if (DB.Planets == null)
            DB.Planets = DB.GenerateDefaultPlanetData();

              foreach (var item in DB.Planets)
            Planets.Add(new Planet(item.PlanetID, item.Position, item.Diameter, (PlanetTypes)item.PlanetType));

              Planets[Planets.Count - 1].Shielded = true;

              Whale = new Whale(DB.CurrentSave.PositionInSpace);
              WhaleEnergy = new UI.EnergyBar(new Vector2(42, 560), DB.CurrentSave.WhaleEnergy / 1000);

              ButtonTeleport = new UI.Button(0, 0, "UI/ButtonTeleport", Events.Teleport);
              ButtonTeleport.ScrollingScreen = true;

              ButtonInventory = new UI.Button(807, 556, "UI/ButtonInventory", Events.ShowHideInventory);
              ButtonWiki = new UI.Button(870, 556, "UI/ButtonWiki", Events.ShowHideWiki);
              ButtonSettings = new UI.Button(933, 556, "UI/ButtonSettings", Events.ShowHideSettings);

              Game1.EventMan.Register(Events.MouseClick, MouseClick);
              Game1.EventMan.Register(Events.MouseMove, MouseMove);
              Game1.EventMan.Register(Events.Teleport, Teleport);
              Game1.EventMan.Register(Events.ShowHideWiki, UIWiki.ShowHide);
              Game1.EventMan.Register(Events.ShowHideInventory, UIInventory.ShowHide);
              Game1.EventMan.Register(Events.ShowHideSettings, UISettings.ShowHide);

              // Deregister so that only this controller can direct mouse events
              ButtonInventory.DeregisterEvents();
              ButtonWiki.DeregisterEvents();
              ButtonSettings.DeregisterEvents();
              ButtonTeleport.DeregisterEvents();

              Audio.Play(Music.Title);

              DB.SaveToDisk();
        }
Esempio n. 2
0
        public Controller()
            : base()
        {
            int currentPlanet = DB.CurrentPlanet;

              Player = new Player(new Vector2(World.WORLD_WIDTH / 2, 100));
              Type = (PlanetTypes)DB.Planets[currentPlanet].PlanetType;
              Camera = new Camera();

              WhaleButton = new UI.Button(Player.Position.X, 100, "Planet/WhaleButton", Events.GoToSystemView);

              if (currentPlanet != 7)
              {
            Generators.Add(new Generator(new Vector2(0, 250)));
            Generators.Add(new Generator(new Vector2(World.WORLD_WIDTH - Generator.WIDTH, 250)));
              }
              else
              {
            AncientMachines.Add(new AncientMachine(new Vector2(0, 250)));
            AncientMachines.Add(new AncientMachine(new Vector2(
              World.WORLD_WIDTH - Generator.WIDTH, 250)));
              }

              if (Generators.Count > 0)
              {
            ActiveObjects.Add(Generators[0]);
            ActiveObjects.Add(Generators[1]);
              }

              foreach (var item in DB.Planets[currentPlanet].Hostiles)
              {
            switch ((HostilesTypes)item.Type)
            {
              case HostilesTypes.Boomba: ActiveObjects.Add(new Boomba(item.Position)); break;
              case HostilesTypes.Buffalo: ActiveObjects.Add(new Buffalo(item.Position)); break;
              case HostilesTypes.Bullfrog: ActiveObjects.Add(new Bullfrog(item.Position)); break;
              case HostilesTypes.CrushingMachine: ActiveObjects.Add(new CrushingMachine(item.Position)); break;
              case HostilesTypes.FireColumn: ActiveObjects.Add(new FireColumn(item.Position)); break;
              case HostilesTypes.FlamingBoulderSpawner: ActiveObjects.Add(new FlamingBoulder(item.Position)); break;
              case HostilesTypes.IceCloud: ActiveObjects.Add(new IceCloud(item.Position)); break;
              case HostilesTypes.IceColumn: ActiveObjects.Add(new IceColumn(item.Position)); break;
              case HostilesTypes.Icydactyl: ActiveObjects.Add(new Icydactyl(item.Position)); break;
              case HostilesTypes.Leech: ActiveObjects.Add(new Leech(item.Position)); break;
              case HostilesTypes.RobotSender: ActiveObjects.Add(new RobotSender(item.Position)); break;
              case HostilesTypes.RobotSentinel: ActiveObjects.Add(new RobotSentinel(item.Position)); break;
              case HostilesTypes.Rockguy: ActiveObjects.Add(new Rockguy(item.Position)); break;
              case HostilesTypes.SnappingPlant: ActiveObjects.Add(new SnappingPlant(item.Position)); break;
              case HostilesTypes.SpikeWall: ActiveObjects.Add(new SpikeWall(item.Position)); break;
              case HostilesTypes.StoneRobot: ActiveObjects.Add(new StoneRobot(item.Position)); break;
              case HostilesTypes.StormCloud: ActiveObjects.Add(new StormCloud(item.Position)); break;
              case HostilesTypes.Swarm: ActiveObjects.Add(new Swarm(item.Position)); break;
              case HostilesTypes.Yeti: ActiveObjects.Add(new Yeti(item.Position)); break;
            }
              }

              foreach (var item in DB.Planets[currentPlanet].Foods)
            Foods.Add(new Food(item.Position));

              foreach (var item in DB.Planets[currentPlanet].Cubes)
            Cubes.Add(new Cube(item.Position));

              foreach (var item in DB.Planets[currentPlanet].Critters)
            Critters.Add(new Critter(item.Position, item.Type));

              foreach (var item in DB.Planets[currentPlanet].Peoples)
            Persons.Add(new Person((CharacterTypes)item.Type, item.Position));

              Game1.EventMan.Register(Events.MouseMove, MouseMove);
              Game1.EventMan.Register(Events.MouseClick, MouseClick);
              Game1.EventMan.Register(Events.GoToSystemView, GoToSystemView);
              Game1.EventMan.Register(Events.PlayerHitByFeedback, PlayerHitByFeedback);
              Game1.EventMan.Register(Events.TeleportedFood, TeleportedFood);
              Game1.EventMan.Register(Events.PersonTeleported, PersonTeleported);

              WhaleButton.DeregisterEvents();

              switch (Type)
              {
            case PlanetTypes.Green:
              Audio.Play(Music.Jungle);
              break;
            case PlanetTypes.Jungle:
              Audio.Play(Music.Jungle);
              break;
            case PlanetTypes.Ice:
              Audio.Play(Music.Ice);
              break;
            case PlanetTypes.Desert:
              Audio.Play(Music.Jungle);
              break;
            case PlanetTypes.Volcano:
              Audio.Play(Music.Volcano);
              break;
            case PlanetTypes.Machine:
              Audio.Play(Music.Machine);
              break;
              }
        }