Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.06 KB | None | 0 0
  1. public class Boite : MonoBehaviour
  2. {
  3.     public bool hasClient;
  4.  
  5.     // Client data
  6.     public SessionType desiredSessionType;
  7.     public Attribute desiredAttribute;
  8.     public int desiredHostessCount;
  9.     public float desiredSessionTime;
  10.  
  11.     // Session data
  12.     public List<Hostess> currentHostesses = new List<Hostess>();
  13.     public SessionType currentSessionType;
  14.     public float currentSatisfaction;
  15.     public float currentSessionTime;
  16.  
  17.     private void Update()
  18.     {
  19.         if (hasClient)
  20.         {
  21.             float score = 0;
  22.            
  23.             // Client is unhappy if count does not match.
  24.             if (currentHostesses.Count != desiredHostessCount)
  25.             {
  26.                 score -= 5;
  27.             }
  28.  
  29.             // Client is unhappy if session does not match.
  30.             if (desiredSessionType != currentSessionType)
  31.             {
  32.                 score -= 3;
  33.             }
  34.            
  35.             // Client is happy or unhappy based on attributes and skill.
  36.             for (int i = 0; i < currentHostesses.Count; i++)
  37.             {
  38.                 Hostess hostess  = currentHostesses[i];
  39.                 if (hostess.Attribute == desiredAttribute)
  40.                 {
  41.                     score += 5;
  42.                 }
  43.                
  44.                 // Other stuff like hostess skill and such
  45.             }
  46.            
  47.             // Add the score to the satisfaction of the client each frame.
  48.             currentSatisfaction += score * Time.deltaTime;
  49.            
  50.             // End session when time is up
  51.             currentSessionTime += Time.deltaTime;
  52.             if (currentSessionTime > desiredSessionTime)
  53.             {
  54.                 EndSession();
  55.             }
  56.         }
  57.         else
  58.         {
  59.             // Add a timer for the spawn of a client or something
  60.             GenerateNewClientAndStartSession();
  61.         }
  62.     }
  63.    
  64.     private void GenerateNewClientAndStartSession()
  65.     {
  66.         hasClient = true;
  67.         currentSessionTime = 0;
  68.         currentSatisfaction = 0;
  69.        
  70.         // Random stuff
  71.         desiredHostessCount = Random.Range(1,2);
  72.         desiredSessionTime = Random.Range(1,3) * 15;
  73.        
  74.         // 6 is the number of session types. This will pick a random one
  75.         desiredSessionType = (SessionType)Random.Range(0, 6);
  76.        
  77.         // Same, 10 is the number of attributes
  78.         desiredAttribute = (Attribute)Random.Range(0, 10);
  79.        
  80.         // Generate other stuff like appearance
  81.     }
  82.    
  83.     private void EndSession()
  84.     {
  85.         hasClient = false;
  86.        
  87.         // Do score stuff
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement