Exemplo n.º 1
0
        private void UpdateDeathTypeInfo(EUIDeadType type, int weaponId)
        {
            switch (type)
            {
            case EUIDeadType.Weapon:
                ShowWeaponIcon(weaponId);
                break;

            case EUIDeadType.Unarmed:
                ShowHandIcon();
                break;

            case EUIDeadType.VehicleHit:
                ShowVehicleIcon(weaponId);
                break;

            case EUIDeadType.VehicleBomb:
                if (weaponId > 0)
                {
                    ShowVehicleIcon(weaponId);
                }
                else
                {
                    SetDeathIconView(false);
                }
                break;

            default:
                SetDeathIconView(false);
                break;
            }
        }
Exemplo n.º 2
0
        public override float DecreaseHp(VehiclePartIndex index, float amount, EUIDeadType damageType, EntityKey damageSource)
        {
            AssertUtility.Assert(amount >= 0);

            switch (index)
            {
            case VehiclePartIndex.FirstWheel:
                FirstWheelHp = FirstWheelHp < amount ? 0.0f : FirstWheelHp - amount;
                return(FirstWheelHp);

            case VehiclePartIndex.SecondWheel:
                SecondWheelHp = SecondWheelHp < amount ? 0.0f : SecondWheelHp - amount;
                return(SecondWheelHp);

            case VehiclePartIndex.ThirdWheel:
                ThirdWheelHp = ThirdWheelHp < amount ? 0.0f : ThirdWheelHp - amount;
                return(ThirdWheelHp);

            case VehiclePartIndex.FourthWheel:
                FourthWheelHp = FourthWheelHp < amount ? 0.0f : FourthWheelHp - amount;
                return(FourthWheelHp);

            default:
                return(base.DecreaseHp(index, amount, damageType, damageSource));
            }
        }
Exemplo n.º 3
0
        public IKillInfoItem CreateKillInfo(string killerName, long killerTeamId, int killerWeaponId, int killType,
                                            string deadName, long deadTeamId, EUIDeadType deathType)
        {
            Logger.InfoFormat(
                "KillMessage:KillName={0},killerTeamId={1},killerWeaponId={2}, killType={3},deadName={4},deadTeamId={5},deathType={6}",
                killerName, killerTeamId, killerWeaponId, killType, deadName, deadTeamId, deathType);

            IKillInfoItem item = new KillInfoItem();

            item.createTime     = SingletonManager.Get <FreeUiManager>().Contexts1.session.currentTimeObject.CurrentTime;
            item.killerName     = killerName;
            item.killerTeamId   = killerTeamId;
            item.killerWeaponId = killerWeaponId;
            item.killType       = killType;
            item.deadName       = deadName;
            item.deadTeamId     = deadTeamId;
            item.deathType      = deathType;

            var weaponConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(killerWeaponId);

            if (null != weaponConfig)
            {
                var config = SingletonManager.Get <WeaponAvatarConfigManager>().GetConfigById(weaponConfig.AvatorId);
                if (null != config)
                {
                    item.weaponAsset = new AssetInfo(config.IconBundle, config.KillIcon);
                }
            }

            return(item);
        }
Exemplo n.º 4
0
        public virtual void Reset()
        {
            Hp             = MaxHp;
            RemainingFuel  = MaxFuel;
            IsAccelerated  = false;
            CurrentSoundId = 0;
            SoundSyncTime  = 0;

            LastDamageType   = EUIDeadType.Unkown;
            LastDamageSource = EntityKey.Default;
        }
