Exemple #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))
                {
                    continue;
                }
                if (entityMgr.HasComponent <LocomotionState>(defenderEntity))
                {
                    var isRole = RoleMgr.GetInstance().IsRoleEntity(defenderEntity);
                    //进入受击状态
                    bool playBehit = UnityEngine.Random.Range(0, 100) > 40.0f;
                    if (!isRole && playBehit)
                    {
                        var locomotionState = entityMgr.GetComponentData <LocomotionState>(defenderEntity);
                        locomotionState.LocoState    = LocomotionState.State.BeHit;
                        locomotionState.StateEndType = LocomotionState.EndType.PlayAnimationOnce;
                        ECSHelper.ChangeLocoState(defenderEntity, locomotionState);
                        // entityMgr.SetComponentData<LocomotionState>(defenderEntity, locomotionState);
                    }
                    bool isNeedShakeCamera = (isRole && playBehit) || !isRole;
                    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();
                }
                ECSHelper.ChangeHP(defenderEntity, defender.cur_hp, defender.flag, hurtEvent.attacker_uid);
            }
        }
Exemple #2
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);
            }
        }