Ejemplo n.º 1
0
        private void MsgCallBack(MsgInformationEx MsgDTO)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    var bindAi = RestrictorSvc.AllocateBindAi(MsgDTO);
                    IEnumerable <AIBase> groups;
                    if (string.IsNullOrEmpty(bindAi))
                    {
                        groups = AIGroup.Where(p => (int)p.PriorityLevel >= (int)AIPriority.System);
                    }
                    else
                    {
                        MsgDTO.BindAi = bindAi;
                        groups        = AIGroup;
                    }

                    foreach (var ai in groups)
                    {
                        if (ai.OnMsgReceived(MsgDTO))
                        {
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                }
            });
        }
Ejemplo n.º 2
0
    public AIGroup GetAIGroup(string id)
    {
        int key = CRC32.GetHashForAnsi(id);

        AIGroup aiGroup = null;

        m_aiGroup.TryGetValue(key, out aiGroup);

        return(aiGroup);
    }
Ejemplo n.º 3
0
        public override NPC SpawnMinion(NPCEntry entry, ref Vector3 position, int durationMillis)
        {
            var minion = base.SpawnMinion(entry, ref position, durationMillis);

            if (Group == null)
            {
                Group = new AIGroup(this);
            }
            Group.Add(minion);
            return(minion);
        }
Ejemplo n.º 4
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="teamId"></param>
    /// <param name="agent"></param>
    public void AddAgent(string teamId, AIAgent agent)
    {
        int key = CRC32.GetHashForAnsi(teamId);

        AIGroup group = null;

        if (!m_aiGroup.TryGetValue(key, out group))
        {
            m_aiGroup.Add(key, new AIGroup(teamId));
        }

        RemoveAgent(agent);
        m_aiGroup[key].AddAgent(agent);
    }
Ejemplo n.º 5
0
 public void OnGroupChange(AIGroup newGroup)
 {
     //if (newGroup != null)
     //{
     //    // now in new/different group
     //    DefaultState = newGroup.DefaultState;
     //    EnterDefaultState();
     //}
     //else
     //{
     //    // left Group
     //    DefaultState = DefaultBrainState;
     //    if (m_currentAction != null && m_currentAction.IsGroupAction)
     //    {
     //        m_currentAction.Stop();
     //        EnterDefaultState();
     //    }
     //}
 }
Ejemplo n.º 6
0
    public void SetCrosshair(Vector3 p, string id = "basic")
    {
        Vector3 ProposedPosition = p;

        //make sure it's not inside an obstacle
        for (int i = 0; i < m_Obstacles.Count; ++i)
        {
            AIObject curOb = m_Obstacles[i];
            if (MathUtil.PointInCircle(curOb.VPos(), curOb.BRadius(), ProposedPosition))
            {
                return;
            }
        }

        AIGroup aiGroup = GetAIGroup(id);

        if (aiGroup != null)
        {
            aiGroup.SetCrosshair(p);
        }
    }
Ejemplo n.º 7
0
        /// <summary>
        /// 加载世界线
        /// </summary>
        public void Load()
        {
            Logger.Log($"{Name} WorldLine is starting up...");

            try
            {
                AIGroup = AIGroup.Where(a => a != null && a.Enable).OrderByDescending(a => a.PriorityLevel).ToList();
                var count = AIGroup.Count;

                Logger.Log("AI 加载中...");
                for (var i = 0; i < AIGroup.Count; i++)
                {
                    AIGroup[i].Initialization();

                    Logger.Log($"{AIGroup[i].AIName}({i + 1}/{count})");
                }
                CmdTag.CreateCmdTree(CmdTagTree, AllAvailableGroupCommands);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
Ejemplo n.º 8
0
 public NPCSpawnPool(Map map, NPCSpawnPoolTemplate templ)
     : base(map, templ)
 {
     AIGroup = new AIGroup();
 }
Ejemplo n.º 9
0
 public T AIInstance <T>() where T : AIBase
 {
     return(AIGroup.FirstOrDefault(ai => ai.GetType().Name == typeof(T).Name) as T);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 群成员变动事件
 /// </summary>
 /// <param name="model"></param>
 public void OnGroupMemberChanged(GroupMemberChangeModel model)
 {
     if (AIGroup.Any(ai => ai.OnGroupMemberChanged(model)))
     {
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 收款到账事件
 /// </summary>
 /// <param name="model"></param>
 public void OnMoneyReceived(ChargeModel model)
 {
     if (AIGroup.Any(ai => ai.OnMoneyReceived(model)))
     {
     }
 }
Ejemplo n.º 12
0
 public void OnGroupChange(AIGroup newGroup)
 {
 }
Ejemplo n.º 13
0
 public void CreateGroup()
 {
     Group = new AIGroup(Owner);
 }
Ejemplo n.º 14
0
 public void SetAIGroup(AIGroup aiGroup)
 {
     m_aiGroup = aiGroup;
 }