Exemplo n.º 5
0
        public override void DoAction(IEventArgs args)
        {
            UnitPosition up = pos.Select(args);

            float       realRadius = FreeUtil.ReplaceFloat(radius, args);
            float       realDamage = FreeUtil.ReplaceFloat(damage, args);
            EUIDeadType realType   = (EUIDeadType)FreeUtil.ReplaceInt(type, args);

            if (damagePara == null)
            {
                damagePara = new FloatPara("damage", realDamage);
                disPara    = new FloatPara("dis", 0f);
                typePara   = new StringPara("type", FreeUtil.ReplaceVar(type, args));
            }

            if (up != null)
            {
                var bombPos   = new Vector3(up.GetX(), up.GetY(), up.GetZ());
                var colliders = Physics.OverlapSphere(bombPos, realRadius,
                                                      UnityLayerManager.GetLayerMask(EUnityLayerName.Player) | UnityLayerManager.GetLayerMask(EUnityLayerName.UserInputRaycast)
                                                      | UnityLayerManager.GetLayerMask(EUnityLayerName.Vehicle) | UnityLayerManager.GetLayerMask(EUnityLayerName.Glass));

                foreach (var collider in colliders)
                {
                    float trueDamage = CalculateBombDamage(collider.transform, bombPos, realDamage, realType);

                    if (Logger.IsDebugEnabled)
                    {
                        Logger.DebugFormat("Process {0}", collider.name);
                    }
                    if (collider.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.Player))
                    {
                        HandlePlayer(collider, args, args.GameContext, trueDamage, bombPos);
                    }
                    if (collider.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.UserInputRaycast))
                    {
                        HandleFracturedObjects(collider.transform, bombPos, trueDamage);
                    }
                    if (collider.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.Vehicle))
                    {
                        HandleVehicle(collider.transform, trueDamage);
                    }
                    if (collider.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.Glass))
                    {
                        HandleGlass(collider.transform);
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void UpdateCardInfo(EUIDeadType type)
        {
            switch (type)
            {
            case EUIDeadType.VehicleHit:
            case EUIDeadType.NoHelp:
            case EUIDeadType.Weapon:
            case EUIDeadType.Unarmed:
                UpdatePlayerCard();
                break;

            default:
                UpdateNonCardById((int)type);
                break;
            }
        }
Exemplo n.º 7
0
        public virtual float DecreaseHp(VehiclePartIndex partIndex, float amount, EUIDeadType damageType, EntityKey damageSource)
        {
            if (partIndex == VehiclePartIndex.Body)
            {
                if (Hp > 0 && Hp < amount)
                {
                    LastDamageType   = damageType;
                    LastDamageSource = damageSource;
                }

                Hp = Hp < amount ? 0.0f : Hp - amount;
                return(Hp);
            }

            return(0.0f);
        }
Exemplo n.º 8
0
        public void OnHitPlayer(Contexts contexts, PlayerEntity src, PlayerEntity target, RaycastHit hit,
                                MeleeAttackInfo attackInfo, MeleeFireLogicConfig config, int seq)
        {
            EBodyPart part       = BulletPlayerUtil.GetBodyPartByHitBoxName(hit.collider);
            var       baseDamage = MeleeHitUtil.GetPlayerFactor(hit, config, part) *
                                   MeleeHitUtil.GetBaseDamage(attackInfo, config);

            if (src.hasStatisticsData)
            {
                src.statisticsData.Statistics.AttackType = (int)attackInfo.AttackType;
            }

            //有效命中

            /*if (target.gamePlay.IsLastLifeState(EPlayerLifeState.Alive))
             * {
             *  src.statisticsData.Statistics.ShootingPlayerCount++;
             * }*/
            var playerWeaponId            = src.WeaponController().HeldConfigId;
            WeaponResConfigItem newConfig =
                SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(playerWeaponId);
            EUIDeadType euiDeadType = (null != newConfig && newConfig.SubType == (int)EWeaponSubType.Hand)
                            ? EUIDeadType.Unarmed
                            : EUIDeadType.Weapon;

            BulletPlayerUtil.ProcessPlayerHealthDamage(contexts, _damager, src, target,
                                                       new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)euiDeadType, (int)part,
                                                                            src.WeaponController().HeldWeaponAgent.ConfigId, false, false, false, hit.point,
                                                                            target.position.Value - src.position.Value));

            //   Logger.InfoFormat("[Hit] process damage sucess,dvalue:{0}", baseDamage);
            //由于动画放在客户端做了,服务器调用的命令会被忽视,需要发送事件到客户端
            //            if (target.hasStateInterface && target.stateInterface.State.CanBeenHit())
            //            {
            //                target.stateInterface.State.BeenHit();
            //            }

            ClientEffectFactory.AddBeenHitEvent(src, target, AttackUtil.GeneraterUniqueHitId(src, seq),
                                                contexts.session.currentTimeObject.CurrentTime);
            int audioId = SingletonManager.Get <AudioWeaponManager>().FindById(playerWeaponId).HitList.Body;

            ClientEffectFactory.AddHitPlayerEffectEvent(src, target.entityKey.Value, hit.point, audioId, part);
        }
