Exemplo n.º 1
0
    private void CreateAgents()
    {
        List <PlayAgent> agentList = new List <PlayAgent>();

        for (int i = 0; i < maxAgentNums; i++)
        {
            GameObject agentprefab = Resources.Load <GameObject>("prefabs/Agent");

            if (null == agentprefab)
            {
                continue;
            }

            GameObject agent = Instantiate <GameObject>(agentprefab);

            if (null == agent)
            {
                continue;
            }

            agent.name = string.Format("Agent{0}", i + 1);

            if (null != AgentMangerTrans)
            {
                agent.transform.SetParent(AgentMangerTrans);
            }

            PlayAgent agentIns = agent.GetComponent <PlayAgent>();

            if (null != agentIns)
            {
                agentIns.Initialize();
                agentIns.Init(i);
                agentList.Add(agentIns);
            }
        }

        if (null != agentManager)
        {
            agentManager.InitAgents(agentList);
        }

        ObservationManager.Instance.InitAgents(agentList);
    }
Exemplo n.º 2
0
    public List <float> GetObjectInfo(PlayAgent obj)
    {
        List <float> curInfo = new List <float>();

        if (!obj.IsActive)
        {
            curInfo.Add(1);
            curInfo.Add(0);
            curInfo.Add(0);
            curInfo.Add(0);
            curInfo.Add(0);

            return(curInfo);
        }

        if (obj.Type == Entity.Entity_Type.AGENT)
        {
            curInfo.Add(1);
            curInfo.Add(1);
            curInfo.Add(0);
        }
        else
        {
            curInfo.Add(1);
            curInfo.Add(0);
            curInfo.Add(1);
        }

        float posX = obj.Trans.position.x;
        float posZ = obj.Trans.position.z;

        curInfo.Add(posX / map_size);
        curInfo.Add(posZ / map_size);

        return(curInfo);
    }