Beispiel #1
0
 void Start()
 {
     myState = BehaviorState.idle;
     stateMachine = gameObject.GetComponent<AnimalStateMachine>();
     animalMap = GameObject.FindGameObjectWithTag("Map").GetComponent<AnimalMap>();
     body = gameObject.GetComponent<FlyingAnimalBody>();
     sensory = gameObject.GetComponent<AnimalSensory>();
 }
Beispiel #2
0
    public override void Consume(AnimalStateMachine consumer, bool witherResource)
    {
        consumer.nutrition += nutritionValue;
        consumer.nutrition = Mathf.Clamp (consumer.nutrition, 0, consumer.maximumNutrition);
        isGrown = false;
        regrowTimer = 0f;

        isWithered = witherResource;
    }
    public void InitializeMe()
    {
        sensory = gameObject.GetComponent<AnimalSensory>();
        body = gameObject.GetComponent<AnimalBody>();
        brain = gameObject.GetComponent<AnimalBrain>();
        stateMachine = gameObject.GetComponent<AnimalStateMachine>();
        possesor = GameObject.FindGameObjectWithTag("Player").GetComponent<PhantomController>();
        moveSpeed = body.moveSpeed;
        isInitialized = true;

        if(stateMachine.myType == AnimalType.prairieDog)
            jumpController = gameObject.GetComponent<JumpController>();
    }
    void CheckForCreature()
    {
        RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up, 0.5f, faunaMask.value);
        potentialFauna = gameObject;
        if(hit.transform != null)
            potentialFauna = hit.transform.gameObject;

        if(!isPossessing && !isFollowing && Input.GetKey (KeyCode.Q) && potentialFauna.CompareTag("Fauna"))
        {
            possessedCreature = potentialFauna;
            stateMachine = possessedCreature.GetComponent<AnimalStateMachine>();
            animalController = possessedCreature.GetComponent<PossesionController>();
            animalController.enabled = true;
            isPossessing = true;
        }

        if(!isPossessing && !isFollowing && Input.GetKey (KeyCode.W) && potentialFauna.CompareTag("Fauna"))
        {
            possessedCreature = potentialFauna;
            transform.position = potentialFauna.transform.position;
            renderer.enabled = false;
            isFollowing = true;
        }
    }
Beispiel #5
0
 public virtual void Stash(AnimalStateMachine consumer)
 {
     //Whatever happens when an animal decides to bring me home. Only meaningful for food.
 }
Beispiel #6
0
 public virtual void Consume(AnimalStateMachine consumer, bool witherResource)
 {
     //Whatever happens when I'm eaten
 }
 public override void Consume(AnimalStateMachine consumer, bool witherResource)
 {
     consumer.hydration += hydrationValue;
     consumer.hydration = Mathf.Clamp (consumer.hydration, 0, consumer.maximumHydration);
     drinksRemaining--;
 }
 public override void Stash(AnimalStateMachine consumer)
 {
     Debug.Log ("Uh, a prairie Dog is trying to stash an already stored piece of food");
 }
Beispiel #9
0
 void Start()
 {
     myState = BehaviorState.idle;
     stateMachine = gameObject.GetComponent<AnimalStateMachine>();
     animator = gameObject.transform.FindChild("AnimatedChild").gameObject.GetComponent<Animator>();
     body = gameObject.GetComponent<AnimalBody>();
     foodMap = GameObject.FindGameObjectWithTag("Map").GetComponent<FoodMap>();
     animalMap = GameObject.FindGameObjectWithTag("Map").GetComponent<AnimalMap>();
     PrairieBrainStart(); //Only meaningful in the child class PrairieDogBrain
 }
Beispiel #10
0
 public override void Stash(AnimalStateMachine consumer)
 {
     isGrown = false;
     regrowTimer = 0f;
 }