Exemplo n.º 1
0
    public override void Execute(IODAAgent source, IODAAgent target)
    {
        //Get Energy from corpse
        AnimalAgent b = target.GetComponent<AnimalAgent>();
        AnimalAgent a = source.GetComponent<AnimalAgent>();

        //if (a.timerHolder.ConsumeToken("attack"))
        //{
            //fight result calculator
            float fightResult = FightCalculator(a, b);
            if (fightResult >= 0.0f)
            {
                b.RemoveToValue(EvolutionNames.AgentSelf.Health,fightResult);
                //b.health = b.health - fightResult;
            }
            else
            {
                b.RemoveToValue(EvolutionNames.AgentSelf.Health,fightResult);
                a.AddToValue(EvolutionNames.AgentSelf.Health,fightResult);
                //a.health = a.health + fightResult;
            }
            a.gameObject.transform.LookAt(b.gameObject.transform);

            a.GetAAC().fightAnimation();

            //Debug.Log(source.ToString() + " fight and deals (" + fightResult + ") dmg");

        //}
    }
Exemplo n.º 2
0
 public override void Execute(IODAAgent source, IODAAgent target)
 {
     source.SetDebug("Wiggle");
     AnimalAgent agent = source.GetComponent<AnimalAgent>() as AnimalAgent;
     agent.Wiggle();
     //Debug.Log("Wiggle");
 }
Exemplo n.º 3
0
 public override void Execute(IODAAgent source, IODAAgent target)
 {
     //Get Energy from berries
     Berry b = target.GetComponent<Berry>();
     //Debug.Log(source.ToString() + " eats a berry (+" + target.GetComponent<EvolutionAgent>().energy +")");
     //b.energy += b.energy;
 }
Exemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     Debug.Assert(player != null);
     playerAgent = player.GetComponent<IODA.IODAAgent>();
     Debug.Assert(playerAgent != null);
 }
Exemplo n.º 5
0
 public void Start()
 {
     ioda = GetComponent<IODA.IODAAgent> ();
     if (timerHolder == null) {
         timerHolder = gameObject.AddComponent<TimerHolder> ();
         timerHolder.Prepare();
     }
 }
Exemplo n.º 6
0
 public override void Execute(IODAAgent source, IODAAgent target)
 {
     source.SetDebug("GrowPlant");
         PlantAgent plant = (PlantAgent)source.GetComponent<PlantAgent>();
         if (!plant.IsMature())
         {
             plant.Grow(Time.deltaTime, Time.timeScale);
         }
 }
Exemplo n.º 7
0
    public override void Execute(IODAAgent source, IODAAgent target)
    {
        source.SetDebug("EatCorpse");
        //Get Energy from corpse
        CorpseAgent b = target.GetComponent<CorpseAgent>();
        AnimalAgent a = source.GetComponent<AnimalAgent>();

        a.GetAAC().eatingAnimation();

        a.AddToValue(EvolutionNames.AgentSelf.Energy,b.Take());
        //Debug.Log(source.ToString() + " eats a corpse (+" + b.reserve + ")");
    }
Exemplo n.º 8
0
 public override bool IsTriggered(IODAAgent source, IODAAgent target)
 {
     AnimalAgent agent = source.GetComponent<AnimalAgent>() as AnimalAgent;
     if (agent.GetEnergy() < agent.GetEnergyMaximum() / 2)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Exemplo n.º 9
0
    public override bool IsValid(IODAAgent source, IODAAgent target)
    {
        //target exists and is a bush
        if (target == null)
            return false;

        Berry b = target.GetComponent<Berry>();
        if(b == null)
            return false;

        if(distance!= -1 && source.DistanceTo(target) < distance)
                return true;

        return false;
    }
Exemplo n.º 10
0
    public override bool IsValid(IODAAgent source, IODAAgent target)
    {
        //target exists and is a bush
        if (target == null)
            return false;

        CorpseAgent b = target.GetComponent<CorpseAgent>();
        if (b == null)
            return false;

        if (source.DistanceTo(target) > distance)
            return false;

        return true;
    }
Exemplo n.º 11
0
    public override bool IsValid(IODAAgent source, IODAAgent target)
    {
        //target exists and is a Animal and animal is carnivore
        if (target == null)
            return false;

        AnimalAgent b = target.GetComponent<AnimalAgent>();
        if (b == null || !source.GetComponent<AnimalAgent>().IsCarnivore())
            return false;
        //distance to fight
        if (source.DistanceTo(target) > distance)
            return false;

        return true;
    }
Exemplo n.º 12
0
    public override void Execute(IODAAgent source, IODAAgent target)
    {
        source.SetDebug("SeekFood");
        //GameObject.FindGameObjectWithTag("GameController").GetComponent<QuestManager>().SendMessage("EventListner", "fight");
        AnimalAgent agent = source.GetComponent<AnimalAgent>() as AnimalAgent;
        if (agent != null)
        {
            List<EvolutionAgent> percepts = agent.GetPerceptGetter().GetPercepts();
            EvolutionAgent foundTarget = null;
            if (agent.IsCarnivore())
            {
                foundTarget = SeekCorpse(agent, percepts);
                if (!foundTarget)
                {
                    foundTarget = SeekAnimal(agent, percepts);
                }
            }
            else
            {
                foundTarget = SeekBush(agent, percepts);
            }

            if (null != foundTarget)
            {
                source.target = foundTarget.GetComponent<IODAAgent>();
                source.SetDebug("SeekFood-Found");
            }
            else
            {
                source.target = null;
                source.SetDebug("SeekFood-Not found");

            }

            if (null != source.target)
            {
                source.SetDebug("SeekFood-MoveToward");
                agent.MoveTowards(source.target.GetComponent<EvolutionAgent>());
            }
            else
            {
                agent.Wiggle();
                source.SetDebug("SeekFood-Wiggle");

            }
        }
    }
Exemplo n.º 13
0
    public override void Execute(IODAAgent source, IODAAgent target)
    {
        source.SetDebug("EatBush");
        //Get Energy from berries
        Bush b = target.GetComponent<Bush>();
        AnimalAgent a = source.GetComponent<AnimalAgent>();

        if (b.IsMature())
        {
            a.GetAAC().eatingAnimation();
            a.AddToValue(EvolutionNames.AgentSelf.Energy, b.Take());
            //a.RemoveBush(target.gameObject);
            //Debug.Log(source.ToString() + " eats a bush (+" + b.growMax + ")");
        }
        else
        {
            source.target = null;
        }
    }
Exemplo n.º 14
0
 public override void Execute(IODAAgent source, IODAAgent target)
 {
     //Debug.Log("MoveTo");
     //source.gameObject.GetComponent<N>
 }
Exemplo n.º 15
0
 public abstract bool IsValid(IODAAgent source, IODAAgent target);
Exemplo n.º 16
0
 public abstract bool IsTriggered(IODAAgent source, IODAAgent target);
Exemplo n.º 17
0
 public abstract void Execute(IODAAgent source, IODAAgent target);
Exemplo n.º 18
0
 public override bool IsTriggered(IODAAgent source, IODAAgent target)
 {
     //Berries are mature
     Bush b = target.GetComponent<Bush>();
     return b.IsMature();
 }
Exemplo n.º 19
0
 public static float DistanceBetween(IODAAgent source, IODAAgent target)
 {
     return Vector3.Distance(source.transform.position, target.gameObject.transform.position);
 }
Exemplo n.º 20
0
 public float DistanceTo(IODAAgent target)
 {
     return DistanceBetween(this, target);
 }
Exemplo n.º 21
0
 public override bool IsTriggered(IODAAgent source, IODAAgent target)
 {
     //Berries are mature
     Berry b = target.GetComponent<Berry>();
     return b != null && b.IsMature();
 }
Exemplo n.º 22
0
 public override bool IsTriggered(IODAAgent source, IODAAgent target)
 {
     return true;
 }
Exemplo n.º 23
0
 public override bool IsValid(IODAAgent source, IODAAgent target)
 {
     PlantAgent pa = source.GetComponent<PlantAgent>();
         return pa != null;
 }
Exemplo n.º 24
0
 public override bool IsValid(IODAAgent source, IODAAgent target)
 {
     return true;
 }
Exemplo n.º 25
0
 public override bool IsValid(IODAAgent source, IODAAgent target)
 {
     AnimalAgent aa = source.GetComponent<AnimalAgent>() as AnimalAgent;
     return aa != null;
 }