コード例 #1
10
ファイル: User.cs プロジェクト: RenaudWasTaken/SkyLands
        public User(StateManager stateMgr, API.Geo.World world)
        {
            this.mStateMgr = stateMgr;
            this.mWorld = world;
            this.mTimeSinceGUIOpen = new Timer();

            this.mCameraMan = null;
            this.IsAllowedToMoveCam = true;
            this.IsFreeCamMode = true;
            Camera cam = this.mStateMgr.Camera;
            cam.Position = new Vector3(-203, 633, -183);
            cam.Orientation = new Quaternion(0.3977548f, -0.1096644f, -0.8781486f, -0.2421133f);
            this.mCameraMan = new CameraMan(cam);
            this.mSelectedAllies = new HashSet<VanillaNonPlayer>();
            this.mRandom = new Random();

            this.mFigures = new MOIS.KeyCode[10];
            for (int i = 0; i < 9; i++)
                this.mFigures[i] = (MOIS.KeyCode)System.Enum.Parse(typeof(MOIS.KeyCode), "KC_" + (i + 1));
            this.mFigures[9] = MOIS.KeyCode.KC_0;

            this.mWireCube = this.mStateMgr.SceneMgr.RootSceneNode.CreateChildSceneNode();
            this.mWireCube.AttachObject(StaticRectangle.CreateRectangle(this.mStateMgr.SceneMgr, Vector3.UNIT_SCALE * Cst.CUBE_SIDE));
            this.mWireCube.SetVisible(false);

            this.Inventory = new Inventory(10, 4, new int[] { 3, 0, 1, 2 }, true);
        }
コード例 #2
0
ファイル: User.cs プロジェクト: huangtao36/SkyLands
        public User(StateManager stateMgr, API.Geo.World world)
        {
            this.mStateMgr         = stateMgr;
            this.mWorld            = world;
            this.mTimeSinceGUIOpen = new Timer();

            this.mCameraMan         = null;
            this.IsAllowedToMoveCam = true;
            this.IsFreeCamMode      = true;
            Camera cam = this.mStateMgr.Camera;

            cam.Position         = new Vector3(-203, 633, -183);
            cam.Orientation      = new Quaternion(0.3977548f, -0.1096644f, -0.8781486f, -0.2421133f);
            this.mCameraMan      = new CameraMan(cam);
            this.mSelectedAllies = new HashSet <VanillaNonPlayer>();
            this.mRandom         = new Random();

            this.mFigures = new MOIS.KeyCode[10];
            for (int i = 0; i < 9; i++)
            {
                this.mFigures[i] = (MOIS.KeyCode)System.Enum.Parse(typeof(MOIS.KeyCode), "KC_" + (i + 1));
            }
            this.mFigures[9] = MOIS.KeyCode.KC_0;

            this.mWireCube = this.mStateMgr.SceneMgr.RootSceneNode.CreateChildSceneNode();
            this.mWireCube.AttachObject(StaticRectangle.CreateRectangle(this.mStateMgr.SceneMgr, Vector3.UNIT_SCALE * Cst.CUBE_SIDE));
            this.mWireCube.SetVisible(false);

            this.Inventory = new Inventory(10, 4, new int[] { 3, 0, 1, 2 }, true);
        }
コード例 #3
0
        public void PrepareGameInstance()
        {
            // physics system
            InitializePhysics();

            // various other things
            frameTimer = new Mogre.Timer();

            serverShipMgr = new ServerShipManager(world, eventMgr, netServer);
            mode          = new GameModeFactory(eventMgr, serverShipMgr).CreateMode(netServer.GameMode);
        }
コード例 #4
0
        public void PrepareGameInstance()
        {
            // physics system
            InitializePhysics();

            // various other things
            frameTimer = new Mogre.Timer();

            serverShipMgr = new ServerShipManager(world, eventMgr, netServer);
            mode = new GameModeFactory(eventMgr, serverShipMgr).CreateMode(netServer.GameMode);
        }
コード例 #5
0
        public void UpdateLoop(object frameTotalTime)
        {
            int frameTime = (int)frameTotalTime;
            // 20 ms -> 50 fps
            Timer timer = new Timer();

            timer.Reset();
            uint start, end;

            start = timer.Milliseconds;
            float timeSinceLastFrame;

            while (updater.IsAlive)
            {
                Monitor.Enter(HydraxManager.Singleton);
                try
                {
                    if (stopUpdater)
                    {
                        return;
                    }
                }
                finally
                {
                    Monitor.Exit(HydraxManager.Singleton);
                }



                int sleepTime = 50;
                if (hydrax != null && hydrax.IsCreated)
                {
                    timeSinceLastFrame = (timer.Milliseconds - start) / 1000.0f; // w sekundach
                    start = timer.Milliseconds;

                    Monitor.Enter(HydraxManager.Singleton);
                    hydrax.Update(timeSinceLastFrame);
                    Monitor.Exit(HydraxManager.Singleton);


                    end = timer.Milliseconds;

                    int duration = (int)(end - start);

                    sleepTime = frameTime - duration;
                    if (sleepTime < 0)
                    {
                        sleepTime = 1;
                    }
                }
                Thread.Sleep(sleepTime);
            }
        }
