Game Development Reference
In-Depth Information
027 //Private damage texture
028 private Texture2D DamageTexture = null;
029
030 //Screen coordinates
031 private Rect ScreenRect;
032
033 //Show damage texture?
034 private bool ShowDamage = false;
035
036 //Damage texture interval (amount of time in seconds to show texture)
037 private float DamageInterval = 0.2f;
038
039 //Default player weapon (Punch)
040 public Weapon DefaultWeapon = null;
041
042 //Currently active weapon
043 public Weapon ActiveWeapon = null;
044 //------------------------------------------------
045 //Called when object is created
046 void Start()
047 {
048 //Register controller for weapon expiration events
049 GameManager.Notifications.AddListener(this, "AmmoExpired");
050
051 //Activate default weapon
052 DefaultWeapon.gameObject.SendMessage("Equip", DefaultWeapon.Type);
053
054 //Set active weapon
055 ActiveWeapon = DefaultWeapon;
056
057 //Get First person capsule and make non-visible
058 MeshRenderer Capsule = GetComponentInChildren<MeshRenderer>();
059 Capsule.enabled = false;
060
061 //Get Animator
062 AnimComp = GetComponentInChildren<Animator>();
063
064 //Create damage texture
065 DamageTexture = new Texture2D(1,1);
066 DamageTexture.SetPixel(0,0,new Color(255,0,0,0.5f));
067 DamageTexture.Apply();
068
069 //Get cached transform
070 ThisTransform = transform;
071 }
072 //------------------------------------------------
073 //Accessors to set and get cash
074 public float Cash
075 {
076 //Return cash value
077 get{return cash;}
078
Search WWH ::




Custom Search