예제 #1
0
 protected override void Update()
 {
     foreach (var key in sfxKeys.Keys.Where(RawKeyboardInput.IsPressed).Select(key => key))
     {
         Sfx.PlaySfx(sfxKeys[key]);
     }
 }
예제 #2
0
    public void RunFireEffects()
    {
        ActualAssert(ParentPlayer != null);

        if (CurrentWeapon.Kind == WeaponKind.PISTOL)
        {
            Sfx.PlaySfx(SfxCatagory.PISTOL_FIRE, 0, GlobalTransform.origin, 0);
        }
        else if (CurrentWeapon.Kind == WeaponKind.AK)
        {
            Sfx.PlaySfx(SfxCatagory.AK_FIRE, 0, GlobalTransform.origin, 0);
        }
        else if (CurrentWeapon.Kind == WeaponKind.SHOTGUN)
        {
            Sfx.PlaySfx(SfxCatagory.SHOTGUN_FIRE, 0, GlobalTransform.origin, 0);
        }

        float RecoilDampen = ((1 - CalcAdsDisplay()) + ParentPlayer.CrouchPercent) / 2f;

        ParentPlayer.CamAnimations.Add(new WeaponRecoil(CurrentWeapon.RecoilTime, CurrentWeapon.RecoilAmount, RecoilDampen));

        int Index = TinkChooser.Choose();

        Sfx.PlaySfxSpatially(SfxCatagory.CASING_TINK, Index, GlobalTransform.origin + new Vector3(0, -2, 0), 0);
    }
    public void HandleFootsteps(float Delta)
    {
        float Decrement = Delta;
        float Muffle    = 16;

        if (Round(Momentum.Flattened().Length()) > BaseSpeed)
        {
            Decrement *= SprintingFootstepAcceleration;
            Muffle     = 0;
        }

        FootstepCountdown -= Decrement;

        if (OnFloor && Mode != MovementMode.SNEAKING && (BackwardForwardDirection != 0 || RightLeftDirection != 0))
        {
            if (FootstepCountdown <= 0)
            {
                FootstepCountdown = FootstepBaseTime;

                int Index    = -1;
                var Catagory = (SfxCatagory)(-1);
                if (FloorCast.GetCollider() is Node Floor)
                {
                    if (Floor.IsInGroup("concrete"))
                    {
                        Index    = ConcreteChooser.Choose();
                        Catagory = SfxCatagory.CONCRETE_FOOTSTEPS;
                    }
                    else if (Floor.IsInGroup("leaves"))
                    {
                        Index    = LeavesChooser.Choose();
                        Catagory = SfxCatagory.LEAVES_FOOTSTEPS;
                    }
                    else if (Floor.IsInGroup("metal"))
                    {
                        Index    = MetalChooser.Choose();
                        Catagory = SfxCatagory.METAL_FOOTSTEPS;
                    }
                    else if (Floor.IsInGroup("marble"))
                    {
                        Index    = MarbleChooser.Choose();
                        Catagory = SfxCatagory.MARBLE_FOOTSTEPS;
                    }
                    else
                    {
                        Index    = ConcreteChooser.Choose();
                        Catagory = SfxCatagory.CONCRETE_FOOTSTEPS;
                    }
                }

                if (Index != -1)
                {
                    ActualAssert(Catagory != (SfxCatagory)(-1));
                    Sfx.PlaySfx(Catagory, Index, GlobalTransform.origin, Muffle);
                }
            }
        }
    }
    public override void _PhysicsProcess(float Delta)
    {
        HandleMovementInput(Delta);
        HandleCrouchInput(Delta);

        bool  WasOnFloor   = OnFloor;
        float OldMomentumY = Momentum.y;

        Momentum = Move(Momentum, Delta, 5, 40, 0.42f);
        if (!WasOnFloor && OnFloor && OldMomentumY < CrunchSpeed)
        {
            CamAnimations.Add(new CrunchCamDip());

            bool TakeFallDamage = true;
            if (FloorCast.GetCollider() is Node Floor && Floor.IsInGroup("leaves"))
            {
                TakeFallDamage = false;
            }

            if (TakeFallDamage)
            {
                Sfx.PlaySfx(SfxCatagory.FALL_CRUNCH, 0, GlobalTransform.origin, 0);

                float Overkill = -(OldMomentumY - CrunchSpeed);
                float Percent  = Overkill / (MaxFallSpeed + CrunchSpeed);
                float Damage   = BaseCrunchDmg + (100f * Percent);
                Health -= (int)Damage;
                GD.Print("Overkill: ", Overkill, " Percent: ", Percent, " Damage: ", Damage);
                CheckDie(-1);
            }
            else
            {
                Sfx.PlaySfx(SfxCatagory.LEAVES_FOOTSTEPS, LeavesChooser.Choose(), GlobalTransform.origin, -30);
            }
        }

        HandleFootsteps(Delta);
        HandleAdsSprintEffects();

        CamJoint.RotationDegrees = new Vector3();

        int Index = 0;

        while (Index < CamAnimations.Count)
        {
            CamAnimations[Index].Tick(CamJoint, Delta);

            if (CamAnimations[Index].ReachedEnd())
            {
                CamAnimations.RemoveAt(Index);
            }
            else
            {
                Index += 1;
            }
        }

        Rpc(nameof(ThirdPersonPlayer.NetUpdateTransform), Transform, CrouchPercent);
        Rpc(nameof(ThirdPersonPlayer.NetUpdateSpecateCam), CamJoint.Rotation.x, Cam.Rotation.x, Cam.Fov);
        Rpc(nameof(ThirdPersonPlayer.NetUpdateWeaponHolder), Holder.Momentum, Holder.ReloadHidePercent, Holder.SprintTime, Holder.AdsTime);

        base._PhysicsProcess(Delta);
    }