コード例 #6
0
ファイル: TestEngine_Init.cs プロジェクト: andyhebear/ymfas
        public void PrepareGameInstance()
        {
            // create the root object with paths to various configuraion files
            root = new Root();

            // call the various rendering functions, essentially in
            // the order they are defined
            DefineResources();
            if (!SetupRenderSystem(RenderType.Direct3D9, 1024, 768, false))
            {
                //if (!SetupRenderSystem())
                throw new Exception();
            }

            CreateWindow("YMFAS");
            InitializeResourceGroups();

            // Ogre allows callbacks for lots of different events.
            // For instance, frame listeners can be called at the start
            // or end of the rendering loop.
            root.FrameEnded += new FrameListener.FrameEndedHandler(OnFrameEnd);

            // initialize the input system
            IntPtr hwnd;

            root.AutoCreatedWindow.GetCustomAttribute("Window", out hwnd);
            input    = new InputSystem(hwnd);
            inputMgr = new UserInputManager(input, eventMgr, (byte)PlayerId);

            // physics system
            InitializePhysics();

            // various other things
            frameTimer = new Mogre.Timer();

            // initalize the scene
            InitializeScene();

            //initialize chat manager
            chatMgr = new ChatManager(netClient.GameMode, netClient.PlayerId);
            TextRenderer.AddTextBox("frameCtr", "FPS: 0", 900, 700, 100, 50, ColourValue.Green, ColourValue.White);
        }
コード例 #7
0
ファイル: AdManager.cs プロジェクト: wof2/Wings-Of-Fury-2
        public AdStatus GatherAsyncResult(int id, int downloadMsTimeout, out Ad outAd)
        {
            outAd = null;
            if (EngineConfig.IsEnhancedVersion || EngineConfig.AdManagerDisabled)
            {
                return(AdStatus.ADS_DISABLED);
            }


            if (downloadingAds.ContainsKey(id))
            {
                // jeszcze nie skonczono

                Timer timer = new Timer();
                timer.Reset();
                uint start, end;
                start = timer.Milliseconds;

                for (; downloadingAds[id];)
                {
                    // System.Console.Write(".");
                    Work(null);
                    System.Threading.Thread.Sleep(100);
                    end = timer.Milliseconds;
                    if (end - start > downloadMsTimeout)
                    {
                        return(AdStatus.TIMEOUT);
                    }
                }
            }
            else
            {
                return(AdStatus.DOWNLOAD_FAILED);
            }
            // przypisz dopiero co sciagnieta reklame
            outAd = ads.Find(delegate(Ad ad)
            {
                return(ad.id.Equals(id));
            });
            return(AdStatus.OK);
        }
コード例 #8
0
ファイル: AdManager.cs プロジェクト: wof2/Wings-Of-Fury-2
        /// <summary>
        ///
        /// </summary>
        /// <param name="zone"></param>
        /// <param name="downloadMsTimeout"></param>
        /// <param name="allowedSizes">Jesli null to nie ma ograniczenia wielkosci</param>
        /// <param name="adDownloadedCallback"></param>
        /// <returns></returns>
        public AdStatus GetAd(string zone, int downloadMsTimeout, float ratio, AdManaged.AdDownloaded adDownloadedCallback, out Ad outAd)
        {
            outAd = null;
            if (EngineConfig.IsEnhancedVersion || EngineConfig.AdManagerDisabled)
            {
                return(AdStatus.ADS_DISABLED);
            }

            int id1 = 0;

            try
            {
                id1 = adAction.Get_Ad_For_Zone(zone, ratio);
                //  Console.WriteLine(id1);
            }
            catch (Exception ex)
            {
                return(AdStatus.DOWNLOAD_FAILED);
            }



            Timer timer = new Timer();

            timer.Reset();
            uint start, end;

            start = timer.Milliseconds;


            if (id1 != 0)
            {
                // jesli są reklamy
                downloadingAds[id1] = true;

                try
                {
                    if (!adAction.Download_Ad(id1, adDownloadedCallback))
                    {
                        return(AdStatus.DOWNLOAD_FAILED);
                    }
                }
                catch (Exception ex)
                {
                    return(AdStatus.DOWNLOAD_FAILED);
                }


                //  System.Console.Write("Downloading " + id1);
                for (; downloadingAds[id1];)
                {
                    // System.Console.Write(".");
                    Work(null);
                    System.Threading.Thread.Sleep(100);
                    end = timer.Milliseconds;
                    if (end - start > downloadMsTimeout)
                    {
                        return(AdStatus.TIMEOUT);
                    }
                }


                // przypisz dopiero co sciagnieta reklame
                outAd = ads.Find(delegate(Ad ad)
                {
                    return(ad.id.Equals(id1));
                });


                return(AdStatus.OK);
            }
            return(AdStatus.NO_ADS);
        }
