Advertisement
alexorbh7

Error Stack Overflow

Jun 1st, 2020
744
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.33 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityStandardAssets.Characters.FirstPerson;
  6.  
  7. public enum CharacterIdentifier
  8. {
  9.     CHARACTER_1,
  10.     CHARACTER_2,
  11.     CHARACTER_3,
  12.     CHARACTER_4
  13. }
  14.  
  15. public enum PropIdentifier
  16. {
  17.     PROP_1,
  18.     PROP_2,
  19.     PROP_3,
  20.     PROP_4
  21. }
  22.  
  23. /// <summary>
  24. /// Base class for characters in the scene:
  25. /// Player and NPCs will inherit form this class
  26. /// </summary>
  27. [System.Serializable]
  28. public class CharacterLogic : MonoBehaviour
  29. {
  30.     #region ExternalConditions
  31.     //Marked as protected to by used by class
  32.     //which inherit from this parent class
  33.     [SerializeField]
  34.     protected CharacterIdentifier CharacterID
  35.     {
  36.         get { return CharacterID; }
  37.         set { CharacterID = value; }
  38.     }
  39.  
  40.     [SerializeField]
  41.     protected PropIdentifier PropID
  42.     {
  43.         get { return PropID; }
  44.         set { PropID = value; }
  45.     }
  46.  
  47.     [SerializeField]
  48.     protected BoatIdentifier BoatID
  49.     {
  50.         get { return BoatID; }
  51.         set { BoatID = value; }
  52.     }
  53.     #endregion
  54.  
  55.     #region HealthConditions
  56.  
  57.     [SerializeField]
  58.     protected float CurrentAcidity
  59.     {
  60.         get { return CurrentAcidity; }
  61.         set { CurrentAcidity = value; }
  62.     }
  63.  
  64.     [SerializeField]
  65.     protected float AcidityLimit
  66.     {
  67.         get { return AcidityLimit; }
  68.         set { AcidityLimit = value; }
  69.     }
  70.  
  71.     [SerializeField]
  72.     protected float CurrentHunger
  73.     {
  74.         get { return CurrentHunger; }
  75.         set { CurrentHunger = value; }
  76.     }
  77.  
  78.     [SerializeField]
  79.     protected float HungerLimit
  80.     {
  81.         get { return HungerLimit; }
  82.         set { HungerLimit = value; }
  83.     }
  84.  
  85.     [SerializeField]
  86.     protected float CurrentSanity
  87.     {
  88.         get { return CurrentSanity; }
  89.         set { CurrentSanity = value; }
  90.     }
  91.  
  92.     [SerializeField]
  93.     protected float SanityLimit
  94.     {
  95.         get { return SanityLimit; }
  96.         set { SanityLimit = value; }
  97.     }
  98.  
  99.     [SerializeField]
  100.     protected float CurrentTemperature
  101.     {
  102.         get { return CurrentTemperature; }
  103.         set { CurrentTemperature = value; }
  104.     }
  105.    
  106.     [SerializeField]
  107.     protected float MinIntervalTemperature
  108.     {
  109.         get { return MinIntervalTemperature; }
  110.         set { MinIntervalTemperature = value; }
  111.     }
  112.  
  113.     [SerializeField]
  114.     protected float MaxIntervalTemperature
  115.     {
  116.         get { return MaxIntervalTemperature; }
  117.         set { MaxIntervalTemperature = value; }
  118.     }
  119.  
  120.     [SerializeField]
  121.     protected float CurrentThirst
  122.     {
  123.         get { return CurrentThirst; }
  124.         set { CurrentThirst = value; }
  125.     }
  126.  
  127.     [SerializeField]
  128.     protected float ThirstLimit
  129.     {
  130.         get { return ThirstLimit; }
  131.         set { ThirstLimit = value; }
  132.     }
  133.  
  134.     [SerializeField]
  135.     protected float MinIntervalTime
  136.     {
  137.         get { return MinIntervalTime; }
  138.         set { MinIntervalTime = value; }
  139.     }
  140.  
  141.     [SerializeField]
  142.     protected float MaxIntervalTime
  143.     {
  144.         get { return MaxIntervalTime; }
  145.         set { MaxIntervalTime = value; }
  146.     }
  147.  
  148.     #endregion
  149.  
  150.     public TextAsset normalStory;
  151.     public TextAsset firstSpecialStory;
  152.     public TextAsset secondSpecialStory;
  153.     public TextAsset otherStory;
  154.  
  155.     public void FadeOut()
  156.     {
  157.         GameManager.instance.FadeOutImage();
  158.         GameManager.instance.text.gameObject.SetActive(false);
  159.     }
  160.  
  161.     private void Start()
  162.     {
  163.         AcidityLimit = 9;
  164.         CurrentAcidity = 10f;
  165.        
  166.     }
  167.  
  168.     /// <summary>
  169.     /// Each characters check their conditions
  170.     /// If true, changes the normal story for a special one
  171.     /// </summary>
  172.     public virtual void CheckConditions()
  173.     {
  174.         if (CheckAcidity())
  175.             Debug.Log("[CharacterLogic] Acidity True");
  176.  
  177.         if (CheckHunger())
  178.             Debug.Log("[CharacterLogic] Hunger True");
  179.  
  180.         if (CheckSanity())
  181.             Debug.Log("[CharacterLogic] Sanity True");
  182.  
  183.         if (CheckTemperature())
  184.             Debug.Log("[CharacterLogic] Temperature True");
  185.  
  186.         if (CheckThirst())
  187.             Debug.Log("[CharacterLogic] Thirst True");
  188.  
  189.         if (CheckCurrentTime())
  190.             Debug.Log("[CharacterLogic] Time Interval True");
  191.  
  192.         if (CheckBoat())
  193.             Debug.Log("[CharacterLogic] Boat True");
  194.  
  195.         if (CheckCharactersOnBoat())
  196.             Debug.Log("[CharacterLogic] Character True");
  197.     }
  198.  
  199.     public virtual bool CheckAcidity()
  200.     {
  201.         if (CurrentAcidity > AcidityLimit)
  202.             return true;
  203.         else
  204.             return false;
  205.     }
  206.  
  207.     public virtual bool CheckHunger()
  208.     {
  209.         if (CurrentHunger > HungerLimit)
  210.             return true;
  211.         else
  212.             return false;
  213.     }
  214.  
  215.     public virtual bool CheckSanity()
  216.     {
  217.         if (CurrentSanity > SanityLimit)
  218.             return true;
  219.         else
  220.             return false;
  221.     }
  222.  
  223.     public virtual bool CheckTemperature()
  224.     {
  225.         if (CurrentTemperature < MaxIntervalTemperature
  226.             && CurrentTemperature > MinIntervalTemperature)
  227.             return true;
  228.         else
  229.             return false;
  230.     }
  231.  
  232.     public virtual bool CheckThirst()
  233.     {
  234.         if (CurrentThirst > ThirstLimit)
  235.             return true;
  236.         else
  237.             return false;
  238.     }
  239.  
  240.     public virtual bool CheckCurrentTime()
  241.     {
  242.         float currentTime = GameManager.instance.wheatherController.CurrentTime;
  243.  
  244.         if (currentTime < MaxIntervalTime
  245.             && currentTime > MinIntervalTime)
  246.             return true;
  247.         else
  248.             return false;
  249.     }
  250.  
  251.     public virtual bool CheckBoat()
  252.     {
  253.         BoatIdentifier currentBoat = GameManager.instance.boat.GetComponent<BoatLogic>().boatID;
  254.  
  255.         if (BoatID == currentBoat)
  256.             return true;
  257.         else
  258.             return false;
  259.     }
  260.  
  261.     public virtual bool CheckCharactersOnBoat()
  262.     {
  263.         CharacterIdentifier IDtoCheck = GameManager.instance.boat.testCharacter.GetComponent<NPCLogic>().CharacterID;
  264.  
  265.         if (IDtoCheck == CharacterID)
  266.             return true;
  267.         else
  268.             return false;
  269.     }
  270.  
  271.     public virtual void OnTriggerEnter(Collider other)
  272.     {
  273.         if (other.name == PropID.ToString())
  274.             Debug.Log("[CharacterLogic] ");
  275.     }
  276. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement