Beispiel #1
0
        public ClientGameState(NetClient client, byte usize, byte vsize, float sideLen, Faction playerF, Faction worldF, IEnumerable <Faction> otherFactions, Vector2 basePos)
        {
            //ResourceManager.GraphicsDeviceManager.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            //ResourceManager.GraphicsDeviceManager.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            //ResourceManager.GraphicsDeviceManager.IsFullScreen = true;
            //ResourceManager.GraphicsDeviceManager.ApplyChanges();

            this.client = client;

            this.usize = usize;
            this.vsize = vsize;

            PlayerF     = playerF;
            WorldF      = worldF;
            facRegister = otherFactions.ToDictionary <Faction, byte>(fac => fac.ID);
            facRegister.Add(PlayerF.ID, playerF);
            facRegister.Add(WorldF.ID, worldF);

            if (playerF.FactionType == PlayerType.Human)
            {
                PlayerF.BuildingsUnlocked.AddRange(ResourceManager.Resources["Settings"]["StartHumanBuildings"]);
            }
            else
            {
                PlayerF.BuildingsUnlocked.AddRange(ResourceManager.Resources["Settings"]["StartWumpusBuildings"]);
            }

            cWorld = new World(usize, vsize, sideLen);

            clientT         = new GameLoopTimer(1000d / 60d);
            clientT.Update += new Action <GameTime>(clientT_Update);
            clientT.Start();
        }
Beispiel #2
0
        public override void Init()
        {
            NetPeerConfiguration config = new NetPeerConfiguration("omron");

            config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
            config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
            config.Port = 9001;

            /*config.SimulatedLoss = 0.01f;
             * config.SimulatedMinimumLatency = 0.003f;
             * config.SimulatedRandomLatency = 0.010f;*/
            server = new NetServer(config);


            world                     = new World(50, 50, 1.0f);
            world.server              = server;
            world.NotifyUpdatePushed += new UpdatePushed(world_NotifyUpdatePushed);
            world.NotifyEffectPushed += new EffectPushed(world_NotifyEffectPushed);



            motionT         = new GameLoopTimer(1000d / 60d);
            motionT.Update += new Action <GameTime>(motionT_Update);

            fastT         = new GameLoopTimer(1000d / 60d);
            fastT.Update += new Action <GameTime>(fastT_Update);

            slowT         = new GameLoopTimer(1000d / 2d);
            slowT.Update += new Action <GameTime>(slowT_Update);



            MapGenerator.renewSeed();
            MapGenerator.GeneratePerlinMap(world);


            mapBoundsXY = world.TileGrid.UVToScreen(new Point(world.TileGrid.U_length - 1, world.TileGrid.V_length - 1));
            var cent = 0.5f * mapBoundsXY;


            playerFactions = new List <Faction>();

            //setupBase(cent, playerF);
            //setupBase(cent + Vector2.One * 10f, wumpusF);


            //networking


            server.Start();

            serverT         = new GameLoopTimer(1000d / 60d);
            serverT.Update += new Action <GameTime>(serverT_Update);
            serverT.Start();

            startAllWorldTimers();
        }
Beispiel #3
0
        public override void Init()
        {
            MathHelper.ResetIDs();
            ResourceManager.BaseGame.IsMouseVisible = false;

            fastT         = new GameLoopTimer(1000d / 60d);
            fastT.Update += new Action <GameTime>(fastT_Update);

            slowT         = new GameLoopTimer(1000d / 2d);
            slowT.Update += new Action <GameTime>(slowT_Update);


            spriteBatch = new SpriteBatch(this.GraphicsDevice);


            world = new World(100, 100, ResourceManager.Resources["Settings"]["Grid Size"]);
            var cent = 0.5f * world.TileGrid.UVToScreen(new Point(world.TileGrid.U_length - 1, world.TileGrid.V_length - 1));

            playerF = new Faction(world);
            playerF.Resources.Metal   = 300;
            playerF.Resources.Crystal = 200;
            wumpusF = new Faction(world);
            wumpusF.Resources.Crystal = 30000;

            Factions = new List <Faction>();
            Factions.Add(playerF);
            Factions.Add(wumpusF);

            playerF.Register(wumpusF, FactionRelationship.Hostile);
            //playerF.BuildingsUnlocked.Add("DefenseDept_h");
            //playerF.BuildingsUnlocked.Add("DefenseDept_w");
            //playerF.BuildingsUnlocked.Add("Baraks");
            //playerF.BuildingsUnlocked.Add("Outpost");
            //playerF.BuildingsUnlocked.Add("Spawning Pit");
            //playerF.BuildingsUnlocked.Add("Slime Pit");
            //playerF.BuildingsUnlocked.Add("Killer Growth");
            //playerF.BuildingsUnlocked.Add("Baraks");
            //playerF.BuildingsUnlocked.Add("Fence");


            MapGenerator.renewSeed();
            MapGenerator.GeneratePerlinMap(world);

            setupHumanBase(cent - Vector2.UnitX * 5f, playerF);
            setupWumpusBase(cent + Vector2.UnitX * 5f, wumpusF);

            startAllTimers();

            playerController         = new GameUI(this, world, playerF);
            playerController.GodMode = true;

            playerF.SetVictory(ResourceManager.Resources["TroyRegicide"]);
            wumpusF.SetVictory(ResourceManager.Resources["Conquest"]);
        }