Ejemplo n.º 1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Animal")
     {
         currentPartner = other.gameObject;
         if (currentPartner.GetComponent <Animal>().climaxTotal > climaxTotal)
         {
             currentPartner.GetComponent <Animal>().alpha = true;
         }
         else
         {
             alpha = true;
         }
         int randomSex = Random.Range(0, 100);
         if (randomSex < 50)
         {
             sexyTimer   = climaxTotal;
             animalState = AnimalState.SEXY;
             other.GetComponent <Animal>().animalState = AnimalState.SEXY;
         }
         else
         {
             fightTimer  = climaxTotal;
             animalState = AnimalState.FIGHTING;
             other.GetComponent <Animal>().animalState = AnimalState.FIGHTING;
         }
     }
 }
Ejemplo n.º 2
0
    private void TryEat()
    {
        if (state != AnimalState.Eating)
        {
            return;
        }
        var food_source = GetClosestFoodSource();

        if (food_source == null)
        {
            state = AnimalState.Hungry;
            return;
        }
        var position      = transform.position;
        var food_position = food_source.transform.position;

        if ((food_position - position).magnitude < 10)
        {
            satiety += food_source.GetFood(Time.deltaTime);
        }
        else
        {
            state = AnimalState.Calm;
        }
    }
Ejemplo n.º 3
0
    private string GetStateString(AnimalState state)
    {
        switch (state)
        {
        case AnimalState.Calm:
            return("Calm");

        case AnimalState.Hungry:
            return("Hungry");

        case AnimalState.Afraid:
            return("Afraid");

        case AnimalState.Frenzy:
            return("Frenzy");

        case AnimalState.Dead:
            return("Dead");

        case AnimalState.Overate:
            return("Overate");

        case AnimalState.Eating:
            return("Eating");

        default:
            throw new ArgumentOutOfRangeException(nameof(state), state, null);
        }
    }
Ejemplo n.º 4
0
        public override bool IsWithAgentFree(AgentActor _actor)
        {
            if (!this.AgentInsight || this.IsWithActor || Object.op_Inequality((Object)this.CommandPartner, (Object)null) && this.CommandPartner is AgentActor && Object.op_Inequality((Object)this.CommandPartner, (Object)_actor))
            {
                return(false);
            }
            AnimalState currentState = this.CurrentState;

            switch (currentState)
            {
            case AnimalState.Idle:
            case AnimalState.Locomotion:
            case AnimalState.LovelyIdle:
            case AnimalState.LovelyFollow:
            case AnimalState.Sleep:
            case AnimalState.Eat:
                return(true);

            default:
                if (currentState != AnimalState.Action9)
                {
                    return(false);
                }
                goto case AnimalState.Idle;
            }
        }
Ejemplo n.º 5
0
 public void Clear()
 {
     Index              = -1;
     AttackDir          = AttackDirection.Top;
     curState           = AnimalState.None;
     transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, 0f));
 }
Ejemplo n.º 6
0
        public IAnimal CreateAnimal(string animalName, int foodWeightPerDay, AnimalType type)
        {
            if (_animalStates.ContainsKey(type))
            {
                return(new Animal(animalName, foodWeightPerDay, _animalStates[type]));
            }

            switch (type)
            {
            case AnimalType.OKKAM:
                _animalStates[type] = new AnimalState(type, OKKAM_SPEECH);
                break;

            case AnimalType.LICHURKA:
                _animalStates[type] = new AnimalState(type, LICHURKA_SPEECH);
                break;

            case AnimalType.COMUFLOR:
                _animalStates[type] = new AnimalState(type, COMUFLOR_SPEECH);
                break;
            }

            if (!_animalStates.ContainsKey(type))
            {
                throw new NoSuchAnimalTypeException();
            }

            return(new Animal(animalName, foodWeightPerDay, _animalStates[type]));
        }
Ejemplo n.º 7
0
 public void SetState(AnimalState state)
 {
     if (curState == state)
     {
         return;
     }
     curState = state;
     if (curState == AnimalState.Finish || curState == AnimalState.Dead)
     {
         moveDistance = 0;
         Index        = -1;
     }
     else if (curState == AnimalState.Connect)
     {
     }
     else if (curState == AnimalState.Wait)
     {
         ToSeatDefault();
     }
     else if (curState == AnimalState.Select)
     {
         transform.position = transform.position + new Vector3(0, 0.5f, 0);
         animation.Play(gameObject.name + "_" + curState.ToString());
     }
     else
     {
         animation.Play(gameObject.name + "_" + curState.ToString());
     }
 }
 void Start()
 {
     audioSource  = GetComponent <AudioSource>();
     navAgent     = GetComponent <NavMeshAgent>();
     animator     = GetComponent <Animator>();
     currentState = AnimalState.Idle;
 }
Ejemplo n.º 9
0
    //React to player if seen by animal
    private void ReactToThreat()
    {
        if (state == AnimalState.Wander || state == AnimalState.Alerted)
        {
            if (target == null)
            {
                target = PlayerCharacter.Get();
            }

            if (behavior == AnimalBehavior.Escape || behavior == AnimalBehavior.PassiveEscape)
            {
                state = AnimalState.Escape;
            }
            else if (behavior == AnimalBehavior.Aggressive || behavior == AnimalBehavior.PassiveDefense)
            {
                state = AnimalState.Follow;
            }
            else
            {
                state = AnimalState.Wander;
            }
            state_timer    = 0f;
            follow_reached = false;

            if (state != AnimalState.Wander)
            {
                CalculateNavmesh();
            }
        }
    }
Ejemplo n.º 10
0
    public void SearchForPredator()
    {
        leftTimeForEscaping -= Time.deltaTime;
        /* Check existing escaping */
        if (currentState == AnimalState.Escaping && predator != null)
        {
            float distance = (transform.position - predator.transform.position).magnitude;
            if (distance > sight * 2)
            {
                currentState = AnimalState.Wandering;
                UpdateSpeed(wanderSpeed);
            }
            return;
        }
        if (currentState != AnimalState.Wandering || leftTimeForEscaping > 0)
        {
            return;
        }

        Collider[] predatorColliders = Physics.OverlapSphere(transform.position, sight).Where(coll => predators.Contains(coll.tag)).ToArray();
        if (predatorColliders.Length > 0)
        {
            currentState = AnimalState.Escaping;
            UpdateSpeed(escapeSpeed);

            Collider closest = predatorColliders.Aggregate(
                (acc, cur) => (acc.transform.position - transform.position).magnitude < (cur.transform.position - transform.position).magnitude ? acc : cur
                );
            Vector3 diff = transform.position - closest.transform.position;
            transform.rotation  = Quaternion.LookRotation(new Vector3(diff.x, 0, diff.z), Vector3.up);
            predator            = closest.gameObject;
            leftTimeForEscaping = coolTimeEscaping;
        }
    }
Ejemplo n.º 11
0
    private void ChangeState()
    {
        switch (state)
        {
        case AnimalState.Calm:
            if (satiety < 30)
            {
                if (logging)
                {
                    Debug.Log("The " + GetName() + " is hungry!");
                }
                state = AnimalState.Hungry;
            }
            else if (satiety > overeating_threshold)
            {
                state = AnimalState.Overate;
            }

            break;

        case AnimalState.Hungry:
            var food_source = GetClosestFoodSource();
            var position    = transform.position;

            if ((food_source != null) && (food_source.transform.position - position).magnitude < 4)
            {
                state = AnimalState.Eating;
            }
            if (satiety <= starvation_threshold)
            {
                state = AnimalState.Dead;
                Die();
            }
            break;

        case AnimalState.Overate:
            if (satiety < overeating_threshold)
            {
                state = AnimalState.Calm;
            }
            break;

        case AnimalState.Afraid:
            break;

        case AnimalState.Frenzy:
            break;

        case AnimalState.Dead:
            break;

        case AnimalState.Eating:
            if (satiety > 70)
            {
                state = AnimalState.Calm;
            }
            break;
        }
    }
Ejemplo n.º 12
0
    //Animal State Machine
    void Update()
    {
        if (currentState != AnimalState.Fleeing && InPlayerRange())
        {
            currentState = AnimalState.Fleeing;
            FleeingEntry();
        }

        switch (currentState)
        {
        case AnimalState.Idle:
            IdleDo();
            if (IdleTimePassed())
            {
                IdleExit();
                if (GetChance(eatChance))
                {
                    currentState = AnimalState.Eating;
                    EatingEntry();
                }
                else
                {
                    currentState = AnimalState.Walking;
                    WalkingEntry();
                }
            }
            break;

        case AnimalState.Walking:
            WalkingDo();
            if (ReachedDestination())
            {
                WalkingExit();
                currentState = AnimalState.Idle;
                IdleEntry();
            }
            break;

        case AnimalState.Fleeing:
            FleeingDo();
            if (ReachedDestination())
            {
                FleeingExit();
                currentState = AnimalState.Idle;
                IdleEntry();
            }
            break;

        case AnimalState.Eating:
            EatingDo();
            if (EatingTimePassed())
            {
                EatingExit();
                currentState = AnimalState.Idle;
                IdleEntry();
            }
            break;
        }
    }
Ejemplo n.º 13
0
 protected void Awake()
 {
     this.sleepRemaining = 0;
     this.State = AnimalState.Awake;
 }
Ejemplo n.º 14
0
 public void Sleep(int time)
 {
     this.sleepRemaining = time;
     this.State = AnimalState.Sleeping;
 }
Ejemplo n.º 15
0
 public override void Bind()
 {
     base.Bind();
     this.Tapped = new Signal<TappedCommand>(this);
     this.DestroySelf = new Signal<DestroySelfCommand>(this);
     this.StartDrop = new Signal<StartDropCommand>(this);
     this.GotDropTarget = new Signal<GotDropTargetCommand>(this);
     this.GotIdle = new Signal<GotIdleCommand>(this);
     this.DebugCommand = new Signal<DebugCommandCommand>(this);
     _ShouldDestroyProperty = new P<Boolean>(this, "ShouldDestroy");
     _ShouldDropProperty = new P<Boolean>(this, "ShouldDrop");
     _AnimalTypeProperty = new P<AnimalType>(this, "AnimalType");
     _SameCountProperty = new P<Int32>(this, "SameCount");
     _LocProperty = new P<Loc>(this, "Loc");
     _needDestroyProperty = new P<Boolean>(this, "needDestroy");
     _TargetPropProperty = new P<AnimalProp>(this, "TargetProp");
     _AnimalStateProperty = new AnimalState(this, "AnimalState");
     ResetShouldDestroy();
     ResetShouldDrop();
     AnimalStateProperty.Destroy.AddComputer(ShouldDestroyProperty);
     AnimalStateProperty.Drop.AddComputer(ShouldDropProperty);
     GotDropTarget.Subscribe(_ => AnimalStateProperty.DropStop.OnNext(true));
 }