예제 #1
0
 private void RecycleSceneLogicInfo(SceneLogicInfo logicInfo)
 {
     if (null != logicInfo && m_UnusedSceneLogicInfos.Count < m_SceneLogicInfoPoolSize)
     {
         logicInfo.Reset();
         m_UnusedSceneLogicInfos.Enqueue(logicInfo);
     }
 }
예제 #2
0
        public SceneLogicInfo AddSceneLogicInfo(int id, SceneLogicConfig cfg)
        {
            SceneLogicInfo info = NewSceneLogicInfo(id);

            info.SceneContext     = m_SceneContext;
            info.SceneLogicConfig = cfg;
            m_SceneLogicInfos.AddLast(info.GetId(), info);
            return(info);
        }
예제 #3
0
        public SceneLogicInfo DelayAddSceneLogicInfo(int id, SceneLogicConfig cfg)
        {
            SceneLogicInfo info = NewSceneLogicInfo(id);

            info.SceneContext     = m_SceneContext;
            info.SceneLogicConfig = cfg;
            m_DelayAdd.Add(info);
            return(info);
        }
예제 #4
0
        public SceneLogicInfo DelayAddSceneLogicInfo(int logicId)
        {
            SceneLogicInfo info = NewSceneLogicInfo();

            info.SceneContext               = m_SceneContext;
            info.SceneLogicConfig           = new SceneLogicConfig();
            info.SceneLogicConfig.m_LogicId = logicId;
            m_DelayAdd.Add(info);
            return(info);
        }
예제 #5
0
        public SceneLogicInfo AddSceneLogicInfo(int logicId)
        {
            SceneLogicInfo info = NewSceneLogicInfo();

            info.SceneContext               = m_SceneContext;
            info.SceneLogicConfig           = new SceneLogicConfig();
            info.SceneLogicConfig.m_LogicId = logicId;
            m_SceneLogicInfos.AddLast(info.GetId(), info);
            return(info);
        }
예제 #6
0
        public void RemoveSceneLogicInfo(int id)
        {
            SceneLogicInfo info = GetSceneLogicInfo(id);

            if (null != info)
            {
                m_SceneLogicInfos.Remove(id);
                info.SceneContext = null;
                RecycleSceneLogicInfo(info);
            }
        }
예제 #7
0
        public SceneLogicInfo GetSceneLogicInfoByConfigId(int id)
        {
            SceneLogicInfo ret = null;

            for (LinkedListNode <SceneLogicInfo> linkNode = m_SceneLogicInfos.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                SceneLogicInfo info = linkNode.Value;
                if (info.ConfigId == id)
                {
                    ret = info;
                    break;
                }
            }
            return(ret);
        }
예제 #8
0
        public SceneLogicInfo AddSceneLogicInfo(int id, int logicId)
        {
            SceneLogicInfo info = NewSceneLogicInfo(id);

            info.SceneContext               = m_SceneContext;
            info.SceneLogicConfig           = new SceneLogicConfig();
            info.SceneLogicConfig.m_LogicId = logicId;
            SceneLogicInfo oldInfo;

            if (m_SceneLogicInfos.TryGetValue(id, out oldInfo))
            {
                LogSystem.Error("AddSceneLogicInfo error, Id={0} was exist, LogicId={1}, NewLogicId={2}", id, oldInfo.LogicId, logicId);
            }
            m_SceneLogicInfos.AddLast(info.GetId(), info);
            return(info);
        }
예제 #9
0
        private SceneLogicInfo NewSceneLogicInfo(int id)
        {
            SceneLogicInfo info = null;

            if (m_UnusedSceneLogicInfos.Count > 0)
            {
                info = m_UnusedSceneLogicInfos.Dequeue();
                info.Reset();
                info.InitId(id);
            }
            else
            {
                info = new SceneLogicInfo(id);
            }
            return(info);
        }
예제 #10
0
 public override void Execute(SceneLogicInfo info, long deltaTime)
 {
     if (null == info || info.IsLogicFinished || info.IsLogicPaused)
     {
         return;
     }
     info.Time += deltaTime;
     if (info.Time > 100)
     {
         NpcInAreaLogicInfo data = info.LogicDatas.GetData <NpcInAreaLogicInfo>();
         if (null == data)
         {
             data = new NpcInAreaLogicInfo();
             info.LogicDatas.AddData <NpcInAreaLogicInfo>(data);
             SceneLogicConfig sc = info.SceneLogicConfig;
             if (null != sc)
             {
                 if (null != sc)
                 {
                     List <float> pts = Converter.ConvertNumericList <float>(sc.m_Params[0]);
                     data.m_Area = new Vector3[pts.Count / 2];
                     for (int ix = 0; ix < pts.Count - 1; ix += 2)
                     {
                         data.m_Area[ix / 2].X = pts[ix];
                         data.m_Area[ix / 2].Z = pts[ix + 1];
                     }
                 }
             }
         }
         info.Time = 0;
         if (null != data)
         {
             info.SpatialSystem.VisitObjectOutPolygon(data.m_Area, (float distSqr, ArkCrossEngineSpatial.ISpaceObject obj) =>
             {
                 if (obj.GetObjType() == ArkCrossEngineSpatial.SpatialObjType.kNPC)
                 {
                     NpcInfo npc = obj.RealObject as NpcInfo;
                     if (null != npc && !npc.IsDead())
                     {
                         npc.SetHp(Operate_Type.OT_Absolute, 0);
                         SceneLogicSendStoryMessage(info, "npcleavearea", npc.GetId());
                     }
                 }
             });
         }
     }
 }
예제 #11
0
        public void Tick()
        {
            if (0 == m_LastTickTime)
            {
                m_LastTickTime = TimeUtility.GetServerMilliseconds();
            }
            else
            {
                long delta = TimeUtility.GetServerMilliseconds() - m_LastTickTime;
                m_LastTickTime = TimeUtility.GetServerMilliseconds();
                for (LinkedListNode <SceneLogicInfo> node = m_SceneLogicInfoMgr.SceneLogicInfos.FirstValue; null != node; node = node.Next)
                {
                    SceneLogicInfo info = node.Value;
                    if (null != info)
                    {
                        ISceneLogic logic = SceneLogicManager.Instance.GetSceneLogic(info.LogicId);
                        if (null != logic)
                        {
                            logic.Execute(info, delta);
                        }
                        if (info.IsLogicFinished)
                        {
                            m_SceneLogicInfos.Add(info);
                        }
                    }
                }
                for (int i = 0; i < m_SceneLogicInfos.Count; i++)
                {
                    m_SceneLogicInfoMgr.RemoveSceneLogicInfo(m_SceneLogicInfos[i].GetId());
                }

                /*
                 * foreach (SceneLogicInfo info in m_SceneLogicInfos) {
                 * m_SceneLogicInfoMgr.RemoveSceneLogicInfo(info.GetId());
                 * }*/
                m_SceneLogicInfos.Clear();
                m_SceneLogicInfoMgr.ExecuteDelayAdd();
            }
        }
        public override void Execute(SceneLogicInfo info, long deltaTime)
        {
            if (null == info || info.IsLogicFinished || info.IsLogicPaused)
            {
                return;
            }
            info.Time += deltaTime;
            if (info.Time > 100)
            {
                AreaDetectLogicInfo data = info.LogicDatas.GetData <AreaDetectLogicInfo>();
                if (null == data)
                {
                    data = new AreaDetectLogicInfo();
                    info.LogicDatas.AddData <AreaDetectLogicInfo>(data);

                    SceneLogicConfig sc = info.SceneLogicConfig;
                    if (null != sc)
                    {
                        List <float> pts = Converter.ConvertNumericList <float>(sc.m_Params[0]);
                        data.m_Area = new Vector3[pts.Count / 2];
                        for (int ix = 0; ix < pts.Count - 1; ix += 2)
                        {
                            data.m_Area[ix / 2].X = pts[ix];
                            data.m_Area[ix / 2].Z = pts[ix + 1];
                        }
                        data.m_TriggerType = (AreaDetectLogicInfo.TiggerTypeEnum) int.Parse(sc.m_Params[1]);
                        data.m_Timeout     = long.Parse(sc.m_Params[2]);
                    }
                }
                data.m_CurTime += info.Time;
                info.Time       = 0;
                //执行逻辑
                if (null != data && !data.m_IsTriggered && data.m_CurTime >= data.m_Timeout)
                {
                    data.m_IsTriggered = true;
                    if (data.m_TriggerType == AreaDetectLogicInfo.TiggerTypeEnum.All)
                    {
                        ArrayList list = new ArrayList();
                        info.SpatialSystem.VisitObjectInPolygon(data.m_Area, (float distSqr, ArkCrossEngineSpatial.ISpaceObject obj) =>
                        {
                            list.Add((int)obj.GetID());
                        });
                        OnSceneLogicSendStoryMessage(info, "areadetect:" + info.ConfigId, list.ToArray());
                    }
                    else if (data.m_TriggerType == AreaDetectLogicInfo.TiggerTypeEnum.Npc)
                    {
                        ArrayList list = new ArrayList();
                        info.SpatialSystem.VisitObjectInPolygon(data.m_Area, (float distSqr, ArkCrossEngineSpatial.ISpaceObject obj) =>
                        {
                            if (obj.GetObjType() == ArkCrossEngineSpatial.SpatialObjType.kNPC)
                            {
                                list.Add((int)obj.GetID());
                            }
                        });
                        OnSceneLogicSendStoryMessage(info, "areadetect:" + info.ConfigId, list.ToArray());
                    }
                    else if (data.m_TriggerType == AreaDetectLogicInfo.TiggerTypeEnum.User)
                    {
                        ArrayList list = new ArrayList();
                        info.SpatialSystem.VisitObjectInPolygon(data.m_Area, (float distSqr, ArkCrossEngineSpatial.ISpaceObject obj) =>
                        {
                            if (obj.GetObjType() == ArkCrossEngineSpatial.SpatialObjType.kUser)
                            {
                                list.Add((int)obj.GetID());
                            }
                        });
                        OnSceneLogicSendStoryMessage(info, "areadetect:" + info.ConfigId, list.ToArray());
                    }
                }
            }
        }
        public override void Execute(SceneLogicInfo info, long deltaTime)
        {
            if (null == info || info.IsLogicFinished || info.IsLogicPaused)
            {
                return;
            }
            info.Time += deltaTime;
            if (info.Time > 100)
            {
                UserEnterAreaLogicInfo data = info.LogicDatas.GetData <UserEnterAreaLogicInfo>();
                if (null == data)
                {
                    data = new UserEnterAreaLogicInfo();
                    info.LogicDatas.AddData <UserEnterAreaLogicInfo>(data);

                    SceneLogicConfig sc = info.SceneLogicConfig;
                    if (null != sc)
                    {
                        List <float> pts = Converter.ConvertNumericList <float>(sc.m_Params[0]);
                        data.m_Area = new Vector3[pts.Count / 2];
                        for (int ix = 0; ix < pts.Count - 1; ix += 2)
                        {
                            data.m_Area[ix / 2].X = pts[ix];
                            data.m_Area[ix / 2].Z = pts[ix + 1];
                        }
                        data.m_TriggerType = (UserEnterAreaLogicInfo.TiggerTypeEnum) int.Parse(sc.m_Params[1]);
                    }
                }
                info.Time = 0;
                //执行逻辑
                if (null != data && !data.m_IsTriggered)
                {
                    if (data.m_TriggerType == UserEnterAreaLogicInfo.TiggerTypeEnum.All)
                    {
                        int ct = 0;
                        info.SpatialSystem.VisitObjectInPolygon(data.m_Area, (float distSqr, ArkCrossEngineSpatial.ISpaceObject obj) =>
                        {
                            if (obj.GetObjType() == ArkCrossEngineSpatial.SpatialObjType.kUser)
                            {
                                UserInfo user = obj.RealObject as UserInfo;
                                if (HasNoPartnerOrPartnerInArea(user, data.m_Area))
                                {
                                    ++ct;
                                }
                            }
                        });
                        if (ct == info.UserManager.Users.Count)
                        {
                            SceneLogicSendStoryMessage(info, "alluserenterarea:" + info.ConfigId, ct);
                            data.m_IsTriggered = true;
                        }
                    }
                    else
                    {
                        int id = 0;
                        info.SpatialSystem.VisitObjectInPolygon(data.m_Area, (float distSqr, ArkCrossEngineSpatial.ISpaceObject obj) =>
                        {
                            if (obj.GetObjType() == ArkCrossEngineSpatial.SpatialObjType.kUser)
                            {
                                UserInfo user = obj.RealObject as UserInfo;
                                if (HasNoPartnerOrPartnerInArea(user, data.m_Area))
                                {
                                    id = (int)obj.GetID();
                                    return(false);
                                }
                            }
                            return(true);
                        });
                        if (id > 0)
                        {
                            SceneLogicSendStoryMessage(info, "anyuserenterarea:" + info.ConfigId, id);
                            data.m_IsTriggered = true;
                        }
                    }
                }
            }
        }
        public override void Execute(SceneLogicInfo info, long deltaTime)
        {
            if (null == info || info.IsLogicFinished || info.IsLogicPaused)
            {
                return;
            }
            if (null != info)
            {
                info.Time += deltaTime;
                if (info.Time >= 2000)
                {
                    info.Time = 0;
                    RevivePointLogicInfo data = info.LogicDatas.GetData <RevivePointLogicInfo>();
                    //初始化逻辑数据
                    if (null == data)
                    {
                        data = new RevivePointLogicInfo();
                        info.LogicDatas.AddData(data);

                        SceneLogicConfig sc = info.SceneLogicConfig;
                        if (null != sc)
                        {
                            string[] pos = sc.m_Params[0].Split(' ');
                            data.m_Center.X        = float.Parse(pos[0]);
                            data.m_Center.Y        = float.Parse(pos[1]);
                            data.m_Center.Z        = float.Parse(pos[2]);
                            data.m_RadiusOfTrigger = float.Parse(sc.m_Params[1]);
                        }
                    }
                    //执行逻辑
                    if (null != data)
                    {
                        List <ArkCrossEngineSpatial.ISpaceObject> objs = info.SpatialSystem.GetObjectInCircle(data.m_Center, data.m_RadiusOfTrigger);
                        if (null != objs)
                        {
                            for (int i = 0; i < objs.Count; i++)
                            {
                                if (objs[i].GetObjType() == ArkCrossEngineSpatial.SpatialObjType.kUser)
                                {
                                    UserInfo ui = info.UserManager.GetUserInfo((int)objs[i].GetID());
                                    if (null != ui)
                                    {
                                        ui.RevivePoint = data.m_Center;
                                    }
                                }
                            }

                            /*
                             * foreach (DashFireSpatial.ISpaceObject obj in objs) {
                             * if (obj.GetObjType() == DashFireSpatial.SpatialObjType.kUser) {
                             *  UserInfo ui = info.UserManager.GetUserInfo((int)obj.GetID());
                             *  if (null != ui) {
                             *    ui.RevivePoint = data.m_Center;
                             *  }
                             * }
                             * }*/
                        }
                    }
                }
            }
        }