Exemplo n.º 1
0
    public void SetResetParameters()
    {
        biggestSize         = 1;
        totalSize           = 1;
        transform.position += new Vector3(Random.Range(-fightAreaCom.range, fightAreaCom.range), 1f,
                                          Random.Range(-fightAreaCom.range, fightAreaCom.range)) + myArea.transform.position;
        ClearAllSubAgent();

        GameObject sub = Instantiate <GameObject>(subAgentPrb);

        sub.transform.position = transform.position;
        sub.transform.SetParent(transform);
        SubAgent subAgent = sub.GetComponent <SubAgent>();

        subAgent.OnCreated(1, 2, this);
        m_subAgents.Add(subAgent);
    }
Exemplo n.º 2
0
    void OnCollisionEnter(Collision collision)
    {
        GameObject hitObj   = collision.gameObject;
        SubAgent   hitAgent = hitObj.GetComponent <SubAgent>();

        if (hitObj.CompareTag("food"))
        {
            parent.AddReward(0.3f);
            hitObj.GetComponent <FoodCreaetLogic>().OnEaten();
        }

        if (hitObj.CompareTag("wall"))
        {
            parent.AddReward(-0.5f);
            parent.LoseChild(this);
        }

        if (hitObj.CompareTag("agent"))
        {
            if (hitAgent.parent != parent)
            {
                if (childSize < hitAgent.childSize)
                {
                    OnEaten(true);
                }
                else if (childSize > hitAgent.childSize)
                {
                    parent.AddReward(1);
                    Grow(hitAgent.childSize);
                }
            }
            else
            {
                if (childSize > hitAgent.childSize)
                {
                    hitAgent.OnEaten(false);
                    Grow(hitAgent.childSize);
                }
            }
        }
    }
 public void Edit(SubAgent agent)
 {
     this._dBContext.Attach(agent);
     this._dBContext.Entry(agent).State = EntityState.Modified;
 }
 public void Delete(SubAgent agent)
 {
     this._dBContext.Remove(agent);
 }
 public void Add(SubAgent agent)
 {
     this._dBContext.Add(agent);
 }