예제 #5
0
    public override void _Process(float Delta)
    {
        if (ParentPlayer != null)
        {
            TickFireTime(CurrentWeapon, Delta);

            float PlayerSpeed = Round(ParentPlayer.Momentum.Flattened().Length());
            if (((!CurrentWeapon.FullAuto && Input.IsActionJustPressed("Fire")) ||
                 (CurrentWeapon.FullAuto && Input.IsActionPressed("Fire"))) &&
                CurrentWeapon.FireTimer <= 0 &&
                PlayerSpeed <= FirstPersonPlayer.BaseSpeed &&
                SprintTime <= 0 &&
                Reloading == false)
            {
                CurrentWeapon.FireTimer = CurrentWeapon.MaxFireTime;

                if (CurrentWeapon.CurrentAmmo > 0)
                {
                    CurrentWeapon.CurrentAmmo -= 1;
                    PerformHitscan();
                    RunFireEffects();
                }
                else
                {
                    Sfx.PlaySfx(SfxCatagory.EMPTY_CHAMBER_FIRE_CLICK, 0, GlobalTransform.origin, 0);
                }
            }

            if (Input.IsActionJustPressed("Reload") &&
                CurrentWeapon.ReloadTimer <= 0 &&
                CurrentWeapon.CurrentAmmo < CurrentWeapon.MaxAmmo)
            {
                CurrentWeapon.ReloadTimer = CurrentWeapon.MaxReloadTime;
                Reloading = true;
                Sfx.PlaySfx(SfxCatagory.RELOAD, 0, GlobalTransform.origin, 0);
            }
            else if (Reloading && CurrentWeapon.ReloadTimer > 0)
            {
                CurrentWeapon.ReloadTimer = Clamp(CurrentWeapon.ReloadTimer - Delta, 0, CurrentWeapon.MaxReloadTime);
                if (CurrentWeapon.ReloadTimer <= 0)
                {
                    CurrentWeapon.CurrentAmmo = CurrentWeapon.MaxAmmo;
                    Sfx.PlaySfx(SfxCatagory.RELOAD, 1, GlobalTransform.origin, 0);
                }
            }
            else
            {
                Reloading = false;
            }

            float OneTenth = CurrentWeapon.MaxReloadTime / 10;
            if (CurrentWeapon.ReloadTimer >= OneTenth * 9f)
            {
                ReloadHidePercent = 1 - (CurrentWeapon.ReloadTimer - OneTenth * 9f) / OneTenth;
            }
            else if (CurrentWeapon.ReloadTimer <= OneTenth)
            {
                ReloadHidePercent = CurrentWeapon.ReloadTimer / OneTenth;
            }

            if (ParentPlayer.Mode == MovementMode.SPRINTING)
            {
                SprintTime = Clamp(SprintTime + Delta, 0, SprintChangeStateTime);
            }
            else
            {
                SprintTime = Clamp(SprintTime - Delta, 0, SprintChangeStateTime);
            }
        }

        float ReloadDisplay = Sin((ReloadHidePercent / 2f) * Pi);
        float SprintDisplay = CalcSprintDisplay();

        RotationDegrees = new Vector3(-140 * ReloadDisplay, 75f * SprintDisplay, 0);

        if (ParentPlayer != null)
        {
            if (ParentPlayer.Mode != MovementMode.SPRINTING && Input.IsActionPressed("ADS") && !Reloading)
            {
                AdsTime = Clamp(AdsTime + Delta, 0, AdsChangeStateTime);
            }
            else
            {
                AdsTime = Clamp(AdsTime - Delta, 0, AdsChangeStateTime);
            }
        }

        float AdsDisplay = CalcAdsDisplay();

        Translation = new Vector3(
            OgTranslation.x * AdsDisplay,
            OgTranslation.y * AdsDisplay,
            OgTranslation.z
            );

        TickMomentum(Delta);

        base._Process(Delta);
    }
