示例#1
0
        private void ApplyChangeInfoTargetPos(Entity entity, SprotoType.info_item change_info)
        {
            string[] pos_strs = change_info.value.Split(',');
            // Debug.Log("SynchFromNet recieve pos value : "+change_info.value);
            if (pos_strs.Length != 2)
            {
                Debug.Log("SynchFromNet recieve a wrong pos value : " + change_info.value);
                return;
            }
            long new_x = Int64.Parse(pos_strs[0]);
            // long new_y = Int64.Parse(pos_strs[1]);
            long new_z        = Int64.Parse(pos_strs[1]);
            var  newTargetPos = new float3(new_x / GameConst.RealToLogic, 0, new_z / GameConst.RealToLogic);

            var trans  = SceneMgr.Instance.EntityManager.GetComponentObject <Transform>(entity);
            var curPos = trans.localPosition;

            curPos.y = 0;
            var distance = Vector3.Distance(curPos, newTargetPos);

            // if (distance > 100)
            // {
            //     //如果目标坐标距离人物当前坐标很远就直接设置
            //     newTargetPos.y = trans.localPosition.y;
            //     var newPos = SceneMgr.Instance.GetCorrectPos(newTargetPos);
            //     trans.localPosition = newPos;
            //     return;
            // }
            SceneMgr.Instance.EntityManager.SetComponentData(entity, new TargetPosition {
                Value = newTargetPos
            });
        }
示例#2
0
        private void ApplyChangeInfoJumpState(Entity entity, SprotoType.info_item change_info)
        {
            var actionData = SceneMgr.Instance.EntityManager.GetComponentData <ActionData>(entity);

            actionData.Jump = 1;
            SceneMgr.Instance.EntityManager.SetComponentData(entity, actionData);
        }
示例#3
0
        private void ApplyChangeInfoSceneChange(Entity entity, SprotoType.info_item change_info)
        {
            //本条信息变更只会收到自己的
            var mainRoleGOE = RoleMgr.GetInstance().GetMainRole();

            entity = mainRoleGOE != null?mainRoleGOE.Entity:Entity.Null;
            // Debug.Log("ApplyChangeInfoSceneChange : "+change_info.value+" entity:"+entity);
            string[] strs    = change_info.value.Split(',');
            int      sceneID = int.Parse(strs[0]);

            LoadingView.Instance.SetActive(true);
            LoadingView.Instance.ResetData();
            SceneMgr.Instance.LoadScene(sceneID);

            if (entity != Entity.Null && SceneMgr.Instance.EntityManager.Exists(entity))
            {
                long      new_x = Int64.Parse(strs[2]);
                long      new_y = Int64.Parse(strs[3]);
                long      new_z = Int64.Parse(strs[4]);
                Transform trans = SceneMgr.Instance.EntityManager.GetComponentObject <Transform>(entity);
                trans.localPosition = SceneMgr.Instance.GetCorrectPos(new Vector3(new_x / GameConst.RealToLogic, new_y / GameConst.RealToLogic, new_z / GameConst.RealToLogic));
                SceneMgr.Instance.EntityManager.SetComponentData(entity, new TargetPosition {
                    Value = trans.localPosition
                });
                long uid = Int64.Parse(strs[1]);
                SceneMgr.Instance.ChangeRoleUID(entity, uid);
                mainRoleGOE.name = "MainRole_" + uid;
                // SceneMgr.Instance.EntityManager.SetComponentData<UID>(entity, new UID{Value=uid});
                // MoveQuery moveQuery = SceneMgr.Instance.EntityManager.GetComponentObject<MoveQuery>(entity);
                // if (moveQuery != null)
                //     moveQuery.ChangeUID(uid);
            }
        }
示例#4
0
        private void ApplyChangeInfoBuff(Entity entity, SprotoType.info_item change_info)
        {
            // Debug.Log("ApplyChangeInfoBuff : "+change_info.value);
            string[] strs   = change_info.value.Split(',');
            int      buffID = int.Parse(strs[0]);

            if (buffID == (int)SceneConst.Buff.SuckHP)
            {
                var entityMgr = SceneMgr.Instance.EntityManager;
                if (entityMgr.HasComponent <SuckHPEffect>(entity))
                {
                    var suckHPEffect = entityMgr.GetComponentObject <SuckHPEffect>(entity);
                    suckHPEffect.EndTime = TimeEx.ServerTime + 400;
                    suckHPEffect.Status  = EffectStatus.WaitForRender;
                }
            }
            else if (buffID == (int)SceneConst.Buff.Dizzy)
            {
                var hasLoco = SceneMgr.Instance.EntityManager.HasComponent <LocomotionState>(entity);
                // if (hasLoco)
                // {
                //     var locoState = SceneMgr.Instance.EntityManager.GetComponentData<LocomotionState>(entity);
                //     locoState.LocoState = LocomotionState.State.Dizzy;
                //     SceneMgr.Instance.EntityManager.SetComponentData<LocomotionState>(entity, locoState);
                // }
            }
        }
