상속: MonoBehaviour
예제 #1
0
        /// <summary>
        /// Update
        /// </summary>
        protected override void Update(GameTime gameTime)
        {
            // Update game engine
            base.Update(gameTime);

            var controller = XboxController.RetrieveController(0);

            controller.UpdateState();

            if (controller.IsBackPressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            var elapsedGameTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            var input = new PlayerInput();

            HandleInput(ref input, controller);

            game.Input(input);
            game.Update(elapsedGameTime);
            frame = game.getPosition();

            CameraPos = new Vector3(frame.Position.X, -frame.Position.Y, CameraPos.Z);

            ViewMatrix = Matrix.CreateLookAt(CameraPos, new Vector3(CameraPos.X, CameraPos.Y, 0), Vector3.Up);

            Window.Title = "GTA2.NET - " + WindowTitle + Fps.ToString(CultureInfo.InvariantCulture) + " fps X: " + CameraPos.X.ToString() + "Y: " + CameraPos.Y.ToString() + "Z: " + CameraPos.Z;
        }
예제 #2
0
        protected override void OnRender()
        {
            Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.LightGray, 1.0f, 0);
            Device.BeginScene();

            Device.SetTransform(TransformState.View, Freelook.View);

            foreach (RigidBody body in PhysicsContext.World.CollisionObjectArray)
            {
                Device.SetTransform(TransformState.World, body.WorldTransform);
                RenderWithMaterial(body);

                if (Physics.HasDistanceResult)
                {
                    Device.Material = ActiveMaterial;
                    Device.SetTransform(TransformState.World, Matrix.Identity);
                    PositionColored[] vertices = new PositionColored[2];
                    vertices[0] = new PositionColored(Physics.distanceFrom, -1);
                    vertices[1] = new PositionColored(Physics.distanceTo, -1);
                    Device.DrawUserPrimitives(PrimitiveType.LineList, 1, vertices);
                }
            }

            DebugDrawWorld();

            Fps.Text = string.Format(
                "Move using mouse and WASD+shift\n" +
                "F3 - Toggle debug\n" +
                "F11 - Toggle fullscreen\n" +
                "Distance: {0}", Physics.distance.ToString("0.00"));
            Fps.OnRender(FramesPerSecond);

            Device.EndScene();
            Device.Present();
        }
예제 #3
0
파일: SoftDemo.cs 프로젝트: diqost/bullet
        protected override void OnRender()
        {
            Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.LightGray, 1.0f, 0);
            Device.BeginScene();

            Device.SetTransform(TransformState.View, Freelook.View);

            foreach (CollisionObject colObj in PhysicsContext.World.CollisionObjectArray)
            {
                if (colObj.CollisionShape.ShapeType == BroadphaseNativeType.SoftBodyShape)
                {
                    if (IsDebugDrawEnabled)
                    {
                        continue;
                    }

                    Device.Material = softBodyMaterial;
                    Device.SetTransform(TransformState.World, Matrix.Identity);
                    MeshFactory.RenderSoftBody(colObj as SoftBody);
                }
                else
                {
                    RigidBody body = colObj as RigidBody;
                    Device.SetTransform(TransformState.World, body.MotionState.WorldTransform);
                    RenderWithMaterial(body);
                }
            }

            DebugDrawWorld();

            Fps.OnRender(FramesPerSecond);

            Device.EndScene();
            Device.Present();
        }
예제 #4
0
        protected override void OnRender(DrawingContext context)
        {
            base.OnRender(context);
            context.DrawLine(baselinePen, angleLeftLeft, angleLeftRight);
            //context.DrawText(warningFormattedText, new Point(ActualWidth/2, ActualHeight/2));
            context.DrawLine(baselinePen, angleRightLeft, angleRightRight);
            context.DrawLine(baselinePen, directionLineLeftBoundTop, directionLineLeftBoundBottom);
            context.DrawLine(baselinePen, directionLineRightBoundTop, directionLineRightBoundBottom);
            context.DrawLine(baselinePen, directionTop, directionBottom);

            RenderGauge(context, Humidity.ToString("0.00"), 2, humidityFormattedText);
            RenderGauge(context, Temperature.ToString("0.00"), 6, temperatureFormattedText);
            RenderGauge(context, Fps.ToString("0.0"), 18, fpsFormattedText);
            RenderGauge(context, Voltage.ToString("0.00"), 4, voltageFormattedText);
            RenderGauge(context, Current.ToString("0.00"), 16, currentFormattedText);
            RenderGauge(context, Thrust.ToString("0"), 10, thrustFormattedText);
            RenderGauge(context, Salinity.ToString("0.00"), 8, salinityFormattedText);
            RenderGauge(context, Depth.ToString("0.00"), 12, depthFormattedText);
            RenderGauge(context, ExtTemp.ToString("0.00"), 14, extTempFormattedText);

            RenderDepthGauge(context);
            RenderBatteryBar(context);

            if (ScreenshotAck == true)
            {
                RenderCTDValues(context, "Captured!", 2, screenshotFormattedText);
            }
            RenderCompass(context);
            RenderFalseHorizon(context);
            //RenderMap(context);
            //RenderLocation(context);
        }
예제 #5
0
        //-----------------------------------------------------------------------------------------------
        //
        //-----------------------------------------------------------------------------------------------
        protected override void Draw(GameTime gameTime)
        {
            UpdateFrame();
            _visualTree.AdvanceAnimations(gameTime);
            base.Draw(gameTime);

            //Debug.WriteLine("AAA---------------------- BEGIN ------------------------");
            //Debug.WriteLine("AAA_spriteBatch.Begin();");
            _spriteBatch.Begin();
            GraphicsDevice.Clear(GlobalBackgroundColor);
            BeginClipping(DrawOffset, ScreenSize);
            _visualTree.Prepare(_widgetSpace.StyleLibrary);
            _visualTree.RenderMe(gameTime);

            if (ShowFps)
            {
                DrawText("Fps: " + Fps.ToString(".0"), null, .05f, DrawOffset + new Vector2(0.01f, 0.01f), Color.Black);
            }

            EndClipping(0, Vector2.Zero, new Vector2(1), false, false);
            if (_drawBuffers.Count > 0)
            {
                throw new ApplicationException("There was an unmatch BeginClipping call.");
            }

            //Debug.WriteLine("AAA_spriteBatch.End();");
            _spriteBatch.End();
            //Debug.WriteLine("AAA---------------------- END ------------------------");
        }
예제 #6
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CpuLoad != 0)
            {
                hash ^= CpuLoad.GetHashCode();
            }
            if (GpuLoad != 0)
            {
                hash ^= GpuLoad.GetHashCode();
            }
            if (Fps != 0)
            {
                hash ^= Fps.GetHashCode();
            }
            if (CpuTemp != 0)
            {
                hash ^= CpuTemp.GetHashCode();
            }
            if (GpuTemp != 0)
            {
                hash ^= GpuTemp.GetHashCode();
            }
            if (CpuFreq != 0)
            {
                hash ^= CpuFreq.GetHashCode();
            }
            if (GpuFreq != 0)
            {
                hash ^= GpuFreq.GetHashCode();
            }
            return(hash);
        }
예제 #7
0
        public static Fps operator +(Fps obj1, Fps obj2)
        {
            Fps temp = new Fps();

            temp.feet = obj1.feet + obj2.feet;
            temp.inch = obj1.inch + obj2.inch;
            return(temp);
        }
예제 #8
0
        /// <summary>
        /// The constructor of the class that initializes the fields of the class.
        /// </summary>
        private StreamingServer(IEnumerable <Image> images, Fps fps)
        {
            _thread = null;
            _images = images;

            Clients = new List <Socket>();
            Delay   = (int)fps;
        }
예제 #9
0
    private void attachFps()
    {
        Fps fps = gameObject.GetComponent <Fps>();

        if (fps == null)
        {
            gameObject.AddComponent <Fps>();
        }
    }
예제 #10
0
        /// <summary>
        /// Provides an object for a window stream of a specific application.
        /// </summary>
        /// <param name="applicationName">The title of the main application window.</param>
        /// <param name="fps">FPS.</param>
        /// <param name="isDisplayCursor">Whether to display the cursor in screenshots.</param>
        /// <returns>The object of the StreamingServer class.</returns>
        public static StreamingServer GetInstance(string applicationName,
                                                  Fps fps, bool isDisplayCursor)
        {
            lock (s_syncRoot)
            {
                s_serverInstance ??= new StreamingServer(applicationName, fps, isDisplayCursor);
            }

            return(s_serverInstance);
        }
예제 #11
0
 void Awake()
 {
     Assert.IsNotNull(vrMovieSkybox);
     Assert.IsNotNull(vrVideoPlayer);
     Assert.IsNotNull(informationText);
     Assert.IsNotNull(videoClipFps60);
     Assert.IsNotNull(videoClipFps30);
     currentFps = Fps.Fps30;
     vrMovieSkybox.ChangeMode(targetImageType, targetLayout);
 }
