Game Development Reference
In-Depth Information
006 public class PlayerController : MonoBehaviour
007 {
008 //------------------------------------------------
009 //Amount of cash player should collect to complete level
010 public float CashTotal = 1400.0f;
011
012 //Amount of cash for this player
013 private float cash = 0.0f;
014
015 //Reference to transform
016 private Transform ThisTransform = null;
017
018 //Respawn time in seconds after dying
019 public float RespawnTime = 2.0f;
020
021 //Player health
022 public int health = 100;
023
024 //Get Mecanim animator component in children
025 private Animator AnimComp = null;
026
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 //Called when object is created
040 void Start()
041 {
042 //Get First person capsule and make non-visible
043 MeshRenderer Capsule = GetComponentInChildren<MeshRenderer>();
044 Capsule.enabled = false;
045
046 //Get Animator
047 AnimComp = GetComponentInChildren<Animator>();
048
049 //Create damage texture
050 DamageTexture = new Texture2D(1,1);
051 DamageTexture.SetPixel(0,0,new Color(255,0,0,0.5f));
052 DamageTexture.Apply();
053
054 //Get cached transform
055 ThisTransform = transform;
056 }
Search WWH ::




Custom Search