Beispiel #1
0
 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);
     }
 }
Beispiel #2
0
    // 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;
    }
Beispiel #3
0
 void Awake()
 {
     instance = this;
 }
Beispiel #4
0
 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;
    }