Exemple #1
0
        public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd)
        {
            PlayerEntity player = (PlayerEntity)owner.OwnerEntity;

            if (player.playerMove.IsGround && !player.playerMove.FirstOnGround)
            {
                player.playerMove.FirstOnGround = true;
            }
            else if (player.playerMove.FirstOnGround && !player.playerMove.LastIsCollided && player.playerMove.IsCollided)
            {
                float damage = 0;

                //水平伤害
                Vector2 inVel   = new Vector2(player.playerMove.LastVelocity.x, player.playerMove.LastVelocity.z);
                Vector2 outVel  = new Vector2(0, 0);//(player.playerMove.Velocity.x, player.playerMove.Velocity.z);
                float   xzSpeed = (inVel - outVel).magnitude;

                float hurtSpeedHorizontal = SpeedHorizontal;
                if (player.playerMove.SpeedAffect > 0 && !player.IsOnVehicle())//有加速buff且不在载具内
                {
                    hurtSpeedHorizontal *= player.playerMove.SpeedAffect + 1;
                }
                if (xzSpeed >= hurtSpeedHorizontal)
                {
                    damage += (xzSpeed * 3.6f - 30) * 2;
                }

                //垂直伤害
                float ySpeed = -player.playerMove.LastVelocity.y;

                float hurtSpeedVertical = SpeedVertical;
                if (player.playerMove.JumpAffect > 0 && !player.IsOnVehicle())
                {
                    hurtSpeedVertical *= player.playerMove.JumpAffect + 1;
                }
                if (ySpeed >= hurtSpeedVertical)
                {
                    //damage += (ySpeed - hurtSpeedVertical) * 14; 伤害取二者大值而非相加
                    damage = Mathf.Max(damage, (ySpeed - hurtSpeedVertical) * 14);
                }

                if (damage > 0 && SharedConfig.HaveFallDamage)
                {
                    VehicleDamageUtility.DoPlayerDamage(_contexts, null, player, damage, EUIDeadType.Fall);
                }
            }

            player.playerMove.LastIsCollided = player.playerMove.IsCollided;
            player.playerMove.LastVelocity   = player.playerMove.Velocity;
        }
        private void DoExplosionDamangeToPlayer(VehicleEntity explodedVehicle, Collider collider, Vector3 explosionCenter)
        {
            var player = PlayerEntityUtility.GetPlayerFromChildCollider(collider);

            if (player == null || _processedEntities.Contains(player))
            {
                return;
            }

            _processedEntities.Add(player);

            var damage = CalcExplosionDamageToPlayer(explodedVehicle, player, explosionCenter);

            PlayerEntity sourcePlayer;
            var          damageType = GetDamageType(explodedVehicle, out sourcePlayer);

            VehicleDamageUtility.DoPlayerDamage(sourcePlayer, player, damage, damageType);
        }
Exemple #3
0
        public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd)
        {
            PlayerEntity player = (PlayerEntity)owner.OwnerEntity;

            //受伤状态自动掉血(非被救援状态)
            if (player.gamePlay.IsLifeState(EPlayerLifeState.Dying) && player.gamePlay.InHurtedHp > 0 &&
                !player.gamePlay.IsBeSave)
            {
                player.gamePlay.BuffRemainTime += cmd.FrameInterval;
                int secs = player.gamePlay.BuffRemainTime / 1000;

                if (secs > 0)
                {
                    player.gamePlay.BuffRemainTime %= 1000;
                    float damage = player.gamePlay.InHurtedCount * player.gamePlay.MaxHp * HPLossRate * secs;
                    VehicleDamageUtility.DoPlayerDamage(_contexts, null, player, damage, EUIDeadType.NoHelp);
                }
            }
        }
        public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd)
        {
            PlayerEntity player = (PlayerEntity)owner.OwnerEntity;

            if (player.playerMove.IsGround && !player.playerMove.FirstOnGround)
            {
                player.playerMove.FirstOnGround = true;
            }
            else if (player.playerMove.FirstOnGround && !player.playerMove.LastIsCollided && player.playerMove.IsCollided)
            {
                float damage = 0;

                //水平伤害
                Vector2 inVel   = new Vector2(player.playerMove.LastVelocity.x, player.playerMove.LastVelocity.z);
                Vector2 outVel  = new Vector2(0, 0);//(player.playerMove.Velocity.x, player.playerMove.Velocity.z);
                float   xzSpeed = (inVel - outVel).magnitude;
                if (xzSpeed >= 8.5)
                {
                    damage += (xzSpeed * 3.6f - 30) * 2;
                }

                //垂直伤害
                float ySpeed = -player.playerMove.LastVelocity.y;
                if (ySpeed >= 14)
                {
                    damage += (ySpeed - 14) * 14;
                }

                if ((damage > 0) && (SharedConfig.HaveFallDamage == true))
                {
                    VehicleDamageUtility.DoPlayerDamage(_contexts, null, player, damage, EUIDeadType.Fall);
//                    Debug.LogFormat("IsCollided ... xzSpeed:{0}, ySpeed:{1}, damage:{2}", xzSpeed, ySpeed, damage);
                }
            }

            player.playerMove.LastIsCollided = player.playerMove.IsCollided;
            player.playerMove.LastVelocity   = player.playerMove.Velocity;
        }
 private void DoProcessDamageToPlayer(Contexts contexts, PlayerEntity player, float damage)
 {
     VehicleDamageUtility.DoPlayerDamage(contexts, null, player, damage);
 }
 private void DoProcessDamageToPlayer(PlayerEntity player, float damage)
 {
     VehicleDamageUtility.DoPlayerDamage(null, player, damage);
 }