Esempio n. 1
0
        private void ActivateModeZone(bool forced)
        {
            if (modeID == 4 && ActionID != null)
            {
                ID.Value = ActionID;  //Use Action ID Instead
            }
            if (forced || automatic)
            {
                CurrentAnimal.Mode_Activate((int)modeID, ID); //Current animal was empty  ??!?!??!
                OnZONEActive();

                if (automatic)
                {
                    StartCoroutine(ZoneColliderONOFF());
                }
            }
            else
            {  //In Case the Zone is not Automatic
                var PreMode = CurrentAnimal.Mode_Get(modeID);

                if (PreMode != null)
                {
                    PreMode.AbilityIndex = ID;
                    PreMode.GlobalProperties.OnEnter.AddListener(OnZONEActive);
                }
            }
        }
Esempio n. 2
0
        /// <summary>Enables the Zone using the Stance</summary>
        private void ActivateStanceZone()
        {
            // CurrentAnimal.Mode_Interrupt(); //in case the Animal is doing a mode Interrupt it

            switch (stanceAction)
            {
            case StanceAction.Enter:
                CurrentAnimal.Stance_Set(stanceID);
                break;

            case StanceAction.Exit:
                CurrentAnimal.Stance_Reset();
                break;

            case StanceAction.Toggle:
                CurrentAnimal.Stance_Toggle(stanceID);
                break;

            case StanceAction.Stay:
                CurrentAnimal.Stance_Set(stanceID);
                break;

            default:
                break;
            }

            StatModifierOnActive.ModifyStat(AnimalStats);
            OnZoneActivation.Invoke(CurrentAnimal);
        }
Esempio n. 3
0
        /// <summary>Enables the Zone using the State</summary>
        private void ActivateStateZone()
        {
            switch (stateAction)
            {
            case StateAction.Activate:
                CurrentAnimal.State_Activate(stateID);
                break;

            case StateAction.AllowExit:
                if (CurrentAnimal.ActiveStateID == stateID)
                {
                    CurrentAnimal.ActiveState.AllowExit();
                }
                break;

            case StateAction.ForceActivate:
                CurrentAnimal.State_Force(stateID);
                break;

            case StateAction.Enable:
                CurrentAnimal.State_Enable(stateID);
                break;

            case StateAction.Disable:
                CurrentAnimal.State_Disable(stateID);
                break;

            default:
                break;
            }

            StatModifierOnActive.ModifyStat(AnimalStats);
            OnZoneActivation.Invoke(CurrentAnimal);
        }
Esempio n. 4
0
        public virtual void ResetStoredAnimal()
        {
            CurrentAnimal.IsOnZone = false;

            if (zoneType == ZoneType.Mode)
            {
                var PreMode = CurrentAnimal.Mode_Get(modeID);
                if (PreMode != null)
                {
                    PreMode.ResetAbilityIndex();
                    PreMode.GlobalProperties.OnEnter.RemoveListener(OnZONEActive);
                }
            }

            CurrentAnimal    = null;
            animal_Colliders = new List <Collider>();                            //Clean the colliders
        }
Esempio n. 5
0
        void OnTriggerEnter(Collider other)
        {
            if (other.isTrigger)
            {
                return;
            }

            if (!MalbersTools.CollidersLayer(other, LayerMask.GetMask("Animal")))
            {
                return;                                                                             //Just accept animal layer only
            }
            if (HeadOnly && !other.name.Contains(HeadName))
            {
                return;                                                                             //If is Head Only and no head was found Skip
            }
            MAnimal newAnimal = other.GetComponentInParent <MAnimal>();                             //Get the animal on the entering collider

            if (!newAnimal)
            {
                return;                                                                             //If there's no animal do nothing
            }
            if (animal_Colliders.Find(coll => coll == other) == null)                               //if the entering collider is not already on the list add it
            {
                animal_Colliders.Add(other);
            }

            if (newAnimal == CurrentAnimal)
            {
                return;                                                                //if the animal is the same do nothing (when entering two animals on the same Zone)
            }
            else
            {
                if (CurrentAnimal)
                {
                    animal_Colliders = new List <Collider>();                          //Clean the colliders
                }
                CurrentAnimal = newAnimal;                                             //Set a new Animal
                AnimalStats   = CurrentAnimal.GetComponentInParent <Stats>();

                StatModifierOnEnter.ModifyStat(AnimalStats);                         //Modify the stats when exit
                OnEnter.Invoke(CurrentAnimal);
                ActivateZone();
            }
        }
Esempio n. 6
0
        void OnTriggerExit(Collider other)
        {
            if (other.isTrigger)
            {
                return;
            }
            if (HeadOnly && !other.name.Contains(HeadName))
            {
                return;                                                     //if is only set to head and there's no head SKIP
            }
            MAnimal existing_animal = other.GetComponentInParent <MAnimal>();

            if (!existing_animal)
            {
                return;                                                              //If there's no animal script found skip all
            }
            if (existing_animal != CurrentAnimal)
            {
                return;                                                             //If is another animal exiting the zone SKIP
            }
            if (animal_Colliders.Find(item => item == other))                       //Remove the collider from the list that is exiting the zone.
            {
                animal_Colliders.Remove(other);
            }

            if (animal_Colliders.Count == 0)                                       //When all the collides are removed from the list..
            {
                OnExit.Invoke(CurrentAnimal);                                      //Invoke On Exit when all animal's colliders has exited the Zone
                StatModifierOnExit.ModifyStat(AnimalStats);                        //Modify the stats when exit

                if (zoneType == ZoneType.Stance && stanceAction == StanceAction.Stay && CurrentAnimal.Stance == stanceID.ID)
                {
                    CurrentAnimal.Stance_Reset();
                }

                ResetStoredAnimal();
            }
        }