Ejemplo n.º 1
0
 public void AddTrigger(TriggerInstance trigger)
 {
     if (GetTrigger(trigger.TriggerData.id) == null)
     {
         mTriggerDictionary[trigger.TriggerData.id] = trigger;
     }
 }
Ejemplo n.º 2
0
        public override bool OnTransport(NPCInstance npc)
        {
            if (null == npc)
            {
                return(false);
            }

            if (npc.IsMoving)
            {
                return(false);
            }

            TriggerInstance trigger = npc.HostMap.InTriggerRange(npc);

            if (null == trigger)
            {
                npc.ChangeState(eNPCState.Pause);
                mPathNodes.CleanUp();
                npc.OnLeaveMap();
            }
            else
            {
                if (!mPathNodes.NextTargetPos())
                {
                    npc.ChangeState(eNPCState.Pause);
                    return(false);
                }

                npc.Trigger = trigger;
                npc.OnJumpToMap();
                npc.ChangeState(eNPCState.WaitJumpMap);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public virtual void OnInit()
        {
            foreach (var NpcData in mMapInfo.MapDetail.NpcList)
            {
                try
                {
                    var tplNpc = CSTable.StaticDataManager.NPCTpl[NpcData.tid];
                    if (tplNpc.type == (int)CSCommon.eNpcType.FoodCar || tplNpc.type == (int)CSCommon.eNpcType.MoneyCar)
                    {
                        continue;
                    }

                    NPCInstance.CreateNPCInstance(NpcData, this);
                }
                catch (System.Exception ex)
                {
                    Log.Log.Server.Warning("CreateNPCInstance Error,id={0}", NpcData.tid);
                }
            }

            foreach (var portal in mMapInfo.MapDetail.PortalList)
            {
                try
                {
                    var p = TriggerInstance.CreateTriggerInstance(portal, this);
                    if (null == p)
                    {
                        continue;
                    }

                    AddTrigger(p);
                }
                catch (System.Exception ex)
                {
                    Log.Log.Server.Warning("CreateTriggerInstance Error,id={0}", portal.id);
                }
            }

            foreach (var path in mMapInfo.MapDetail.PathList)
            {
                foreach (var node in path.PatrolNodeList)
                {
                    try
                    {
                        var p = WayPoint.CreateWayPoint(node, this);
                        if (null == p)
                        {
                            continue;
                        }

                        AddWayPoint(path.id, p);
                    }
                    catch (System.Exception ex)
                    {
                        Log.Log.Server.Warning("CreateWayPoint Error,pathId={0},nodeId={1}", path.id, node.id);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static TriggerInstance CreateTriggerInstance(MapInfo_Portal td, MapInstance map)
        {
            if (td == null)
            {
                return(null);
            }

            TriggerInstance ret = new TriggerInstance();

            //ret.mInstId = ServerFrame.Util.GenerateObjID(ServerFrame.GameObjectType.Trigger);
            var init = new TriggerInit();

            init.GameType   = eActorGameType.Potal;
            init.PortalDate = td;
            ret.Initialize(init);
            ret.OnEnterMap(map);

            return(ret);
        }
Ejemplo n.º 5
0
        public bool MapTriggerGuid2UInt32(TriggerInstance role)
        {
            if (role.SingleId != 0)
            {
                return(false);
            }
            TriggerInstance temp;

            if (mTableTriggers.TryGetValue(role.Id, out temp))
            {
                return(false);
            }
            UInt32 singleId = 0;

            for (int count = 0; count < (UInt32)EIdIndexInfo.MaxTriggerInPlanes; count++)
            {
                if (mSingeIdTriggers.TryGetValue(mNextTriggerId, out temp) == false)
                {
                    singleId = mNextTriggerId;
                    mNextTriggerId++;
                    break;
                }
                else
                {
                    ++mNextTriggerId;
                    if (mNextTriggerId >= (UInt32)EIdIndexInfo.TriggerEnd)
                    {
                        mNextTriggerId = (UInt32)EIdIndexInfo.TriggerStart;
                    }
                }
            }

            if (singleId == 0)
            {
                return(false);
            }
            role._SetSingleId(singleId);
            mTableTriggers.Add(role.Id, role);
            mSingeIdTriggers.Add(singleId, role);
            return(true);
        }
Ejemplo n.º 6
0
 public void RemoveTrigger(TriggerInstance trigger)
 {
     mTriggerDictionary.Remove(trigger.TriggerData.id);
 }
Ejemplo n.º 7
0
 public void UnmapTriggerGuid2UInt32(TriggerInstance role)
 {
     mTableTriggers.Remove(role.Id);
     mSingeIdTriggers.Remove(role.SingleId);
     role._SetSingleId(0);
 }