Pedestrian.Update C# (CSharp) Метод

Update() публичный Метод

public Update ( ) : void
Результат void
    void Update()
    {
        LinkedListNode<PedestrianPosition> cur;

        /*if (pc.playing) {
            GetComponent<Animation>().Play ();
        /*} else {
            GetComponent<Animation>().Stop ();
        }*/

        //int index = _getTrait(positions, pc.current_time);

        /*
        if(animOn){
            GetComponent<Animation>().Play();
            //r.enabled = true;
        }else{
            GetComponent<Animation>().Stop();
            //r.enabled = false;
        }
        */

        cur = _getTrait2 (pc.current_time);

            //Debug.Log("x:\t" +cur.Value.getX() +"y:\t"+ cur.Value.getY() + "time:\t"+cur.Value.getTime() + "id:\t" + id);
            if (cur != null && cur != last) {

                iterator = cur;

            //r.enabled = true;

            if(!isActive()){
                active = true;
                r.enabled = true;
            }

                //bool necessaryToTransform = false;

                //Not On Trigger
                //if(!animOn){

                    //same with ray

            //var heading = new Vector3(cur.Value.getX(),cam.transform.position.y,cur.Value.getY()) - cam.transform.position;
            //if(Vector3.Dot(heading,cam.transform.forward)> 40){

            /*

            int dist =(int)Vector3.Distance(new Vector3(cur.Value.getX(),cam.transform.position.y,cur.Value.getY()),cam.transform.position);

            if(dist > 30){
                GetComponent<Animation>().Stop();

            }

            GetComponent<Animation>().Play();

            */

                //r.enabled = true;
                //if(animOn){
                //bool necessaryToTransform = (pc.current_time - lastTime) > reducedStepTime;

                            //GetComponent<Animation>().Play ();
                            //lastTime = pc.current_time;
                            //if (index < positions.Count - 1 && index > -1){

                            //PedestrianPosition pos = (PedestrianPosition) positions.GetByIndex (index);
                            //PedestrianPosition pos2 = (PedestrianPosition) positions.GetByIndex (index+1);

            PedestrianPosition pos = (PedestrianPosition)cur.Value;
            PedestrianPosition pos2 = (PedestrianPosition)cur.Next.Value;
            start = new Vector3 (pos.getX (), 0, pos.getY ());
            target = new Vector3 (pos2.getX (), 0, pos2.getY ());
            float time = pc.current_time;
            float timeStepLength = Mathf.Clamp (pos2.getTime () - pos.getTime (), 0.1f, 50f); // We don't want to divide by zero. OTOH, this results in pedestrians never standing still.
            float movement_percentage = (time - pos.getTime ()) / timeStepLength;
            Vector3 newPosition = Vector3.Lerp (start, target, movement_percentage);
            //Debug.Log("Pos:/tx:" + newPosition.x +"y:/t" +newPosition.z + "id:/t" + id);

            gameObject.hideFlags = HideFlags.None;
            transform.position = newPosition;

            if (pos != lastPos) {

                lastPos = pos;

                Vector3 relativePos = target - start;

                speed = relativePos.magnitude;
                //if (start != target)
                transform.rotation = Quaternion.LookRotation (relativePos);
                genderBasedAnim.speed = getSpeed () / timeStepLength;

            }

                    /*}else {
                        if(GetComponent<Animation>().isPlaying)
                        GetComponent<Animation> ().Stop ();

                    }*/

            } else {
            //Debug.Log("hide");
                //currentTrait = 0;

            //TODO search an better stantment for looping
                if(pc.current_time < 1)
                iterator = positions.First;
            //Debug.Log(iterator.Value.getTime());
                active = false;
                r.enabled = false;
                gameObject.hideFlags = HideFlags.HideInHierarchy;
            }
    }