Esempio n. 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();
        }
Esempio n. 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();
        }
Esempio n. 3
0
 void startAllTimers()
 {
     fastT.Start();
     slowT.Start();
 }
Esempio n. 4
0
 void startAllWorldTimers()
 {
     slowT.Start();
     fastT.Start();
     motionT.Start();
 }