Beispiel #1
0
    public void DoubleClick()
    {
        DebugLog.DebugLogInfo("双击-----------------");
        if (BlockManager.Instance.availableBaseCount > 0)
        {
            DebugLog.DebugLogInfo("availableBaseCount--- " + BlockManager.Instance.availableBaseCount);
            BlockManager.Instance.availableBaseCount--;
            TouchableObject tobj = GetComponent <TouchableObject>();
            tobj.SetDraggable(false);
            tobj.SetRotatable(false);
            TweenRotation tween = TweenRotation.Begin(gameObject, 0.5f, targetRotation);
            DebugLog.DebugLogInfo("tween--- " + tween);
            tween.method = UITweener.Method.EaseInOut;
            UITweener tweener = TweenPosition.Begin(gameObject, 0.3f, targetPosition);
            DebugLog.DebugLogInfo("tweener--- " + tweener);
            tweener.method = UITweener.Method.EaseInOut;
            //TweenRotation tween = GetComponent<TweenRotation>();
            tween.from = m_transform.localEulerAngles;

            tween.to = targetAngles;
            float y = tween.from.y;
            if (Mathf.Abs(360 - tween.from.y) < Mathf.Abs(tween.from.y - 0))
            {
                //tween.from = new Vector3(tween.from.x, tween.from.y - 360, tween.from.z);
                tween.to = new Vector3(tween.to.x, tween.to.y + 360, tween.to.z);
            }
            DebugLog.DebugLogInfo("from:" + tween.from + "to:" + tween.to);
            tween.SetOnFinished(BlockManager.Instance.AddScore);
            //BlockManager.Instance.AddScore();
            isFinished = true;//标志该结构已经归位

            this.GetComponent <DraggableObject>().enabled = false;
            this.GetComponent <RotatableObject>().enabled = false;
        }
    }
Beispiel #2
0
 void Start()
 {
     screenCenterX = Screen.width / 2;
     faceRot = faceMeTran.GetComponent<TweenRotation>();
     carlRot = carlTran.GetComponent<TweenRotation>();
     isTurning = false;
     faceRot.SetOnFinished(delegate()
     {
         isTurning = false;
     });
     carl = carlTran.GetComponent<Carl>();
 }
Beispiel #3
0
    public void Die()
    {
        died = true;
        GetComponent <Image>().raycastTarget = false;

        if ((harmless || !gameController.action) && !gameController.learning)
        {
            TweenAlpha twA = TweenAlpha.Begin(gameObject, 0.5f, 0.0f);
            twA.from = 0.5f;
            twA.SetOnFinished(() =>
            {
                Destroy(gameObject);
            });

            return;
        }

        float z = type == TargetType.Right ? -15 : 15;

        Blood.SetActive(true);
        Vector3 pos = Blood.transform.localPosition;

        pos.x = 15 * Mathf.Sign(z);
        Blood.transform.localPosition = pos;

        TweenRotation twR = TweenRotation.Begin(Body, 0.05f, Quaternion.Euler(0, 0, z));

        twR.quaternionLerp = true;
        twR.method         = UITweener.Method.EaseIn;
        twR.style          = UITweener.Style.PingPong;
        twR.onLoop         = () =>
        {
            twR.style = UITweener.Style.Once;
        };
        twR.SetOnFinished(() => {
            TweenAlpha twA = TweenAlpha.Begin(gameObject, 0.5f, 0.0f);
            //twA.from = 0.5f;
            twA.SetOnFinished(() =>
            {
                Destroy(gameObject);
            });
        });
    }
Beispiel #4
0
    private void checkCollison(float positionThreshold, float angleThreshold)
    {
        float distance = Vector3.Distance(m_transform.localPosition, targetPosition);

        if (distance <= positionThreshold)
        {
            print("position ok");
        }
        if (distance <= positionThreshold &&
            Vector3.Angle(m_transform.right, targetRight) < angleThreshold &&
            Vector3.Angle(m_transform.up, targetUp) < angleThreshold &&
            Vector3.Angle(m_transform.forward, targetForward) < angleThreshold
            )//判断为达到正确位置
        {
            TouchableObject tobj = GetComponent <TouchableObject>();
            tobj.SetDraggable(false);
            tobj.SetRotatable(false);
            TweenRotation tween = TweenRotation.Begin(gameObject, 0.5f, targetRotation);
            tween.method = UITweener.Method.EaseInOut;
            UITweener tweener = TweenPosition.Begin(gameObject, 0.5f, targetPosition);
            tweener.method = UITweener.Method.EaseInOut;
            //TweenRotation tween = GetComponent<TweenRotation>();
            tween.from = m_transform.localEulerAngles;

            tween.to = targetAngles;
            float y = tween.from.y;
            if (Mathf.Abs(360 - tween.from.y) < Mathf.Abs(tween.from.y - 0))
            {
                //tween.from = new Vector3(tween.from.x, tween.from.y - 360, tween.from.z);
                tween.to = new Vector3(tween.to.x, tween.to.y + 360, tween.to.z);
            }
            Debug.Log("from:" + tween.from + "to:" + tween.to);
            //tween.PlayForward();
            //BlockManager.Instance.AddScore();
            tween.SetOnFinished(BlockManager.Instance.AddScore);
            isFinished = true;//标志该结构已经归位
            //targetRotation.
        }
    }
Beispiel #5
0
    public override void shooting(Vector3 position)
    {
        GameObject gOb, bullet;
        Vector3    deltaRotHand, deltaRotBody;

        if (!animPlaying)
        {
            GameObject clone = copy(gameObject);
            clone.GetComponent <PlayerController>().Header.SetActive(false);
            clone.GetComponent <PlayerController>().enabled = false;
        }

        if (position.x > transform.position.x)
        {
            if (!animPlaying)
            {
                HandRight.transform.localEulerAngles = HandRightRotDefault;
            }
            if (!animPlaying)
            {
                ChildHandRight.transform.localEulerAngles = ChildHandRightRotDefault;
            }

            gOb = HandLeft;
            target(gOb, position, true);

            deltaRotHand    = gOb.transform.eulerAngles;
            deltaRotHand.z += 15;

            deltaRotBody    = Body.transform.localEulerAngles;
            deltaRotBody.z += 5;

            //GetComponent<Animator>().SetTrigger("Quay Trai");

            bullet = GunLeft.transform.GetChild(0).gameObject;
        }
        else
        {
            if (!animPlaying)
            {
                HandLeft.transform.localEulerAngles = HandLeftRotDefault;
            }
            if (!animPlaying)
            {
                ChildHandLeft.transform.localEulerAngles = ChildHandLeftRotDefault;
            }

            gOb = HandRight;
            target(gOb, position, false);

            deltaRotHand    = gOb.transform.eulerAngles;
            deltaRotHand.z -= 15;

            deltaRotBody    = Body.transform.localEulerAngles;
            deltaRotBody.z -= 5;

            //GetComponent<Animator>().SetTrigger("Quay Phai");

            bullet = GunRight.transform.GetChild(0).gameObject;
        }

        animPlaying = true;

        TweenRotation twRHand = TweenRotation.Begin(gOb, 0.05f, Quaternion.Euler(deltaRotHand));

        //twRHand.worldSpace = true;
        twRHand.method = UITweener.Method.EaseIn;
        twRHand.style  = UITweener.Style.PingPong;
        twRHand.onLoop = () =>
        {
            twRHand.style = UITweener.Style.Once;
        };
        twRHand.SetOnFinished(() => { animPlaying = false; });

        Body.transform.localEulerAngles = Vector3.zero;
        TweenRotation twRBody = TweenRotation.Begin(Body, 0.05f, Quaternion.Euler(deltaRotBody));

        twRBody.quaternionLerp = true;
        twRBody.method         = UITweener.Method.EaseIn;
        twRBody.style          = UITweener.Style.PingPong;
        twRBody.onLoop         = () =>
        {
            twRBody.style = UITweener.Style.Once;
        };

        //animator.SetTrigger("Attack LB");

        if (!bullet.activeSelf)
        {
            bullet.SetActive(true);
        }
        StartCoroutine(delay(0.1f, () => { if (bullet.activeSelf)
                                           {
                                               bullet.SetActive(false);
                                           }
                             }));
    }