示例#1
0
    void FixedUpdate()
    {
        s_person person = transform.GetComponentInParent <s_person>();

        time = (person.timeLeft * 6) / timeScale - 90;
        transform.rotation = Quaternion.AngleAxis(time, Vector3.up);
    }
示例#2
0
    void stealTime()
    {
//        if (victim != null){
//            s_person otherPerson = victim.gameObject.GetComponent<s_person>();
//            float otherTime = otherPerson.timeLeft;
//            //Debug.Log("Other time: " + otherTime);
//            float diffTime = otherTime - timeLeft;
//            float adjDiffTime = diffTime * 0.02f;
//            //if (adjDiffTime > 0)
//            //{
//            otherPerson.timeLeft = otherPerson.timeLeft - adjDiffTime;
//            timeLeft = timeLeft + adjDiffTime;
//            //}
//            Transform pinP = victim.transform.FindChild("pinP");
//            Vector3 deltaP = this.transform.position - victim.transform.position;
//            Vector3 dir = victim.transform.InverseTransformDirection(deltaP);
//            float angle = Mathf.Atan2(dir.z, dir.x) * Mathf.Rad2Deg;

//            pinP.rotation = Quaternion.AngleAxis(-angle + 90, Vector3.up);
//            ParticleSystem ps = pinP.GetComponent<ParticleSystem>();
//            ps.startLifetime = deltaP.magnitude / ps.startSpeed;
//        }

        foreach (GameObject v in victimList)
        {
//        if (victim != null){
            s_person otherPerson = v.gameObject.GetComponent <s_person>();
            float    otherTime   = otherPerson.timeLeft;
            //Debug.Log("Other time: " + otherTime);
            float diffTime    = otherTime - timeLeft;
            float adjDiffTime = diffTime * 0.02f;
            //if (adjDiffTime > 0)
            //{
            otherPerson.timeLeft = otherPerson.timeLeft - adjDiffTime;
            timeLeft             = timeLeft + adjDiffTime;
            //}


            //particle system
            Transform pinP   = v.transform.FindChild("pinP");
            Vector3   deltaP = this.transform.position - v.transform.position;
            Vector3   dir    = v.transform.InverseTransformDirection(deltaP);
            float     angle  = Mathf.Atan2(dir.z, dir.x) * Mathf.Rad2Deg * -1 + 90;

            //pinP.rotation = Quaternion.AngleAxis(-angle + 90, Vector3.up);

            ParticleSystem ps = pinP.GetComponent <ParticleSystem>();
            ps.startLifetime = deltaP.magnitude / ps.startSpeed;

            //ps.startColor = Color.Lerp(Color.red, Color.blue, (diffTime + 30)/60);
            if (adjDiffTime < 0)
            {
//                ps.startColor = Color.red;
                pinP.rotation = Quaternion.AngleAxis(angle + 180, Vector3.up);
                pinP.position = gameObject.transform.position + new Vector3(0, 1, 0);
            }
            else
            {
                //               ps.startColor = Color.blue;
                pinP.rotation = Quaternion.AngleAxis(angle, Vector3.up);
                pinP.position = v.transform.position + new Vector3(0, 1, 0);
            }
        }
    }