コード例 #9
0
ファイル: Engine.cs プロジェクト: ext0/Flex
        public static void Initialize(SceneViewModel view)
        {
            _sceneNodeStore = new SceneNodeStore();
            _host           = new System.Windows.Forms.Integration.WindowsFormsHost();


            _panel          = new Panel();
            _panel.Name     = "MogrePanel";
            _panel.Location = new System.Drawing.Point(0, 0);
            _panel.Size     = new System.Drawing.Size((int)view.View.RenderWindow.Width, (int)view.View.RenderWindow.Height);
            //_panel.Resize += _panel_Resize;

            _keyboardHandler = new KeyboardHandler(_host, _panel);
            _mouseHandler    = new MouseHandler(_host, _panel);

            _host.Child = _panel;

            view.View.RenderWindow.Children.Add(_host);

            FlexUtility.SpawnThread(() =>
            {
                RunOnUIThread(() =>
                {
                    _renderer = new MogreRenderer(_panel.Handle.ToString(), (uint)_panel.Width, (uint)_panel.Height);

                    _renderer.CreateScene();

                    while (_preInitializationActions.Count != 0)
                    {
                        _preInitializationActions.Dequeue().Invoke();
                    }

                    _mouseHandler.Initialize();
                    _keyboardHandler.Initialize();

                    _initialized = true;

                    FlexUtility.SpawnThread(() =>
                    {
                        _renderThread          = Thread.CurrentThread;
                        Mogre.Timer timer      = new Mogre.Timer();
                        int attemptedFrameRate = 60;
                        bool physicsRender     = true;

                        while (true)
                        {
                            while (_renderDispatcherActionQueue.Count != 0)
                            {
                                System.Action action;
                                lock (_renderDispatcherActionQueue)
                                {
                                    action = _renderDispatcherActionQueue.Dequeue();
                                }
                                if (action != null)
                                {
                                    action.Invoke();
                                }
                            }
                            lock (_renderNextDispatcherActionQueue)
                            {
                                lock (_renderDispatcherActionQueue)
                                {
                                    while (_renderNextDispatcherActionQueue.Count != 0)
                                    {
                                        _renderDispatcherActionQueue.Enqueue(_renderNextDispatcherActionQueue.Dequeue());
                                    }
                                }
                            }
                            uint elapsed = timer.Milliseconds;
                            timer.Reset();

                            int wait = (int)((1000 / attemptedFrameRate) - elapsed);

                            if (wait > 0)
                            {
                                Thread.Sleep(wait);
                            }

                            _keyboardHandler.KeyboardTick();
                            if (physicsRender)
                            {
                                PhysicsEngine.Step();
                            }
                            physicsRender = !physicsRender;
                            Renderer.Loop();
                        }
                    });
                });
            });
        }
コード例 #10
0
ファイル: TestEngine_Init.cs プロジェクト: andyhebear/ymfas
        public void PrepareGameInstance()
        {
            // create the root object with paths to various configuraion files
            root = new Root();

            // call the various rendering functions, essentially in
            // the order they are defined
            DefineResources();
            if (!SetupRenderSystem(RenderType.Direct3D9, 1024, 768, false))
                //if (!SetupRenderSystem())
                throw new Exception();

            CreateWindow("YMFAS");
            InitializeResourceGroups();

            // Ogre allows callbacks for lots of different events.
            // For instance, frame listeners can be called at the start
            // or end of the rendering loop.
            root.FrameEnded += new FrameListener.FrameEndedHandler(OnFrameEnd);

            // initialize the input system
            IntPtr hwnd;
            root.AutoCreatedWindow.GetCustomAttribute("Window", out hwnd);
            input = new InputSystem(hwnd);
            inputMgr = new UserInputManager(input, eventMgr, (byte)PlayerId);

            // physics system
            InitializePhysics();

            // various other things
            frameTimer = new Mogre.Timer();

            // initalize the scene
            InitializeScene();

            //initialize chat manager
            chatMgr = new ChatManager(netClient.GameMode, netClient.PlayerId);
            TextRenderer.AddTextBox("frameCtr","FPS: 0",900,700,100,50, ColourValue.Green, ColourValue.White);
        }