示例#5
0
        private void ApplyChangeInfoExp(Entity entity, SprotoType.info_item change_info)
        {
            string[] strs      = change_info.value.Split(',');
            long     newExp    = Int64.Parse(strs[0]);
            long     isUpgrade = Int64.Parse(strs[1]);

            CSLuaBridge.GetInstance().CallLuaFunc2Num(GlobalEvents.ExpChanged, newExp, isUpgrade);
        }
示例#6
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;
            var      healthData = SceneMgr.Instance.EntityManager.GetComponentData <HealthStateData>(entity);

            healthData.CurHp = curHp;
            SceneMgr.Instance.EntityManager.SetComponentData(entity, healthData);
            bool hasNameboardData = SceneMgr.Instance.EntityManager.HasComponent <NameboardData>(entity);

            if (hasNameboardData)
            {
                var nameboardData = SceneMgr.Instance.EntityManager.GetComponentData <NameboardData>(entity);
                if (nameboardData.UIResState == NameboardData.ResState.Loaded)
                {
                    var nameboardNode = SceneMgr.Instance.EntityManager.GetComponentObject <Nameboard>(nameboardData.UIEntity);
                    if (nameboardNode != null)
                    {
                        nameboardNode.CurHp = curHp;
                        //remove nameboard when dead
                        var isDead = strs.Length == 2 && strs[1] == "dead";
                        if (isDead)
                        {
                            SceneMgr.Instance.World.RequestDespawn(nameboardNode.gameObject);
                            nameboardData.UIResState = NameboardData.ResState.DontLoad;
                            nameboardData.UIEntity   = Entity.Null;
                            SceneMgr.Instance.EntityManager.SetComponentData(entity, nameboardData);
                        }
                    }
                }
                else if (nameboardData.UIResState == NameboardData.ResState.DontLoad)
                {
                    var isRelive = strs.Length == 2 && strs[1] == "relive";
                    Debug.Log("isRelive : " + isRelive);
                    if (isRelive)
                    {
                        nameboardData.UIResState = NameboardData.ResState.WaitLoad;
                        SceneMgr.Instance.EntityManager.SetComponentData(entity, nameboardData);
                    }
                }
            }
            if (strs.Length == 2)
            {
                var isRelive  = strs[1] == "relive";
                var locoState = SceneMgr.Instance.EntityManager.GetComponentData <LocomotionState>(entity);
                locoState.LocoState = isRelive?LocomotionState.State.Idle:LocomotionState.State.Dead;
                // Debug.Log("Time : "+TimeEx.ServerTime.ToString()+" time:"+change_info.time+" isRelive:"+isRelive+" state:"+locoState.LocoState.ToString());
                locoState.StartTime = Time.time - (TimeEx.ServerTime - change_info.time) / 1000.0f;
                SceneMgr.Instance.EntityManager.SetComponentData(entity, locoState);
            }
        }
示例#7
0
        private void ApplyChangeInfoSpeed(Entity entity, SprotoType.info_item change_info)
        {
            if (!entityMgr.HasComponent <SpeedData>(entity))
            {
                Debug.Log(string.Format("SynchFromNet:ApplyChangeInfoSpeed[has no speed data com] entity:{0}", entity));
                return;
            }
            string[] strs      = change_info.value.Split(',');
            string   bodName   = strs[0];
            bool     isSet     = int.Parse(strs[1]) == 1;
            long     value     = Int64.Parse(strs[2]);
            var      speedData = entityMgr.GetComponentObject <SpeedData>(entity);

            speedData.ChangeSpeed(bodName, isSet, value);
        }
示例#8
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);
        }
示例#9
0
        private void ApplyChangeInfoSceneChange(Entity entity, SprotoType.info_item change_info)
        {
            // Debug.Log("ApplyChangeInfoSceneChange : "+change_info.value);
            string[] strs    = change_info.value.Split(',');
            int      sceneID = int.Parse(strs[0]);

            LoadingView.Instance.SetActive(true);
            LoadingView.Instance.ResetData();
            SceneMgr.Instance.LoadScene(sceneID);

            if (entity != Entity.Null)
            {
                long      new_x = Int64.Parse(strs[2]);
                long      new_y = Int64.Parse(strs[3]);
                long      new_z = Int64.Parse(strs[4]);
                Transform trans = SceneMgr.Instance.EntityManager.GetComponentObject <Transform>(entity);
                trans.localPosition = SceneMgr.Instance.GetCorrectPos(new Vector3(new_x / GameConst.RealToLogic, new_y / GameConst.RealToLogic, new_z / GameConst.RealToLogic));
                SceneMgr.Instance.EntityManager.SetComponentData(entity, new TargetPosition {
                    Value = trans.localPosition
                });
                // var uidData = SceneMgr.Instance.EntityManager.GetComponentData<UID>(entity);
                long uid = Int64.Parse(strs[1]);
                SceneMgr.Instance.EntityManager.SetComponentData <UID>(entity, new UID {
                    Value = uid
                });
                // SceneMgr.Instance.EntityManager.SetComponentData<UID>(entity);
                MoveQuery moveQuery = SceneMgr.Instance.EntityManager.GetComponentObject <MoveQuery>(entity);
                // Debug.Log("ApplyChangeInfoSceneChange new uid : "+uid+" moveQuery:"+(moveQuery!=null));
                if (moveQuery != null)
                {
                    moveQuery.ChangeUID(uid);
                }
                // var uidProxy = SceneMgr.Instance.EntityManager.GetComponentObject<UIDProxy>(entity);
                // // SceneMgr.Instance.EntityManager.SetComponentData<UID>(entity);
                // if (uidProxy!=null)
                // {
                //     long uid = Int64.Parse(strs[1]);
                //     uidProxy.Value = new UID{Value=uid};
                //     MoveQuery moveQuery = SceneMgr.Instance.EntityManager.GetComponentObject<MoveQuery>(entity);
                //     // Debug.Log("ApplyChangeInfoSceneChange new uid : "+uid+" moveQuery:"+(moveQuery!=null));
                //     if (moveQuery != null)
                //     {
                //         moveQuery.ChangeUID(uid);
                //     }
                // }
            }
        }
示例#10
0
        private void ApplyChangeInfoTargetPos(Entity entity, SprotoType.info_item change_info)
        {
            string[] pos_strs = change_info.value.Split(',');
            // Debug.Log("SynchFromNet recieve pos value : "+change_info.value);
            if (pos_strs.Length != 3)
            {
                Debug.Log("SynchFromNet recieve a wrong pos value : " + change_info.value);
                return;
            }
            long new_x = Int64.Parse(pos_strs[0]);
            // long new_y = Int64.Parse(pos_strs[1]);
            long new_z = Int64.Parse(pos_strs[1]);

            SceneMgr.Instance.EntityManager.SetComponentData(entity, new TargetPosition {
                Value = new float3(new_x / GameConst.RealToLogic, 0, new_z / GameConst.RealToLogic)
            });
        }
示例#11
0
        private void ApplyChangeInfoBuff(Entity entity, SprotoType.info_item change_info)
        {
            // Debug.Log("ApplyChangeInfoBuff : "+change_info.value);
            string[] strs   = change_info.value.Split(',');
            int      buffID = int.Parse(strs[0]);

            if (buffID == (int)SceneConst.Buff.SuckHP)
            {
                var entityMgr = SceneMgr.Instance.EntityManager;
                if (entityMgr.HasComponent <SuckHPEffect>(entity))
                {
                    var suckHPEffect = entityMgr.GetComponentObject <SuckHPEffect>(entity);
                    suckHPEffect.EndTime = TimeEx.ServerTime + 400;
                    suckHPEffect.Status  = EffectStatus.WaitForRender;
                }
            }
        }
示例#12
0
        private void ApplyChangeInfoPos(Entity entity, SprotoType.info_item change_info)
        {
            string[] pos_strs = change_info.value.Split(',');
            // Debug.Log("SynchFromNet recieve pos value : "+change_info.value);
            if (pos_strs.Length < 3)
            {
                Debug.Log("SynchFromNet recieve a wrong pos value : " + change_info.value);
                return;
            }
            long      new_x = Int64.Parse(pos_strs[0]);
            long      new_y = Int64.Parse(pos_strs[1]);
            long      new_z = Int64.Parse(pos_strs[2]);
            Transform trans = SceneMgr.Instance.EntityManager.GetComponentObject <Transform>(entity);

            trans.localPosition = SceneMgr.Instance.GetCorrectPos(new Vector3(new_x / GameConst.RealToLogic, new_y / GameConst.RealToLogic, new_z / GameConst.RealToLogic));
            SceneMgr.Instance.EntityManager.SetComponentData(entity, new TargetPosition {
                Value = trans.localPosition
            });
        }
示例#13
0
        private void ApplyChangeInfoSceneChange(Entity entity, SprotoType.info_item change_info)
        {
            Debug.Log("ApplyChangeInfoSceneChange : " + change_info.value);
            string[] strs    = change_info.value.Split(',');
            int      sceneID = int.Parse(strs[0]);

            LoadingView.Instance.SetActive(true);
            LoadingView.Instance.ResetData();
            SceneMgr.Instance.LoadScene(sceneID);

            if (entity != Entity.Null)
            {
                long      new_x = Int64.Parse(strs[1]);
                long      new_y = Int64.Parse(strs[2]);
                long      new_z = Int64.Parse(strs[3]);
                Transform trans = SceneMgr.Instance.EntityManager.GetComponentObject <Transform>(entity);
                trans.localPosition = SceneMgr.Instance.GetCorrectPos(new Vector3(new_x / GameConst.RealToLogic, new_y / GameConst.RealToLogic, new_z / GameConst.RealToLogic));
                SceneMgr.Instance.EntityManager.SetComponentData(entity, new TargetPosition {
                    Value = trans.localPosition
                });
            }
        }
示例#14
0
 private void ApplyChangeInfoBuff(Entity entity, SprotoType.info_item change_info)
 {
     BuffMgr.GetInstance().HandleBuff(entity, change_info.value);
 }