Exemplo n.º 1
0
    public Brain(sMis actor)
    {
        this.actor = actor;

        behaviour.AddVertex(new Node <BehaviourNode>(new Idle(), "Idle"));
        behaviour.AddVertex(new Node <BehaviourNode>(new Die(), "Die"));
        behaviour.AddVertex(new Node <BehaviourNode>(new SearchForHome(), "SearchForHome"));
        behaviour.AddVertex(new Node <BehaviourNode>(new MoveToHouse(), "MoveToHouse"));

        behaviour.AddEdgeCondition("Idle", "Die", delegate(object a)
        {
            return(((sMis)a).hunger >= 100 || ((sMis)a).energy <= 0);
        });
        behaviour.AddEdgeCondition("Idle", "SearchForHome", delegate(object a)
        {
            return(((sMis)a).house == null);
        });
        behaviour.AddEdgeCondition("SearchForHome", "MoveToHouse", delegate(object a)
        {
            return(((sMis)a).house != null);
        });
        behaviour.AddEdgeCondition("MoveToHouse", "MoveToHouse", delegate(object a)
        {
            return(Vector3.Distance(((sMis)a).house.transform.position, ((sMis)a).transform.position) > 0.1f);
        });
        behaviour.AddEdgeCondition("MoveToHouse", "Idle", delegate(object a)
        {
            return(Vector3.Distance(((sMis)a).house.transform.position, ((sMis)a).transform.position) <= 0.1f);
        });

        behaviour.AddEdgeCondition("Idle", "Idle", delegate(object a) { return(true); });

        currentAction = "Idle";
    }
Exemplo n.º 2
0
    public override void Action(sMis actor)
    {
        House house = GameManager.Instance.GetRandomHouse();

        while (house.residents.Count > 0)
        {
            house = GameManager.Instance.GetRandomHouse();
        }

        actor.house = house;
    }
Exemplo n.º 3
0
 public abstract void Action(sMis actor);
Exemplo n.º 4
0
    public override void Action(sMis actor)
    {
        Vector3 direction = actor.house.transform.position - actor.transform.position;

        actor.transform.Translate(direction.normalized * 70.0f * Time.deltaTime);
    }
Exemplo n.º 5
0
Arquivo: Die.cs Projeto: ChepChaf/sMis
 public override void Action(sMis actor)
 {
     GameManager.Instance.RemoveSMis(actor.gameObject);
     GameObject.Destroy(actor.gameObject);
 }
Exemplo n.º 6
0
 public override void Action(sMis actor)
 {
     actor.hunger += Random.Range(0, 4);
     actor.energy -= Random.Range(0, 4);
 }