Пример #1
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            _graphicsDevice.Clear(Color.White);

            _spriteBatch.Begin();

            foreach (var sprite in sprites)
            {
                sprite.Draw(_spriteBatch);
            }
            if (!Pause)
            {
                foreach (var component in _components)
                {
                    component.Draw(gameTime, _spriteBatch);
                }
            }
            else if (Pause)
            {
                foreach (var component in _componentsPause)
                {
                    component.Draw(gameTime, _spriteBatch);
                }
                screenFont.Draw(_spriteBatch);
            }

            score.Draw(_spriteBatch);
            if (ball.speed < 4 && score.playerScore == 0 && score.AIscore == 0)
            {
                screenFont.Draw(_spriteBatch); //drawn for the first 5 seconds
            }

            _spriteBatch.End();
        }
Пример #2
0
        internal void Render()
        {
            mPost.SetTargets(mGD, "SceneDepthMatNorm", "SceneDepth");

            mPost.ClearTarget(mGD, "SceneDepthMatNorm", Color.White);
            mPost.ClearDepth(mGD, "SceneDepth");

            mZoneDraw.DrawDMN(mGD, mZone.IsMaterialVisibleFromPos,
                              mZone.GetModelTransform, RenderExternalDMN);

            mPost.SetTargets(mGD, "SceneColor", "SceneDepth");

            mPost.ClearTarget(mGD, "SceneColor", Color.CornflowerBlue);
            mPost.ClearDepth(mGD, "SceneDepth");

            if (mDynLights != null)
            {
                mDynLights.SetParameter();
            }

            mShadKeeper.BatchShadowRender(mGD, mStaticMats);

            mZoneDraw.Draw(mGD, mShadowHelper.GetShadowCount(),
                           mZone.IsMaterialVisibleFromPos,
                           mZone.GetModelTransform,
                           RenderExternal,
                           mShadowHelper.DrawShadows,
                           SetUpAlphaRenderTargets);

            mPost.SetTargets(mGD, "Outline", "null");
            mPost.SetParameter("mNormalTex", "SceneDepthMatNorm");
            mPost.DrawStage(mGD, "Outline");

            mPost.SetTargets(mGD, "Bloom1", "null");
            mPost.SetParameter("mBlurTargetTex", "SceneColor");
            mPost.DrawStage(mGD, "BloomExtract");

            mPost.SetTargets(mGD, "Bloom2", "null");
            mPost.SetParameter("mBlurTargetTex", "Bloom1");
            mPost.DrawStage(mGD, "GaussianBlurX");

            mPost.SetTargets(mGD, "Bloom1", "null");
            mPost.SetParameter("mBlurTargetTex", "Bloom2");
            mPost.DrawStage(mGD, "GaussianBlurY");

            mPost.SetTargets(mGD, "Bleach", "null");
            mPost.SetParameter("mBlurTargetTex", "Bloom1");
            mPost.SetParameter("mColorTex", "SceneColor");
            mPost.DrawStage(mGD, "BloomCombine");

            mPost.SetTargets(mGD, "BackColor", "BackDepth");
            mPost.SetParameter("mBlurTargetTex", "Outline");
            mPost.SetParameter("mColorTex", "Bleach");
            mPost.DrawStage(mGD, "Modulate");

            mST.Draw(mGD.DC, Matrix.Identity, mTextProj);
        }
Пример #3
0
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch.Draw(_image, _imageRectangle, Color.White);

            var stringBuilder = new StringBuilder();
            var position      = 1;

            foreach (var highScore in _highScores)
            {
                stringBuilder.AppendLine(position + " " + highScore.Name + " " + highScore.Date + " " + highScore.Score);
                position++;
            }
            _highScoreTableText.Draw(SpriteBatch, stringBuilder.ToString());

            _pressSpaceToContinue.Draw(SpriteBatch, "GO TO MAIN MENU, PRESS \"F1\"");

            if (!IshighScore)
            {
                _gameOverText.Draw(SpriteBatch, "GAME OVER");

                if (!string.IsNullOrEmpty(_result))
                {
                    _resultText.Draw(SpriteBatch, _result);
                }
            }

            base.Draw(gameTime);
        }
Пример #4
0
        internal void Render(DeviceContext dc)
        {
            foreach (Character c in mCharacters)
            {
                c.Draw(dc, mCharMats);
            }

            foreach (StaticMesh sm in mMeshes)
            {
                sm.Draw(dc, mStaticMats);
            }

            for (int i = 0; i < mCharacters.Count; i++)
            {
                foreach (KeyValuePair <int, Matrix> bone in mCBones[i])
                {
                    Matrix boneTrans = bone.Value;

                    if (bone.Key == mCBone[i])
                    {
                        mCPrims.DrawBox(dc, bone.Key, boneTrans * mCharacters[i].GetTransform(), mHitColor);
                    }
                    else
                    {
                        mCPrims.DrawBox(dc, bone.Key, boneTrans * mCharacters[i].GetTransform(), Vector4.One * 0.5f);
                    }
                }
            }

            int idx = 10000;

            for (int i = 0; i < mMeshes.Count; i++)
            {
                StaticMesh sm = mMeshes[i];

                Matrix mat = sm.GetTransform();

                Dictionary <Mesh, BoundingBox> bnd = mMeshBounds[i];

                foreach (KeyValuePair <Mesh, BoundingBox> b in bnd)
                {
                    if (b.Key == mPartHit && mMeshHit == sm)
                    {
                        mCPrims.DrawBox(dc, idx++, b.Key.GetTransform() * mat, mHitColor);
                    }
                    else
                    {
                        mCPrims.DrawBox(dc, idx++, b.Key.GetTransform() * mat, Vector4.One * 0.5f);
                    }
                }
            }

            mCPrims.DrawAxis(dc);

            mSUI.Draw(dc, Matrix.Identity, mTextProj);
            mST.Draw(dc, Matrix.Identity, mTextProj);
        }
Пример #5
0
        internal void Render()
        {
            mZoneDraw.Draw(mGD, 0,
                           mZone.IsMaterialVisibleFromPos,
                           mZone.GetModelTransform,
                           RenderExternal,
                           DrawShadows, SetUpAlphaTargets);

            mPathDraw.Draw();

            mST.Draw(mGD.DC, Matrix.Identity, mTextProj);
        }
Пример #6
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            _graphicsDevice.Clear(Color.Green);

            _spriteBatch.Begin();

            _spriteBatch.Draw(_content.Load <Texture2D>("background"),
                              new Rectangle(0, 0, Game1.screenWidth, Game1.screenHeight),
                              new Rectangle(0, 0, 2020, 980),
                              Color.White);

            foreach (var sprite in sprites)
            {
                sprite.Draw(_spriteBatch);
            }
            if (!Pause)
            {
                foreach (var component in _components)
                {
                    component.Draw(gameTime, _spriteBatch);
                }
            }
            else if (Pause)
            {
                foreach (var component in _componentsPause)
                {
                    component.Draw(gameTime, _spriteBatch);
                }
                screenFont.Draw(_spriteBatch);
            }

            score.Draw(_spriteBatch);
            if (ball.speed < 7 && score.playerScore == 0 && score.AIscore == 0)
            {
                screenFont.Draw(_spriteBatch); //drawn for the first 5 seconds
            }

            _spriteBatch.End();
        }
Пример #7
0
        internal void Render()
        {
            mTerMats.ApplyMaterialPass("Sky", mGD.DC, 0);
            mSkyCube.Draw(mGD.DC);

            if (mTerrain != null)
            {
                mTerrain.Draw(mGD, mTerMats, mFrust);
            }

            mDrawRays.Draw(mOtherCam);

            mST.Draw(mGD.DC, Matrix.Identity, mTextProj);
        }
Пример #8
0
        internal void Render(GraphicsDevice gd)
        {
            if (mDBDraw != null && mbDrawWorld)
            {
                mDBDraw.Draw(gd);
            }
            if (mDS != null)
            {
                mDS.Draw(gd);
            }

            mSUI.Draw(mGD.DC, Matrix.Identity, mTextProj);
            mST.Draw(mGD.DC, Matrix.Identity, mTextProj);
        }
Пример #9
0
        internal void Render()
        {
            mTerMats.ApplyMaterialPass("Sky", mGD.DC, 0);
            mSkyCube.Draw(mGD.DC);

            if (mTerrain != null)
            {
                mTerrain.Draw(mGD, mTerMats, mFrust);
            }

            if (mQTreeBoxes != null)
            {
                mDebugMats.ApplyMaterialPass("DebugBoxes", mGD.DC, 0);
                mQTreeBoxes.Draw(mGD.DC);
            }

            mST.Draw(mGD.DC, Matrix.Identity, mTextProj);
        }
        private async Task goToLocation(Vector3 currentPosition, Vector3 newPos, string transitType)
        {
            countdownTimer.Draw();

            Log.ToChat("[Transit]", $"Currently waiting for transport this will take a little bit", ConstantColours.Blue);
            var currentSecond = 0;
            var playerPed     = Cache.PlayerPed;

            do
            {
                countdownTimer.Caption = $"{waitTime - currentSecond}";
                if (playerPed.Position.DistanceToSquared(currentPosition) > Math.Pow(3, 2) || playerPed.IsInVehicle())
                {
                    Log.ToChat("[Transit]", $"You moved to far away from the {transitType} station", ConstantColours.Blue);
                    countdownTimer.StopDraw();
                    return;
                }
                await BaseScript.Delay(1000);

                currentSecond++;
            } while (currentSecond <= waitTime);

            if (playerPed.Position.DistanceToSquared(currentPosition) < Math.Pow(3, 2))
            {
                await playerPed.TeleportToLocation(newPos, true);

                var cost = API.GetConvarInt($"mg_{transitType}TransitCost", transitType == "bus" ? 25 : 50);
                Client.TriggerServerEvent("Payment.PayForItem", cost, $"{transitType} station");
                Log.ToChat("[Bank]", $"You paid ${cost} for this {transitType} ride", ConstantColours.Bank);
            }
            else
            {
                Log.ToChat("[Transit]", $"You moved to far away from the {transitType} station", ConstantColours.Blue);
            }

            countdownTimer.StopDraw();
        }
Пример #11
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            GraphicsDevice gd = new GraphicsDevice("Audio Test Program",
                                                   FeatureLevel.Level_9_3, 0.1f, 3000f);

            //save renderform position
            gd.RendForm.DataBindings.Add(new System.Windows.Forms.Binding("Location",
                                                                          Settings.Default,
                                                                          "MainWindowPos", true,
                                                                          System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));

            gd.RendForm.Location = Settings.Default.MainWindowPos;

            //used to have a hard coded path here for #debug
            //but now can just use launch.json to provide it
            string gameRootDir = ".";

            Audio aud = new Audio();

            aud.LoadAllSounds(gameRootDir + "/Audio/SoundFX");
            aud.LoadAllSounds(gameRootDir + "/Audio/Music");

            List <string> sounds = aud.GetSoundList();

            int curSound = 0;

            Emitter emitter = Audio.MakeEmitter(Vector3.Zero);

            SharedForms.ShaderCompileHelper.mTitle = "Compiling Shaders...";

            StuffKeeper sk = new StuffKeeper();

            sk.eCompileNeeded += SharedForms.ShaderCompileHelper.CompileNeededHandler;
            sk.eCompileDone   += SharedForms.ShaderCompileHelper.CompileDoneHandler;

            sk.Init(gd, gameRootDir);

            PlayerSteering pSteering    = SetUpSteering();
            Input          inp          = SetUpInput();
            Random         rand         = new Random();
            CommonPrims    comPrims     = new CommonPrims(gd, sk);
            bool           bMouseLookOn = false;

            EventHandler actHandler = new EventHandler(
                delegate(object s, EventArgs ea)
                { inp.ClearInputs(); });

            EventHandler <EventArgs> deActHandler = new EventHandler <EventArgs>(
                delegate(object s, EventArgs ea)
            {
                gd.SetCapture(false);
                bMouseLookOn = false;
            });

            gd.RendForm.Activated      += actHandler;
            gd.RendForm.AppDeactivated += deActHandler;

            int resx = gd.RendForm.ClientRectangle.Width;
            int resy = gd.RendForm.ClientRectangle.Height;

            MatLib fontMats = new MatLib(gd, sk);

            fontMats.CreateMaterial("Text");
            fontMats.SetMaterialEffect("Text", "2D.fx");
            fontMats.SetMaterialTechnique("Text", "Text");

            List <string> fonts = sk.GetFontList();

            ScreenText st = new ScreenText(gd.GD, fontMats, fonts[0], 1000);

            Matrix textProj = Matrix.OrthoOffCenterLH(0, resx, resy, 0, 0.1f, 5f);

            Vector4 color = Vector4.UnitX + (Vector4.UnitW * 0.95f);

            //string indicators for various statusy things
            st.AddString(fonts[0], "P - Play2D   L - Play at Emitter   [] - Prev/Next Sound  E - Set Emitter Pos to Camera Pos",
                         "Instructions", color, Vector2.UnitX * 20f + Vector2.UnitY * 520f, Vector2.One);
            st.AddString(fonts[0], "Stuffs", "CurrentSound",
                         color, Vector2.UnitX * 20f + Vector2.UnitY * 540f, Vector2.One);
            st.AddString(fonts[0], "Stuffs", "EmitterPosition",
                         color, Vector2.UnitX * 20f + Vector2.UnitY * 560f, Vector2.One);
            st.AddString(fonts[0], "Stuffs", "PosStatus",
                         color, Vector2.UnitX * 20f + Vector2.UnitY * 580f, Vector2.One);

            Vector3     pos      = Vector3.One * 5f;
            Vector3     lightDir = -Vector3.UnitY;
            UpdateTimer time     = new UpdateTimer(false, false);

            time.SetFixedTimeStepSeconds(1f / 60f);             //60fps update rate
            time.SetMaxDeltaSeconds(MaxTimeDelta);

            List <Input.InputAction> acts = new List <Input.InputAction>();

            RenderLoop.Run(gd.RendForm, () =>
            {
                if (!gd.RendForm.Focused)
                {
                    Thread.Sleep(33);
                }

                gd.CheckResize();

                if (bMouseLookOn && gd.RendForm.Focused)
                {
                    gd.ResetCursorPos();
                }

                time.Stamp();
                while (time.GetUpdateDeltaSeconds() > 0f)
                {
                    acts = UpdateInput(inp, gd,
                                       time.GetUpdateDeltaSeconds(), ref bMouseLookOn);
                    if (!gd.RendForm.Focused)
                    {
                        acts.Clear();
                        bMouseLookOn = false;
                        gd.SetCapture(false);
                        inp.UnMapAxisAction(Input.MoveAxis.MouseYAxis);
                        inp.UnMapAxisAction(Input.MoveAxis.MouseXAxis);
                    }
                    Vector3 moveDelta = pSteering.Update(pos, gd.GCam.Forward,
                                                         gd.GCam.Left, gd.GCam.Up, acts);

                    moveDelta *= 200f;

                    pos -= moveDelta;

                    gd.GCam.Update(pos, pSteering.Pitch, pSteering.Yaw, pSteering.Roll);

                    CheckInputKeys(acts, aud, ref curSound, sounds, emitter, gd.GCam.Position);

                    //update status text
                    st.ModifyStringText(fonts[0], "Current Sound: " + sounds[curSound], "CurrentSound");
                    st.ModifyStringText(fonts[0], "Emitter Pos: " + emitter.Position.X + ", " + emitter.Position.Y + ", " + emitter.Position.Z, "EmitterPosition");
                    st.ModifyStringText(fonts[0], "Cam Pos: " + gd.GCam.Position +
                                        ", Sounds Playing: " + aud.GetNumInstances(), "PosStatus");
                    time.UpdateDone();
                }


                st.Update(gd.DC);

                comPrims.Update(gd.GCam, lightDir);

                aud.Update(gd.GCam);

                //Clear views
                gd.ClearViews();

                comPrims.DrawAxis(gd.DC);

                st.Draw(gd.DC, Matrix.Identity, textProj);

                gd.Present();

                acts.Clear();
            }, true);                   //true here is slow but needed for winforms events

            Settings.Default.Save();

            gd.RendForm.Activated      -= actHandler;
            gd.RendForm.AppDeactivated -= deActHandler;

            //Release all resources
            st.FreeAll();
            fontMats.FreeAll();
            comPrims.FreeAll();
            inp.FreeAll();

            sk.eCompileDone   -= SharedForms.ShaderCompileHelper.CompileDoneHandler;
            sk.eCompileNeeded -= SharedForms.ShaderCompileHelper.CompileNeededHandler;
            sk.FreeAll();

            aud.FreeAll();
            gd.ReleaseAll();
        }