Example #1
0
        public void Update()
        {
            if (camera == null)
            {
                return;
            }

            if (API.IsPauseMenuActive())
            {
                return;
            }

            if (menu != null && menu.IsOpen())
            {
                menu.Update();
            }

            if (menu != null && !menu.IsOpen())
            {
                menu.Open();
            }

            if (CitizenFX.Core.Game.IsControlPressed(0, Control.CursorScrollUp))
            {
                zoom -= 0.15f;
            }

            if (CitizenFX.Core.Game.IsControlPressed(0, Control.CursorScrollDown))
            {
                zoom += 0.15f;
            }

            zoom = Math.Min(zoom, 3);
            zoom = Math.Max(zoom, 0.75f);

            float mouseX = -CitizenFX.Core.Game.GetDisabledControlNormal(0, Control.LookLeft);
            float mouseY = -CitizenFX.Core.Game.GetDisabledControlNormal(0, Control.LookDown);

            var cam = CitizenFX.Core.Game.Player.Character;

            angle -= mouseX * CitizenFX.Core.Game.LastFrameTime * 400;

            angle = Math.Min(angle, 290);
            angle = Math.Max(angle, 95);

            CameraPosition = new Vector3(cam.Position.X + zoom * (float)Math.Sin((angle / 180) * Math.PI), cam.Position.Y + zoom * (float)Math.Cos((angle / 180) * Math.PI), CameraPosition.Z);

            CameraPosition.Z -= mouseY * CitizenFX.Core.Game.LastFrameTime * 10;
            CameraPosition.Z  = Math.Min(CameraPosition.Z, 31.4f);
            CameraPosition.Z  = Math.Max(CameraPosition.Z, 29.888f);

            var lookAt = CitizenFX.Core.Game.Player.Character.Position;

            lookAt.Z = CameraPosition.Z;

            camera.Position = CameraPosition;
            camera.LookAt(lookAt);
            camera.Update();
        }
Example #2
0
        public override void Update(GameTime gameTime)
        {
            updateControls();
            cam.Update(gameTime, player.Position);
            updateDelayTimers(gameTime);
            if (!devCamOn)
            {
                modelInteraction(gameTime);
            }
            if (player.WindBlowing && !player.IsInTree && player.CurrentState == LittleFlame.Flames.NORMAL)
            {
                underWater(player.Position.Y);
            }
            levelBoundaries(player.Position.X, player.Position.Z);
            if (player.WindBlowing && !player.IsInTree && player.CurrentState == LittleFlame.Flames.NORMAL)
            {
                terrain.BurningField(player.Position, gameTime, Game, this);
            }
            this.PlaySong(gameTime);
            startPosition = player.Position;

            if (this.timeScore < 0)
            {
                this.timeScore = 0;
            }
            else if (this.timeScore > 0)
            {
                this.timeScore -= (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
#if WINDOWS
            if (GameSaveRequested == true)
            {
                GameSaveRequested = false;
                //saveProgress(saveName);
            }
#endif

#if XBOX
            if ((!Guide.IsVisible) && (GameSaveRequested == true))
            {
                GameSaveRequested = false;
                //saveProgress(saveName);
            }
#endif

            base.Update(gameTime);
        }
Example #3
0
        public override async Task Loop()
        {
            if (characterCreator.Active)
            {
                characterCreator.Update();
                return;
            }

            if (!IsCharacterSelectionActive)
            {
                return;
            }

            if (cam != null)
            {
                cam.Update();
            }

            CitizenFX.Core.Game.Player.Character.Position = pos;

            Function.Call(Hash.DRAW_SCALEFORM_MOVIE_FULLSCREEN, _instructionalButtonsScaleform.Handle, 255, 255, 255, 255, 0);

            hideAll();

            if (peds.Count <= 0)
            {
                return;
            }

            float angle  = -45;
            float radius = 3;

            foreach (var ped in peds)
            {
                ped.Key.Show();

                var offset = new Vector3(cam.Position.X + radius * (float)Math.Sin((angle / 180) * Math.PI), cam.Position.Y + radius * (float)Math.Cos((angle / 180) * Math.PI), pos.Z);
                ped.Key.Position = offset;

                var textPos = new Vector3(offset.X, offset.Y, offset.Z + 1.65f);
                Draw($"{ped.Value.FirstName} {ped.Value.LastName}", System.Drawing.Color.FromArgb(255, 255, 255, 255), textPos, 1, true, 4);

                var a       = new Vector2(cam.Position.X, cam.Position.Y);
                var b       = new Vector2(offset.X, offset.Y);
                var dir     = a - b;
                var heading = ((Math.Atan2(dir.Y, dir.X) * 180) / Math.PI) - 90;

                ped.Key.Heading = (float)heading;

                angle += 90 / peds.Count;
            }

            if (cam.Rotation == Vector3.Zero)
            {
                cam.MoveTo(new Camera.Waypoint(cam.Position, peds.Keys.ToArray()[lookAt].Position, 50, 0.5f));
                peds.Keys.ToArray()[lookAt].Task.HandsUp(-1);
            }

            if (CitizenFX.Core.Game.IsControlJustReleased(0, Control.MoveLeftOnly))
            {
                lookAt--;
                if (lookAt < 0)
                {
                    lookAt = peds.Count - 1;
                }

                foreach (var ped in peds)
                {
                    ped.Key.Task.ClearAll();
                }

                cam.MoveTo(new Camera.Waypoint(cam.Position, peds.Keys.ToArray()[lookAt].Position, 50, 0.5f));
            }

            if (CitizenFX.Core.Game.IsControlJustReleased(0, Control.MoveRightOnly))
            {
                lookAt++;
                if (lookAt > peds.Count - 1)
                {
                    lookAt = 0;
                }

                foreach (var ped in peds)
                {
                    ped.Key.Task.ClearAll();
                }

                cam.MoveTo(new Camera.Waypoint(cam.Position, peds.Keys.ToArray()[lookAt].Position, 50, 0.5f));
            }

            if (CitizenFX.Core.Game.IsControlJustReleased(0, Control.Context))
            {
                var character = peds.Values.ToArray()[lookAt];
                CharacterSelected(character);
                return;
            }

            if (CitizenFX.Core.Game.IsControlJustReleased(0, Control.InteractionMenu))
            {
                foreach (var ped in peds.Keys)
                {
                    ped.Delete();
                }

                await characterCreator.Start();

                return;
            }

            var selectedPed = peds.Keys.ToArray()[lookAt];

            if (selectedPed.Exists() && !selectedPed.IsDead)
            {
                if (!API.GetIsTaskActive(selectedPed.Handle, 0))
                {
                    selectedPed.Task.HandsUp(-1);
                }
            }
        }