Advertisement
ensiferum888

New_Elder

Feb 22nd, 2014
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.43 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class New_Elder : MonoBehaviour {
  5.     public Rect container;
  6.     public GUISkin _mySkin;
  7.     public Texture2D image;
  8.     public string eventDescription;
  9.     public GameObject target;
  10.     Rect title;
  11.     Rect pictureFrame;
  12.     Rect description;
  13.     Rect firstResponse;
  14.     string targetName;
  15.    
  16.     bool tooltip = false;
  17.    
  18.     // Use this for initialization
  19.     void Start () {
  20.         GUIEnabled.enabled = false;
  21.         container = new Rect(Screen.width /2 - 225, Screen.height / 2 - 300, 450, 600);
  22.         title = new Rect(container.width / 2 - 100, 50, 200, 50);
  23.         pictureFrame = new Rect(container.width / 2 - 195, 100, 390, 199);
  24.         description = new Rect(50, 320, container.width - 100, 60);
  25.         firstResponse = new Rect(25, 435, container.width - 50, 30);
  26.         Time.timeScale = 0.0f;
  27.     }
  28.    
  29.     public void setTargetName(){
  30.         targetName = target.GetComponent<CitizenAI>().citizenName;
  31.         eventDescription = "As the oldest male member of the community, " + targetName + " has assumed the " +
  32.             "position of Elder. The community's well being is now under your responsability.";
  33.     }
  34.    
  35.     void OnGUI(){
  36.         GUI.skin = _mySkin;
  37.         GUI.depth = -20;
  38.         GUI.Box(container, "", "EventWindow");
  39.         GUI.BeginGroup(container);
  40.             GUI.Label(title, "New Elder", "BlackCenter");
  41.             GUI.Box (pictureFrame, "", "PictureFrame");
  42.             GUI.BeginGroup(pictureFrame);
  43.                 GUI.DrawTexture(new Rect(5, 5, pictureFrame.width - 10, pictureFrame.height - 10), image);
  44.             GUI.EndGroup();
  45.             GUI.Label(description, eventDescription, "BlackCenter");
  46.             if(GUI.Button(firstResponse, "I will do my best to guide our community.", "Scroll")){
  47.                 Time.timeScale = 1.0f;
  48.                 GUIEnabled.enabled = true;
  49.                 foreach(GameObject citizen in SaveManager.Instance.citizenList){
  50.                     CitizenOpinion co = citizen.GetComponent<CitizenOpinion>();
  51.                     if(co != null){
  52.                         co.addOpinion(10);
  53.                     }
  54.                 }
  55.                 Authority.Instance.GetApprovalRating();
  56.                 Destroy (gameObject);
  57.             }
  58.             tooltip = firstResponse.Contains(Event.current.mousePosition);
  59.         GUI.EndGroup();
  60.         if(tooltip){
  61.             Rect tool = new Rect(Input.mousePosition.x + 10, Screen.height - Input.mousePosition.y - 15, 200, 40);
  62.             GUI.Box(tool, "", "BuildMenu");
  63.             GUI.BeginGroup (tool);
  64.             GUI.Label (new Rect(10, 10, tool.width - 20, 20), "Everyone's opinion of " + targetName + " increased by 10", "TextBlack");
  65.             GUI.EndGroup();
  66.         }
  67.         GameGUI.Instance.isOnOtherGUI = container.Contains (Event.current.mousePosition);
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement