Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityStandardAssets.Characters.FirstPerson;
- public enum CharacterIdentifier
- {
- CHARACTER_1,
- CHARACTER_2,
- CHARACTER_3,
- CHARACTER_4
- }
- public enum PropIdentifier
- {
- PROP_1,
- PROP_2,
- PROP_3,
- PROP_4
- }
- /// <summary>
- /// Base class for characters in the scene:
- /// Player and NPCs will inherit form this class
- /// </summary>
- [System.Serializable]
- public class CharacterLogic : MonoBehaviour
- {
- #region ExternalConditions
- //Marked as protected to by used by class
- //which inherit from this parent class
- [SerializeField]
- protected CharacterIdentifier CharacterID
- {
- get { return CharacterID; }
- set { CharacterID = value; }
- }
- [SerializeField]
- protected PropIdentifier PropID
- {
- get { return PropID; }
- set { PropID = value; }
- }
- [SerializeField]
- protected BoatIdentifier BoatID
- {
- get { return BoatID; }
- set { BoatID = value; }
- }
- #endregion
- #region HealthConditions
- [SerializeField]
- protected float CurrentAcidity
- {
- get { return CurrentAcidity; }
- set { CurrentAcidity = value; }
- }
- [SerializeField]
- protected float AcidityLimit
- {
- get { return AcidityLimit; }
- set { AcidityLimit = value; }
- }
- [SerializeField]
- protected float CurrentHunger
- {
- get { return CurrentHunger; }
- set { CurrentHunger = value; }
- }
- [SerializeField]
- protected float HungerLimit
- {
- get { return HungerLimit; }
- set { HungerLimit = value; }
- }
- [SerializeField]
- protected float CurrentSanity
- {
- get { return CurrentSanity; }
- set { CurrentSanity = value; }
- }
- [SerializeField]
- protected float SanityLimit
- {
- get { return SanityLimit; }
- set { SanityLimit = value; }
- }
- [SerializeField]
- protected float CurrentTemperature
- {
- get { return CurrentTemperature; }
- set { CurrentTemperature = value; }
- }
- [SerializeField]
- protected float MinIntervalTemperature
- {
- get { return MinIntervalTemperature; }
- set { MinIntervalTemperature = value; }
- }
- [SerializeField]
- protected float MaxIntervalTemperature
- {
- get { return MaxIntervalTemperature; }
- set { MaxIntervalTemperature = value; }
- }
- [SerializeField]
- protected float CurrentThirst
- {
- get { return CurrentThirst; }
- set { CurrentThirst = value; }
- }
- [SerializeField]
- protected float ThirstLimit
- {
- get { return ThirstLimit; }
- set { ThirstLimit = value; }
- }
- [SerializeField]
- protected float MinIntervalTime
- {
- get { return MinIntervalTime; }
- set { MinIntervalTime = value; }
- }
- [SerializeField]
- protected float MaxIntervalTime
- {
- get { return MaxIntervalTime; }
- set { MaxIntervalTime = value; }
- }
- #endregion
- public TextAsset normalStory;
- public TextAsset firstSpecialStory;
- public TextAsset secondSpecialStory;
- public TextAsset otherStory;
- public void FadeOut()
- {
- GameManager.instance.FadeOutImage();
- GameManager.instance.text.gameObject.SetActive(false);
- }
- private void Start()
- {
- AcidityLimit = 9;
- CurrentAcidity = 10f;
- }
- /// <summary>
- /// Each characters check their conditions
- /// If true, changes the normal story for a special one
- /// </summary>
- public virtual void CheckConditions()
- {
- if (CheckAcidity())
- Debug.Log("[CharacterLogic] Acidity True");
- if (CheckHunger())
- Debug.Log("[CharacterLogic] Hunger True");
- if (CheckSanity())
- Debug.Log("[CharacterLogic] Sanity True");
- if (CheckTemperature())
- Debug.Log("[CharacterLogic] Temperature True");
- if (CheckThirst())
- Debug.Log("[CharacterLogic] Thirst True");
- if (CheckCurrentTime())
- Debug.Log("[CharacterLogic] Time Interval True");
- if (CheckBoat())
- Debug.Log("[CharacterLogic] Boat True");
- if (CheckCharactersOnBoat())
- Debug.Log("[CharacterLogic] Character True");
- }
- public virtual bool CheckAcidity()
- {
- if (CurrentAcidity > AcidityLimit)
- return true;
- else
- return false;
- }
- public virtual bool CheckHunger()
- {
- if (CurrentHunger > HungerLimit)
- return true;
- else
- return false;
- }
- public virtual bool CheckSanity()
- {
- if (CurrentSanity > SanityLimit)
- return true;
- else
- return false;
- }
- public virtual bool CheckTemperature()
- {
- if (CurrentTemperature < MaxIntervalTemperature
- && CurrentTemperature > MinIntervalTemperature)
- return true;
- else
- return false;
- }
- public virtual bool CheckThirst()
- {
- if (CurrentThirst > ThirstLimit)
- return true;
- else
- return false;
- }
- public virtual bool CheckCurrentTime()
- {
- float currentTime = GameManager.instance.wheatherController.CurrentTime;
- if (currentTime < MaxIntervalTime
- && currentTime > MinIntervalTime)
- return true;
- else
- return false;
- }
- public virtual bool CheckBoat()
- {
- BoatIdentifier currentBoat = GameManager.instance.boat.GetComponent<BoatLogic>().boatID;
- if (BoatID == currentBoat)
- return true;
- else
- return false;
- }
- public virtual bool CheckCharactersOnBoat()
- {
- CharacterIdentifier IDtoCheck = GameManager.instance.boat.testCharacter.GetComponent<NPCLogic>().CharacterID;
- if (IDtoCheck == CharacterID)
- return true;
- else
- return false;
- }
- public virtual void OnTriggerEnter(Collider other)
- {
- if (other.name == PropID.ToString())
- Debug.Log("[CharacterLogic] ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement