Exemplo n.º 1
0
 public void initialize()
 {
     state = WFWordBlobState.drifting;
     saveZ = this.transform.position.z;
     //deltaY = targetDeltaY = 0.0f;
     //tab = null;
 }
Exemplo n.º 2
0
 public void pickUp(Vector3 screenPos)
 {
     pickUpWorldPos = screenPos;
     this.GetComponent <Collider> ().enabled = false;
     state  = WFWordBlobState.pickedUp;
     nTurns = 0;         // it is VERY difficult if otherwise
     //targetDeltaY = 0.5f;
 }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (state == WFWordBlobState.paused)
        {
        }

        if (state == WFWordBlobState.drifting)
        {
            Vector3 displacement = Vector3.zero;

            displacement.x = speed * difficulty * Mathf.Cos(angle) * Time.deltaTime;
            displacement.y = speed * difficulty * Mathf.Sin(angle) * Time.deltaTime;

            Vector3 newPos = this.transform.position + displacement;
            this.transform.position = newPos;

            Vector3 diff = newPos - yinYang.transform.position;

            if (!good && (diff.magnitude > turnDist))
            {
                if (nTurns > 0)
                {
                    --nTurns;
                    state = WFWordBlobState.sinking;
                }
            }

            if (diff.magnitude > killdist)
            {
                Destroy(this.gameObject);
            }
        }

        if (state == WFWordBlobState.sinking)
        {
            Vector3 direction = yinYang.transform.position - this.transform.position;
            direction.Normalize();

            Vector3 displacement = Vector3.zero;

            displacement.x = speed * difficulty * direction.x * Time.deltaTime;
            displacement.y = speed * difficulty * direction.y * Time.deltaTime;

            Vector3 newPos = this.transform.position + displacement;
            this.transform.position = newPos;

            Vector3 diff = newPos - yinYang.transform.position;
            if (diff.magnitude < insertDist)
            {
                if (!good)
                {
                    controller.hurtPlayer();
                }
                Destroy(this.gameObject);
            }
        }

        if (state == WFWordBlobState.pickedUp)
        {
            if (deltaY < targetDeltaY)
            {
                deltaY += 2.0f * Time.deltaTime;
            }

            test = 0;

            RaycastHit   hit;
            RaycastHit[] allHits;
            Ray          ray = cam.ScreenPointToRay(Input.mousePosition);

            allHits = Physics.RaycastAll(ray);
            for (int i = 0; i < allHits.Length; ++i)
            {
                GameObject objectHit = allHits[i].transform.gameObject;

                if (objectHit.tag == "RayCastBillboard")
                {
                    prevPosition            = worldCoords;
                    worldCoords             = allHits[i].point;
                    test                    = 1;
                    worldCoords.z           = saveZ;
                    this.transform.position = worldCoords + new Vector3(0, deltaY, 0);
                }
            }             /*else {
                           *    worldCoords = prevPosition;
                           * }*/


            Vector3 diff = worldCoords - yinYang.transform.position;
            if (diff.magnitude < insertDist)
            {
                if (good)
                {
                    controller.hurtShadow();
                }
                else
                {
                    controller.hurtPlayer();
                }
                Destroy(this.gameObject);
            }



            if (Input.GetMouseButtonUp(0))
            {
                /* new speed and angle */
                state = WFWordBlobState.drifting;
                Vector3 releaseVelocity = worldCoords - prevPosition;
                speed = releaseVelocity.magnitude * SpeedFactor;                // / Time.deltaTime;
                angle = Mathf.Acos(releaseVelocity.normalized.x);
                if (releaseVelocity.y < 0.0)
                {
                    angle = Mathf.Deg2Rad * 360.0f - angle;
                }

                /* reenable collider */
                this.GetComponent <Collider> ().enabled = true;

                targetDeltaY = 0.0f;
                //if(tab != null) tab.release ();
            }


            //prevPosition = worldCoords;
        }
    }
Exemplo n.º 4
0
 public void unpause()
 {
     state = savedState;
 }
Exemplo n.º 5
0
 public void pause()
 {
     savedState = state;
     state      = WFWordBlobState.paused;
 }