예제 #6
0
 private void OnGetChestItem(MsgGetChestItem obj)
 {
     Sfx.PlaySfx(obj.getSfx);
 }
예제 #7
0
 private void OnChangeOptionUI(MsgChangeOptionUI obj)
 {
     Sfx.PlaySfx(FayvitSounds.SoundEffectID.Cursor1);
 }
예제 #8
0
 private void OnPositiveUiInput(MsgPositiveUiInput obj)
 {
     Sfx.PlaySfx(FayvitSounds.SoundEffectID.Decision2);
 }
예제 #9
0
 private void OnNegativeUiInput(MsgNegativeUiInput obj)
 {
     Sfx.PlaySfx(FayvitSounds.SoundEffectID.Book1);
 }
예제 #10
0
 private void OnBoxGoingOut(FillTextDisplayMessage obj)
 {
     Sfx.PlaySfx(FayvitSounds.SoundEffectID.Book1);
 }
예제 #11
0
 private void OnHideUpperMessage(MsgHideShowItem obj)
 {
     Sfx.PlaySfx(FayvitSounds.SoundEffectID.Book1);
 }
예제 #12
0
        protected override void Update()
        {
            AxisDirections?moveDirection = null;

            if (RawKeyboardInput.IsPressed(Keys.W) || RawGamepadInput.IsDpadPressed(AxisDirections.Up) || RawGamepadInput.IsLeftJoystickPressed(AxisDirections.Up))
            {
                moveDirection = AxisDirections.Up;
            }
            else if (RawKeyboardInput.IsPressed(Keys.D) || RawGamepadInput.IsDpadPressed(AxisDirections.Right) || RawGamepadInput.IsLeftJoystickPressed(AxisDirections.Right))
            {
                moveDirection = AxisDirections.Right;
            }
            else if (RawKeyboardInput.IsPressed(Keys.S) || RawGamepadInput.IsDpadPressed(AxisDirections.Down) || RawGamepadInput.IsLeftJoystickPressed(AxisDirections.Down))
            {
                moveDirection = AxisDirections.Down;
            }
            else if (RawKeyboardInput.IsPressed(Keys.A) || RawGamepadInput.IsDpadPressed(AxisDirections.Left) || RawGamepadInput.IsLeftJoystickPressed(AxisDirections.Left))
            {
                moveDirection = AxisDirections.Left;
            }

            if (moveDirection != null)
            {
                Point destination = coords + ((AxisDirections)moveDirection).ToPoint();

                if (checkCanMove(destination))
                {
                    GameGrid[coords.X, coords.Y]           = null;
                    GameGrid[destination.X, destination.Y] = Object;
                    coords = destination;
                }
            }


            Diagonals?diagonalDir = null;

            if (RawKeyboardInput.IsPressed(Keys.Q))
            {
                diagonalDir = Diagonals.UpLeft;
            }
            else if (RawKeyboardInput.IsPressed(Keys.E))
            {
                diagonalDir = Diagonals.UpRight;
            }
            else if (RawKeyboardInput.IsPressed(Keys.Z))
            {
                diagonalDir = Diagonals.DownLeft;
            }
            else if (RawKeyboardInput.IsPressed(Keys.C))
            {
                diagonalDir = Diagonals.DownRight;
            }

            if (diagonalDir != null)
            {
                Sfx.PlaySfx("sfx1");
                GameObject projectileObj = ProjectileController.BuildObject(PROJ_SPEED, PROJ_SIZE, PROJ_BOUNCES, ((Diagonals)diagonalDir).ToVector2());
                projectileObj.LocalPosition = Object.LocalPosition.Plus(tileSize / 2 - 1);
                Pigeon.World.AddObj(projectileObj);
            }
        }