void OnTriggerEnter(Collider other) { if (other.CompareTag("Resources")) { BulletResourcesControllerScript pbc = other.GetComponent <BulletResourcesControllerScript> (); ac.IncrementAmmo(pbc.kind); Destroy(other.gameObject); } else if (other.CompareTag("Health")) { HealthControllerScript hcs = other.GetComponent <HealthControllerScript> (); hms.IncrementHealth(hcs.howManyHealth); Destroy(other.gameObject); } }
// Use this for initialization void Start() { healthControllerScript = GameObject.Find("HealthController").gameObject.GetComponent <HealthControllerScript> (); fameControllerScript = GameObject.Find("FameController").gameObject.GetComponent <FameControllerScript> (); flashScript = transform.FindChild("flash").gameObject.GetComponent <flashScript>(); photoArea = transform.FindChild("photoArea").gameObject; photoAreaScript = photoArea.GetComponent <PhotoAreaScript>(); focusScript = photoArea.transform.FindChild("focus").gameObject.GetComponent <FocusScript>(); Transform waypointHolder = GameObject.FindGameObjectWithTag("waypoint").transform; anim = GetComponent <Animator>(); oldTransform = transform; waypoints = new List <Transform> (); foreach (Transform waypoint in waypointHolder) { waypoints.Add(waypoint); } //find nearest waypoint for inital placement currentWaypointIndex = 0; float currentSmallestDistance = Vector2.Distance((Vector2)transform.position, (Vector2)waypoints[currentWaypointIndex].position); foreach (Transform waypoint in waypoints) { if (waypoint == waypoints[currentWaypointIndex]) { continue; } ; float distance = Vector2.Distance((Vector2)transform.position, (Vector2)waypoint.position); if (distance > currentSmallestDistance) { continue; } else { currentSmallestDistance = distance; currentWaypointIndex = waypoints.IndexOf(waypoint); } } currentTime = 0; Random.seed = 42; }
void Awake() { instance = this; }
private void Start() { healthController = GameObject.FindGameObjectWithTag("HealthController").GetComponent <HealthControllerScript>(); playerColor = GetComponent <Renderer>().material.color; StartCoroutine(CoroutineIsteadUpdate()); }
// Use this for initialization void Start() { healthControllerScript = GameObject.Find("HealthController").gameObject.GetComponent<HealthControllerScript> (); fameControllerScript = GameObject.Find ("FameController").gameObject.GetComponent<FameControllerScript> (); flashScript = transform.FindChild ("flash").gameObject.GetComponent<flashScript>(); photoArea = transform.FindChild ("photoArea").gameObject; photoAreaScript = photoArea.GetComponent<PhotoAreaScript>(); focusScript = photoArea.transform.FindChild ("focus").gameObject.GetComponent<FocusScript>(); Transform waypointHolder = GameObject.FindGameObjectWithTag ("waypoint").transform; anim = GetComponent<Animator>(); oldTransform = transform; waypoints = new List<Transform> (); foreach (Transform waypoint in waypointHolder){ waypoints.Add(waypoint); } //find nearest waypoint for inital placement currentWaypointIndex = 0; float currentSmallestDistance = Vector2.Distance((Vector2)transform.position, (Vector2) waypoints[currentWaypointIndex].position); foreach (Transform waypoint in waypoints){ if (waypoint == waypoints[currentWaypointIndex]){continue;}; float distance = Vector2.Distance((Vector2)transform.position, (Vector2) waypoint.position); if (distance > currentSmallestDistance){ continue; }else{ currentSmallestDistance = distance; currentWaypointIndex = waypoints.IndexOf(waypoint); } } currentTime = 0; Random.seed = 42; }