Exemplo n.º 9
0
 public static void DoPlayerDamage(Contexts contexts, PlayerEntity sourcePlayer, PlayerEntity targetPlayer, float damage, EUIDeadType hitType = EUIDeadType.VehicleHit, EBodyPart hitPart = EBodyPart.Chest, int weaponId = 0)
 {
     BulletPlayerUtil.ProcessPlayerHealthDamage(contexts, _damager, sourcePlayer, targetPlayer, new PlayerDamageInfo(damage, (int)hitType, (int)hitPart, weaponId));
 }
Exemplo n.º 10
0
        public static void DoDamageToAllPassgers(Contexts contexts, VehicleEntity vehicle, float damage, EUIDeadType deadType, PlayerEntity sourcePlayer = null, bool isDamagePercent = false, bool sendToServer = false)
        {
            var seats        = vehicle.vehicleSeat;
            var orignalDamge = damage;

            for (int seatId = 0; seatId < VehicleSeatComponent.MaxSeatCount; ++seatId)
            {
                EntityKey entityKey;
                if (seats.GetEntityKey(seatId, out entityKey))
                {
                    var player = contexts.player.GetEntityWithEntityKey(entityKey);
                    if (player != null)
                    {
                        if (sourcePlayer == null && deadType == EUIDeadType.VehicleHit)
                        {
                            var lastDriveEntityKey = seats.LastDriverEntityKey;
                            sourcePlayer = contexts.player.GetEntityWithEntityKey(lastDriveEntityKey);
                        }

                        //the case in which the damage is from self
                        if (sourcePlayer == player)
                        {
                            sourcePlayer = null;
                        }

                        if (isDamagePercent)
                        {
                            var gamePlay = player.gamePlay;
                            damage = orignalDamge * gamePlay.MaxHp;
                        }

                        BulletPlayerUtil.ProcessPlayerHealthDamage(contexts, _damager, sourcePlayer, player, new PlayerDamageInfo(damage, (int)deadType, (int)EBodyPart.Chest, vehicle.vehicleAssetInfo.Id,
                                                                                                                                  false, false, false, deadType == EUIDeadType.VehicleBomb ? player.position.Value : Vector3.zero, deadType == EUIDeadType.VehicleBomb ? player.position.Value - vehicle.position.Value : Vector3.zero));
                        if (sendToServer)
                        {
                            SendDamageToServer(vehicle, player.entityKey.Value, damage);
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
 public float DecreaseHp(VehiclePartIndex partIndex, float amount, EUIDeadType damageType)
 {
     return(DecreaseHp(partIndex, amount, damageType, EntityKey.Default));
 }
Exemplo n.º 12
0
 public override float DecreaseHp(VehiclePartIndex index, float amount, EUIDeadType damageType, EntityKey damageSource)
 {
     AssertUtility.Assert(amount >= 0);
     return(base.DecreaseHp(index, amount, damageType, damageSource));
 }
Exemplo n.º 13
0
        private float CalculateBombDamage(Transform transform, Vector3 bombPos, float damage, EUIDeadType damageType)
        {
            var distance = Vector3.Distance(transform.position, bombPos);

            switch (damageType)
            {
            case EUIDeadType.Weapon:
                if (distance > 9f)
                {
                    return(0f);
                }
                return(Mathf.Max(0f, damage * (1 - distance / 9f)));

            case EUIDeadType.Bombing:
                if (distance > 15f)
                {
                    return(0);
                }
                return(damage);

            case EUIDeadType.Bomb:
                if (distance <= 24f)
                {
                    return(damage);
                }
                if (distance > 24f && distance <= 56f)
                {
                    return(Mathf.Max(0, 3.2f * (55 - distance)));
                }
                return(0f);

            default:
                return(damage);
            }
        }