Пример #1
0
    public void AddSwitchCommandTable(behaviac.Agent agent, string relativePath)
    {
        if (agent == null || m_SwitchTreeCommandTable.ContainsKey(agent.GetId()))
        {
            return;
        }

        m_SwitchTreeCommandTable.Add(agent.GetId(), relativePath);

        LogFormat(agent, $"AddSwitchCommandTable relativePath:{relativePath}");
    }
Пример #2
0
    public void RemoveAgent(behaviac.Agent agent)
    {
        if (agent == null)
        {
            return;
        }

        if (m_AgentTable.ContainsKey(agent.GetId()))
        {
            m_AgentTable.Remove(agent.GetId());
        }
    }
Пример #3
0
    /// <summary>
    /// 添加Agent
    /// </summary>
    /// <param name="agent"></param>
    public void AddAgent(behaviac.Agent agent)
    {
        if (agent == null)
        {
            return;
        }

        if (m_AgentTable.ContainsKey(agent.GetId()))
        {
            return;
        }

        m_AgentTable.Add(agent.GetId(), agent);
    }
Пример #4
0
        public void AddAgent(Agent pAgent)
        {
            int id       = pAgent.GetId();
            int priority = pAgent.GetPriority();
            int num      = -1;

            for (int i = 0; i < this.Agents.get_Count(); i++)
            {
                if (this.Agents.get_Item(i).priority == priority)
                {
                    num = i;
                    break;
                }
            }
            if (num == -1)
            {
                World.HeapItem_t heapItem_t = default(World.HeapItem_t);
                heapItem_t.agents   = new DictionaryView <int, Agent>();
                heapItem_t.priority = priority;
                heapItem_t.agents.set_Item(id, pAgent);
                this.Agents.Add(heapItem_t);
            }
            else
            {
                this.Agents.get_Item(num).agents.set_Item(id, pAgent);
            }
        }
Пример #5
0
        public void AddAgent(Agent pAgent)
        {
            int id       = pAgent.GetId();
            int priority = pAgent.GetPriority();
            int num3     = -1;

            for (int i = 0; i < this.Agents.Count; i++)
            {
                HeapItem_t _t2 = this.Agents[i];
                if (_t2.priority == priority)
                {
                    num3 = i;
                    break;
                }
            }
            if (num3 == -1)
            {
                HeapItem_t item = new HeapItem_t {
                    agents   = new DictionaryView <int, Agent>(),
                    priority = priority
                };
                item.agents[id] = pAgent;
                this.Agents.Add(item);
            }
            else
            {
                HeapItem_t _t3 = this.Agents[num3];
                _t3.agents[id] = pAgent;
            }
        }
Пример #6
0
        public void RemoveAgent(Agent pAgent)
        {
            int id       = pAgent.GetId();
            int priority = pAgent.GetPriority();
            int num3     = -1;

            for (int i = 0; i < this.Agents.Count; i++)
            {
                HeapItem_t _t = this.Agents[i];
                if (_t.priority == priority)
                {
                    num3 = i;
                    break;
                }
            }
            if (num3 != -1)
            {
                HeapItem_t _t2 = this.Agents[num3];
                if (_t2.agents.ContainsKey(id))
                {
                    HeapItem_t _t3 = this.Agents[num3];
                    _t3.agents.Remove(id);
                }
            }
        }
Пример #7
0
    public void AddTask(behaviac.Agent agent, BehaviorTaskData behaviorTaskData)
    {
        if (agent == null)
        {
            return;
        }

        m_TaskTable.Add(agent.GetId(), behaviorTaskData);
    }
Пример #8
0
        public void RemoveAgent(Agent pAgent)
        {
            //ASSERT_MAIN_THREAD();

            int agentId   = pAgent.GetId();
            int priority  = pAgent.GetPriority();
            int itemIndex = this.Agents.FindIndex(delegate(HeapItem_t h) { return(h.priority == priority); });

            if (itemIndex != -1)
            {
                if (this.Agents[itemIndex].agents.ContainsKey(agentId))
                {
                    this.Agents[itemIndex].agents.Remove(agentId);
                }
            }
        }
Пример #9
0
        private void removeAgent_(Agent pAgent)
        {
            int agentId   = pAgent.GetId();
            int priority  = pAgent.GetPriority();
            int itemIndex = this.Agents.FindIndex(delegate(HeapItem_t h)
            {
                return(h.priority == priority);
            });

            if (itemIndex != -1)
            {
                if (this.Agents[itemIndex].agents.ContainsKey(agentId))
                {
                    this.Agents[itemIndex].agents.Remove(agentId);
                }
            }
        }
Пример #10
0
        public void RemoveAgent(Agent pAgent)
        {
            int id       = pAgent.GetId();
            int priority = pAgent.GetPriority();
            int num      = -1;

            for (int i = 0; i < this.Agents.get_Count(); i++)
            {
                if (this.Agents.get_Item(i).priority == priority)
                {
                    num = i;
                    break;
                }
            }
            if (num != -1 && this.Agents.get_Item(num).agents.ContainsKey(id))
            {
                this.Agents.get_Item(num).agents.Remove(id);
            }
        }
Пример #11
0
        public void AddAgent(Agent pAgent)
        {
            //ASSERT_MAIN_THREAD();
            int agentId   = pAgent.GetId();
            int priority  = pAgent.GetPriority();
            int itemIndex = this.Agents.FindIndex(delegate(HeapItem_t h) { return(h.priority == priority); });

            if (itemIndex == -1)
            {
                HeapItem_t pa = new HeapItem_t();
                pa.agents          = new Dictionary <int, Agent>();
                pa.priority        = priority;
                pa.agents[agentId] = pAgent;
                this.Agents.Add(pa);
            }
            else
            {
                this.Agents[itemIndex].agents[agentId] = pAgent;
            }
        }
Пример #12
0
        virtual protected System.IO.StreamWriter GetFile(Agent pAgent)
        {
#if !BEHAVIAC_RELEASE
            if (Config.IsLogging)
            {
                System.IO.StreamWriter fp = null;
                if (pAgent == null)
                {
                    return(null);
                }

                int agentId = pAgent.GetId();
                //int agentId = -1;

                if (!m_logs.ContainsKey(agentId))
                {
                    string buffer;

                    if (string.IsNullOrEmpty(m_logFilePath))
                    {
                        if (agentId == -1)
                        {
                            buffer = "_behaviac_$_.log";
                        }
                        else
                        {
                            //buffer = string.Format("Agent_$_{0:3}.log", agentId);
                            if (!Directory.Exists("./behaviac_log"))
                            {
                                Directory.CreateDirectory("./behaviac_log");
                            }
                            buffer = string.Format("./behaviac_log/Agent_{0}_{1}.log", agentId, pAgent.CustomName);
                        }

#if !BEHAVIAC_NOT_USE_UNITY
                        if (UnityEngine.Application.platform != UnityEngine.RuntimePlatform.WindowsEditor &&
                            UnityEngine.Application.platform != UnityEngine.RuntimePlatform.WindowsPlayer)
                        {
                            buffer = Path.Combine(UnityEngine.Application.persistentDataPath, buffer);
                        }
#endif
                    }
                    else
                    {
                        buffer = m_logFilePath;
                    }

                    fp = new System.IO.StreamWriter(buffer);

                    m_logs[agentId] = fp;
                }
                else
                {
                    fp = m_logs[agentId];
                }

                return(fp);
            }
#endif
            return(null);
        }