예제 #12
0
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (int)ImagePixelFormat;
         hashCode = (hashCode * 397) ^ Resolution.GetHashCode();
         hashCode = (hashCode * 397) ^ Fps.GetHashCode();
         return(hashCode);
     }
 }
예제 #13
0
        public Window1()
        {
            InitializeComponent();
            MapControl.ErrorMessageChanged += MapErrorMessageChanged;
            MapControl.FeatureInfo         += MapControlFeatureInfo;
            Fps.SetBinding(TextBlock.TextProperty, new Binding("Fps"));
            Fps.DataContext = MapControl.FpsCounter;

            OsmClick(this, null);
        }
예제 #14
0
        public override int GetHashCode()
        {
            var hashCode = -2035125405;

            hashCode = hashCode * -1521134295 + EqualityComparer <List <string> > .Default.GetHashCode(_images);

            hashCode = hashCode * -1521134295 + Fps.GetHashCode();
            hashCode = hashCode * -1521134295 + Loop.GetHashCode();
            return(hashCode);
        }
예제 #15
0
        /// <summary>
        /// Provides a server object for a screen stream.
        /// </summary>
        /// <param name="resolutions">Stream Resolution.</param>
        /// <param name="fps">FPS.</param>
        /// <param name="isDisplayCursor">Whether to display the cursor in screenshots.</param>
        /// <returns>The object of the StreamingServer class.</returns>
        public static StreamingServer GetInstance(Resolution.Resolutions resolutions,
                                                  Fps fps, bool isDisplayCursor)
        {
            lock (s_syncRoot)
            {
                s_serverInstance ??= new StreamingServer(resolutions, fps, isDisplayCursor);
            }

            return(s_serverInstance);
        }
예제 #16
0
        void NextFps()
        {
            currentFps++;

            if ((int)currentFps >= Enum.GetValues(typeof(Fps)).Length)
            {
                currentFps = (Fps)Enum.ToObject(typeof(Fps), 0);
            }

            UpdateVrMovie();
        }
예제 #17
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            grade           = new Grade(this);
            grade.DrawOrder = 1;
            Components.Add(grade);

            Fps fps = new Fps(this);

            fps.DrawOrder = 100000;
            Components.Add(fps);

            base.Initialize();
        }
예제 #18
0
파일: Game.cs 프로젝트: diqost/bullet
        protected virtual void OnResetDevice()
        {
            Fps.OnResetDevice();

            Matrix projection = Matrix.PerspectiveFovLH(FieldOfView, AspectRatio, NearPlane, FarPlane);

            Device.SetTransform(TransformState.Projection, projection);
            Device.SetTransform(TransformState.View, Freelook.View);

            Device.SetRenderState(RenderState.Ambient, Ambient);

            MeshFactory.OnResetDevice();
        }
예제 #19
0
 static int StartCheckFps(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         Fps obj = (Fps)ToLua.CheckObject <Fps>(L, 1);
         obj.StartCheckFps();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #20
0
파일: Game.cs 프로젝트: diqost/bullet
 /// <summary>
 /// Disposes of object resources.
 /// </summary>
 /// <param name="disposeManagedResources">If true, managed resources should be
 /// disposed of in addition to unmanaged resources.</param>
 protected virtual void Dispose(bool disposeManagedResources)
 {
     if (disposeManagedResources)
     {
         apiContext.Dispose();
         if (Form.IsDisposed == false)
         {
             Form.Dispose();
         }
         Fps.Dispose();
         MeshFactory.Dispose();
         PhysicsContext.Dispose();
     }
 }
예제 #21
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            //Update fps measurer
            Fps.Update(gameTime);

            GraphicsDevice.Clear(BackgroundColor);
            _spriteBatch.Begin(SpriteSortMode.Deferred, null);
            if (ScriptExecuter.IsInPlayingMovie)//Movie
            {
                ScriptExecuter.DrawVideo(_spriteBatch);
            }
            else
            {
                switch (GameState.State)
                {
                case GameState.StateType.Start:
                    break;

                case GameState.StateType.Title:
                    break;

                case GameState.StateType.Playing:
                    DrawGamePlay(gameTime);
                    if (Globals.ShowMapPos || Globals.ScriptShowMapPos)
                    {
                        DrawMapPos(_spriteBatch);
                    }
                    break;

                case GameState.StateType.EndAds:
                    DrawAds(gameTime);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                //GUI
                GuiManager.Draw(_spriteBatch);
            }

            if (IsInEditMode)
            {
                DrawGameInfo(_spriteBatch);
            }

            _spriteBatch.End();

            base.Draw(gameTime);
        }
예제 #22
0
        public override void Draw(GameTime gameTime)
        {
            if (!this.Visible || Font == null)
            {
                return;
            }

            spriteBatch.Begin();

            spriteBatch.DrawString(Font, Fps.ToString(), Vector2.Zero, Color.Blue);

            spriteBatch.End();

            base.Draw(gameTime);
        }
예제 #23
0
 static int TickToMilliSec(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         long arg0 = LuaDLL.tolua_checkint64(L, 1);
         long o    = Fps.TickToMilliSec(arg0);
         LuaDLL.tolua_pushint64(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #24
0
        /// <inheritdoc/>
        public bool Equals(RawVideoStreamFormat other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((ImagePixelFormat == other.ImagePixelFormat) && Resolution.Equals(other.Resolution) &&
                   Fps.Equals(other.Fps));
        }
예제 #25
0
    static int set_checkFps(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Fps  obj  = (Fps)o;
            bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.checkFps = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index checkFps on a nil value"));
        }
    }
예제 #26
0
        protected override void OnRender()
        {
            Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.LightGray, 1.0f, 0);
            Device.BeginScene();

            foreach (RigidBody body in PhysicsContext.World.CollisionObjectArray)
            {
                Device.SetTransform(TransformState.World, body.MotionState.WorldTransform);
                RenderWithMaterial(body);
            }

            DebugDrawWorld();
            Fps.OnRender(FramesPerSecond);

            Device.EndScene();
            Device.Present();
        }
예제 #27
0
    static int get_checkFps(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Fps  obj = (Fps)o;
            bool ret = obj.checkFps;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index checkFps on a nil value"));
        }
    }
