Esempio n. 1
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;
    }
    // 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;
    }