public void Start()
    {
        GrabSettings();

        rb       = GetComponent <Rigidbody>();
        simCtrl  = GetComponent <SimInstantiator>();
        worldMap = FindObjectOfType <SimulationMap>();
        InvokeRepeating("CalcNeighbors", neighborCalcFreq, neighborCalcFreq);
        InvokeRepeating("Drift", villageNumber / 100f, driftFreq);

        Vector3 scale = gameObject.transform.localScale;

        for (int i = 0; i < population; i++)
        {
            // Make a new agent.
            GameObject clone     = Instantiate(agentPrefab);
            AgentCtrl  cloneCtrl = clone.GetComponent <AgentCtrl>();
            agents.Add(cloneCtrl);
            cloneCtrl.SetHome(this);

            // Set the agent moving along a random direction.
            Rigidbody cloneRB = clone.GetComponent <Rigidbody>();
            cloneRB.velocity = new Vector3(Random.Range(0f, 100f), 0f, Random.Range(0f, 100f));

            // Put the agent somewhere in the village.
            float rndX = Random.Range(-scale.x / 2f, +scale.x / 2f);
            float rndZ = Random.Range(-scale.z / 2f, +scale.z / 2f);
            rndX += gameObject.transform.position.x;
            rndZ += gameObject.transform.position.z;
            clone.transform.position = new Vector3(rndX, 1f, rndZ);    // 1 so agents aren't spawned inside the ground
        }
    }
        public string AddAgent(string agentId, string agentPwd, string agentPhone, string agentName, string agentAddress, int agentGrade, string agentIdCard,
                               string agentNumber, string agentEmail, string agentQq, string remark, int serviceType)
        {
            AgentModel model = new AgentModel();

            model.AgentId       = agentId;
            model.AgentPassword = CommonLib.Helper.Md5Hash(agentPwd);
            model.AgentPhone    = agentPhone;
            model.AgentName     = agentName;
            model.AgentAddress  = agentAddress;
            model.AgentGrade    = agentGrade;
            model.AgentIdCard   = agentIdCard;
            model.AgentNumber   = agentNumber;
            model.AgentEmail    = agentEmail;
            model.AgentQQ       = agentQq;
            model.Remark        = remark;
            model.ServiceType   = serviceType;

            ManageUserModel uM = (ManageUserModel)Session["logUser"];

            if (uM != null)
            {
                model.Creater = uM.Name;
            }

            model.AgentLink = "http://app.i200.cn/LoginReg/Registration.aspx?ag=";
            //舍弃加密方式的代理商编码
            //model.AgentLink += (new Class_Password()).EnCode(agentId);
            model.AgentLink += agentId;

            return(AgentCtrl.AddAgent(model));
        }
Beispiel #3
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "agent")
        {
            AgentCtrl stranger = collision.gameObject.GetComponent <AgentCtrl>();
            foreach (Phoneme phone in RndWord())
            {
                float hisPoununciation = stranger.GetPronunciation(phone);
                float ourPronunciation = idiolect[phone];

                if (hisPoununciation > ourPronunciation)
                {
                    idiolect[phone] = ourPronunciation + speechPlasticity;
                }
                else
                {
                    idiolect[phone] = ourPronunciation - speechPlasticity;
                }

                //if (ourPronunciation > 0.90)
                //    Debug.Log("Phoneme mutation should go here.");

                if (speechBubbleOn)
                {
                    GameObject bubble = Instantiate(speechBubble);
                    Vector3    pos    = gameObject.transform.position;
                    pos.y = 10f;
                    bubble.transform.position = pos;
                }
            }
        }
    }
    public void DisplayVillageLanguage(VillageCtrl villageCtrl)
    {
        AgentCtrl agent = villageCtrl.agents[0];
        string    s     = "";
        bool      odd   = true;

        foreach (Phoneme phone in agent.idiolect.Keys)
        {
            float f = villageCtrl.AvgPronunciation(phone);

            s += string.Format("{0} : {1:0.00}\t\t", phone.glyph, f);

            odd = !odd;
            if (odd)
            {
                s += "\n";
            }
        }

        langTxt.text = s;
    }
 public string GetAgentStat(string stTime, string edTime, string columns)
 {
     string[] cs = columns.Split(',');
     return(AgentCtrl.GetAgentStat(stTime, edTime, cs));
 }
 public string ChangeGroup(int curStat, int id)
 {
     return(AgentCtrl.ChangeGroup(curStat, id));
 }
 public string ChangeStatus(int curStat, int id)
 {
     return(AgentCtrl.ChangeStatus(curStat, id));
 }
 public string GetRandomNum()
 {
     return(AgentCtrl.GetRandomNum());
 }
 public string GetAgentList(int pageIndex)
 {
     return(AgentCtrl.GetAgentList(pageIndex));
 }
 public string ModifyAgentInfo(AgentModel model)
 {
     return(AgentCtrl.ModifyAgentInfo(model));
 }
 public string GetSingleModel(int id)
 {
     return(CommonLib.Helper.JsonSerializeObject(AgentCtrl.GetSingleModel(id)));
 }
        public ActionResult AgentDetail(int id)
        {
            AgentModel model = AgentCtrl.GetSingleModel(id);

            return(View(model));
        }
 /// <summary>
 /// 产生并校验代理商编码
 /// </summary>
 /// <param name="agentName"></param>
 /// <returns></returns>
 public string CheckAndAutoGeneratedCode(string agentName)
 {
     return(AgentCtrl.CheckAndAutoGeneratedCode(agentName));
 }
Beispiel #14
0
    public void PopulatePhonemeOrder()
    {
        AgentCtrl agent = villages[0].agents[0];

        phonemeOrder = agent.idiolect.Keys.ToArray();
    }