예제 #28
0
        public void Start()
        {
            Console.WriteLine("[PikMod] Started.");
            if (self != null)
            {
                return;
            }
            self = new GameObject();
            self.AddComponent <SavedAvatarList>();
            //self.AddComponent<FlyMode>();
            // this.self.AddComponent<BoneEsp>();
            CommandHandler commandHandler = PikMod.self.AddComponent <CommandHandler>();
            PikUIMods      pikui          = PikMod.self.AddComponent <PikUIMods>();

            commandHandler.AddBase <SelectedPlayerCommands>();
            commandHandler.AddBase <GlobalCommands>();
            Fps fpss = PikMod.self.AddComponent <Fps>();

            AvatarUtils.LoadAvatars();
        }
예제 #29
0
        public void Page_Loaded(object o, EventArgs e)
        {
            // Required to initialize variables
            _splash = new Splash();
            canvas.Children.Add(_splash);
            _splash.SetValue(Canvas.ZIndexProperty, 20000);
            KeyHandler = new KeyHandler();
            KeyHandler.Attach(this);
            Focus();
            gameLoop = new GameLoop();
            gameLoop.Attach(parentCanvas);
            gameLoop.Update += gameLoop_Update;
            Fps fps = new Fps();

            canvas.Children.Add(fps);
            fps.SetValue(Canvas.ZIndexProperty, 1000);
            _mainMenu = new MainMenu();
            canvas.Children.Add(_mainMenu);
            _mainMenu.MenuItemSelected += mainMenu_MenuItemSelected;
            Page_SizeChanged(null, null);
        }
예제 #30
0
        /// <summary>
        /// Starts the streaming server.
        /// </summary>
        /// <param name="ipAddress">IP address of the server.</param>
        /// <param name="port">Server port.</param>
        /// <param name="fps">FPS stream.</param>
        private void StartStreamingServer(IPAddress ipAddress, int port, Fps fps)
        {
            if (RbFullScreen.IsChecked == true)
            {
                var  resolution      = GetResolutionFromComboBox(CbScreenResolution.Text);
                bool isDisplayCursor = ChBFullScreenShowCursor.IsChecked != null &&
                                       (bool)ChBFullScreenShowCursor.IsChecked;

                _streamingServer = StreamingServer.GetInstance(resolution, fps, isDisplayCursor);
                _streamingServer.Start(ipAddress, port);
            }
            else if (RbAppWindow.IsChecked == true)
            {
                string applicationName = CbAppWindow.Text;
                bool   isDisplayCursor = ChBAppWindowShowCursor.IsChecked != null &&
                                         (bool)ChBAppWindowShowCursor.IsChecked;

                _streamingServer = StreamingServer.GetInstance(applicationName, fps, isDisplayCursor);
                _streamingServer.Start(ipAddress, port);
            }
        }