示例#1
0
        private void HandleHurtEvent(SprotoType.scene_hurt_event_info hurtEvent)
        {
            // long uid = hurtEvent.attacker_uid;
            var entityMgr = SceneMgr.Instance.EntityManager;

            if (hurtEvent.defenders == null || hurtEvent.defenders.Count <= 0)
            {
                return;
            }
            for (int i = 0; i < hurtEvent.defenders.Count; i++)
            {
                var defender = hurtEvent.defenders[i];
                // Debug.Log("defender uid : "+defender.uid+" count:"+hurtEvent.defenders.Count+" hp:"+defender.cur_hp+" damagetype:"+defender.flag);
                var defenderEntity = SceneMgr.Instance.GetSceneObject(defender.uid);
                // Debug.Log("has LocomotionState : "+entityMgr.HasComponent<LocomotionState>(defenderEntity)+" isdead:"+ECSHelper.IsDead(defenderEntity, entityMgr)+" isnull:"+defenderEntity.Equals(Entity.Null));
                if (defenderEntity.Equals(Entity.Null) || ECSHelper.IsDead(defenderEntity, entityMgr))
                {
                    continue;
                }
                if (entityMgr.HasComponent <LocomotionState>(defenderEntity))
                {
                    var isMainRole = RoleMgr.GetInstance().IsMainRoleEntity(defenderEntity);
                    //进入受击状态
                    bool playBehit = UnityEngine.Random.RandomRange(0, 100) > 30.0f;
                    if (!isMainRole && playBehit)
                    {
                        var locomotionState = entityMgr.GetComponentData <LocomotionState>(defenderEntity);
                        locomotionState.LocoState    = LocomotionState.State.BeHit;
                        locomotionState.StateEndType = LocomotionState.EndType.PlayAnimationOnce;
                        // locomotionState.StartTime = Time.time;
                        entityMgr.SetComponentData <LocomotionState>(defenderEntity, locomotionState);
                    }
                    bool isNeedShakeCamera = (isMainRole && playBehit) || !isMainRole;
                    if (isNeedShakeCamera && entityMgr.HasComponent <CinemachineImpulseSource>(defenderEntity))
                    {
                        var impulseCom = entityMgr.GetComponentObject <CinemachineImpulseSource>(defenderEntity);
                        var velocity   = Vector3.one * defender.change_num / 5;
                        impulseCom.GenerateImpulse();
                    }
                    if (entityMgr.HasComponent <BeHitEffect>(defenderEntity))
                    {
                        var behitEffect = entityMgr.GetComponentObject <BeHitEffect>(defenderEntity);
                        behitEffect.EndTime = TimeEx.ServerTime + 300;
                        behitEffect.Status  = EffectStatus.WaitForRender;
                    }
                    //显示战斗飘字
                    var          defenderTrans = entityMgr.GetComponentObject <Transform>(defenderEntity);
                    var          flyWordObj    = ResMgr.GetInstance().GetGameObject("FightFlyWord");
                    FightFlyWord flyWord       = flyWordObj.GetComponent <FightFlyWord>();
                    flyWord.SetData(defender.change_num, defender.flag);
                    var pos = defenderTrans.position;
                    pos += Vector3.up * 1;
                    flyWord.transform.SetParent(UnityMMO.SceneMgr.Instance.FlyWordContainer);
                    flyWord.transform.position = pos;
                    flyWord.StartFly();
                }
                ChangeHP(defenderEntity, defender.cur_hp, defender.flag, hurtEvent.attacker_uid);
            }
        }
示例#2
0
        private void ApplyChangeInfoHPChange(Entity entity, SprotoType.info_item change_info)
        {
            // Debug.Log("hp change : "+change_info.value);
            string[] strs  = change_info.value.Split(',');
            float    curHp = (float)Int64.Parse(strs[0]) / GameConst.RealToLogic;
            long     flag  = 0;

            if (strs.Length == 2)
            {
                if (strs[1] == "relive")
                {
                    flag = 5;
                }
            }
            ECSHelper.ChangeHP(entity, Int64.Parse(strs[0]), flag, 0);
        }
示例#3
0
        public void HandleDizzy(Entity entity, string[] buffStrs)
        {
            var hasLoco = SceneMgr.Instance.EntityManager.HasComponent <LocomotionState>(entity);

            if (hasLoco)
            {
                var locoState = SceneMgr.Instance.EntityManager.GetComponentData <LocomotionState>(entity);
                locoState.LocoState    = LocomotionState.State.Dizzy;
                locoState.StateEndType = LocomotionState.EndType.EndTime;
                long endTime = Int64.Parse(buffStrs[1]);
                Debug.Log("dizzy buff : " + endTime + " " + TimeEx.ServerTime);
                locoState.EndTime = endTime;
                // SceneMgr.Instance.EntityManager.SetComponentData<LocomotionState>(entity, locoState);
                ECSHelper.ChangeLocoState(entity, locoState);
            }
        }
示例#4
0
        private void HandleHurtEvent(SprotoType.scene_hurt_event_info hurtEvent)
        {
            // long uid = hurtEvent.attacker_uid;
            var entityMgr = SceneMgr.Instance.EntityManager;

            if (hurtEvent.defenders == null || hurtEvent.defenders.Count <= 0)
            {
                return;
            }
            for (int i = 0; i < hurtEvent.defenders.Count; i++)
            {
                var defender = hurtEvent.defenders[i];
                // Debug.Log("defender uid : "+defender.uid+" count:"+hurtEvent.defenders.Count+" damage:"+defender.damage+" hp:"+defender.cur_hp+" damagetype:"+defender.flag);
                var defenderEntity = SceneMgr.Instance.GetSceneObject(defender.uid);
                // Debug.Log("has health : "+entityMgr.HasComponent<HealthStateData>(defenderEntity));
                if (defenderEntity.Equals(Entity.Null) || ECSHelper.IsDead(defenderEntity, entityMgr))
                {
                    continue;
                }
                if (entityMgr.HasComponent <LocomotionState>(defenderEntity))
                {
                    //进入受击状态
                    bool playBehit = UnityEngine.Random.RandomRange(0, 100) > 90.0f;
                    if (playBehit)
                    {
                        var locomotionState = entityMgr.GetComponentData <LocomotionState>(defenderEntity);
                        locomotionState.LocoState = LocomotionState.State.BeHit;
                        locomotionState.StartTime = Time.time;
                        entityMgr.SetComponentData <LocomotionState>(defenderEntity, locomotionState);
                    }
                    //显示战斗飘字
                    var          defenderTrans = entityMgr.GetComponentObject <Transform>(defenderEntity);
                    var          flyWordObj    = ResMgr.GetInstance().GetGameObject("FightFlyWord");
                    FightFlyWord flyWord       = flyWordObj.GetComponent <FightFlyWord>();
                    flyWord.SetData(defender.change_num, defender.flag);
                    var pos = defenderTrans.position;
                    pos += Vector3.up * 1;
                    flyWord.transform.SetParent(UnityMMO.SceneMgr.Instance.FlyWordContainer);
                    flyWord.transform.position = pos;
                    flyWord.StartFly();
                }
                ChangeHP(defenderEntity, defender.cur_hp, defender.flag, hurtEvent.attacker_uid);
            }
        }