Ejemplo n.º 1
0
    // 삼각형 내 단위원을 제외한 모든걸 끔. 단, Tstate, isCo 등 값은 안바꿈. SetActive(false)만 해줌.
    private void ClearTri()
    {
        ClearWeaponEffect();
        ClearEdgeActivated();

        CoAngle.SetActive(false);
        CoAngleEffect.SetActive(false);
        CoAngleDeleteEffect.SetActive(false);
        IdleAngleEffect.SetActive(false);

        HypoEffect.SetActive(false);
        HeightEffect.SetActive(false);
        BaseEffect.SetActive(false);

        HypoDeleteEffect.SetActive(false);
        HeightDeleteEffect.SetActive(false);
        BaseDeleteEffect.SetActive(false);

        Bow.SetActive(false);
        Arrow.SetActive(false);
        Spear.SetActive(false);
        Shield.SetActive(false);
        CoBow.SetActive(false);
        CoArrow.SetActive(false);
        CoSpear.SetActive(false);
        CoShield.SetActive(false);

        HypoIdleLineEffect.SetActive(false);
        HypoCoLineEffect.SetActive(false);
        HeightLineEffect.SetActive(false);
        BaseLineEffect.SetActive(false);
    }
Ejemplo n.º 2
0
    void Update()
    {
        // 좌클릭하면 회전시작
        if (isPlay)
        {
            if (Input.GetKeyDown(KeyCode.Mouse0))
            {
                isRotating = true;
                RotateInit();
            }

            // 변, 각, 무기 Effect
            ClearWeaponEffect();
            if (!isRotating)
            {
                ClearTri();
                switch (Tstate)
                {
                case 0:
                    if (onHypo)
                    {
                        HypoEffect.SetActive(true);
                    }
                    else if (onHeight && isCo)
                    {
                        HeightEffect.SetActive(true);
                    }
                    else if (onBase && !isCo)
                    {
                        BaseEffect.SetActive(true);
                    }
                    break;

                case 1:
                    if (onHypo)
                    {
                        HypoDeleteEffect.SetActive(true);
                    }
                    else if (onHeight && !isCo)
                    {
                        BowEffect.SetActive(true);
                        ArrowEffect.SetActive(true);
                        BaseLineEffect.SetActive(true);
                    }
                    else if (onBase && isCo)
                    {
                        CoBowEffect.SetActive(true);
                        CoArrowEffect.SetActive(true);
                        HeightLineEffect.SetActive(true);
                    }
                    break;

                case 2:
                    if (onHeight)
                    {
                        HeightDeleteEffect.SetActive(true);
                    }
                    else if (onHypo && isCo)
                    {
                        CoSpearEffect.SetActive(true);
                        HypoCoLineEffect.SetActive(true);
                    }
                    else if (onBase && isCo)
                    {
                        CoShieldEffect.SetActive(true);
                    }
                    break;

                case 3:
                    if (onBase)
                    {
                        BaseDeleteEffect.SetActive(true);
                    }
                    else if (onHypo && !isCo)
                    {
                        SpearEffect.SetActive(true);
                        HypoIdleLineEffect.SetActive(true);
                    }
                    else if (onHeight && !isCo)
                    {
                        ShieldEffect.SetActive(true);
                    }
                    break;
                }
                if (onCoAngle)
                {
                    if (isCo)
                    {
                        CoAngleDeleteEffect.SetActive(true);
                    }
                    else if (!isCo)
                    {
                        CoAngleEffect.SetActive(true);
                    }
                }
                if (onIdleAngle && isCo)
                {
                    CoAngleDeleteEffect.SetActive(true);
                    IdleAngleEffect.SetActive(true);
                }
            }

            // 키보드'space' or CoAngle 클릭시
            if (Input.GetKeyDown(KeyCode.Space) || (Input.GetKeyDown(KeyCode.Mouse0) && onCoAngle))
            {
                isCo = !isCo;
            }

            // Co상태에서 IdleAngle 클릭시
            if (isCo && Input.GetKeyDown(KeyCode.Mouse0) && onIdleAngle)
            {
                isCo = false;
            }

            if (isCo)
            {
                CoAngle.SetActive(true);
            }
            else
            {
                CoAngle.SetActive(false);
            }

            // 키보드'w' or Hypo 클릭시
            if (Input.GetKeyDown(KeyCode.W) || (Input.GetKeyDown(KeyCode.Mouse0) && onHypo))
            {
                switch (Tstate)
                {
                case 0:
                    Tstate = 1;
                    if (!isCo)
                    {
                        MakeCircle(HypoIdleCircle);
                    }
                    else
                    {
                        MakeCircle(HypoCoCircle);
                    }
                    break;

                case 1:
                    Tstate = 0;
                    HypoIdleCircle.SetActive(false);
                    HypoCoCircle.SetActive(false);
                    break;

                case 2:
                    if (isCo)
                    {
                        if (Input.GetKeyDown(KeyCode.W))
                        {
                            SetAnimationParameters(0, 1);
                            StartCoroutine("Cosec");
                            RotateFinish();
                        }
                        else
                        {
                            CoSpear.SetActive(true);
                            isLaunching = 5;
                        }
                    }
                    break;

                case 3:
                    if (!isCo)
                    {
                        if (Input.GetKeyDown(KeyCode.W))
                        {
                            SetAnimationParameters(0, 1);
                            StartCoroutine("Sec");
                            RotateFinish();
                        }
                        else
                        {
                            Spear.SetActive(true);
                            isLaunching = 2;
                        }
                    }
                    break;
                }
            }

            // 키보드'd' or Height 클릭시
            if (Input.GetKeyDown(KeyCode.D) || (Input.GetKeyDown(KeyCode.Mouse0) && onHeight))
            {
                switch (Tstate)
                {
                case 0:
                    MakeCircle(HeightCircle);
                    Tstate = 2;
                    break;

                case 1:
                    if (!isCo)
                    {
                        if (Input.GetKeyDown(KeyCode.D))
                        {
                            SetAnimationParameters(0, 1);
                            StartCoroutine("Sin");
                            RotateFinish();
                        }
                        else
                        {
                            Bow.SetActive(true);
                            Arrow.SetActive(true);
                            isLaunching = 1;
                        }
                    }
                    break;

                case 2:
                    Tstate = 0;
                    HeightCircle.SetActive(false);
                    break;

                case 3:
                    if (!isCo)
                    {
                        if (Input.GetKeyDown(KeyCode.D))
                        {
                            SetAnimationParameters(0, 1);
                            StartCoroutine("Tan");
                            RotateFinish();
                        }
                        else
                        {
                            Shield.SetActive(true);
                            isLaunching = 3;
                        }
                    }
                    break;
                }
            }

            // 키보드'a' or Base 클릭시
            if (Input.GetKeyDown(KeyCode.A) || (Input.GetKeyDown(KeyCode.Mouse0) && onBase))
            {
                switch (Tstate)
                {
                case 0:
                    MakeCircle(BaseCircle);
                    Tstate = 3;
                    break;

                case 1:
                    if (isCo)
                    {
                        if (Input.GetKeyDown(KeyCode.A))
                        {
                            SetAnimationParameters(0, 1);
                            StartCoroutine("Cos");
                            RotateFinish();
                        }
                        else
                        {
                            CoBow.SetActive(true);
                            CoArrow.SetActive(true);
                            isLaunching = 4;
                        }
                    }
                    break;

                case 2:
                    if (isCo)
                    {
                        if (Input.GetKeyDown(KeyCode.A))
                        {
                            SetAnimationParameters(0, 1);
                            StartCoroutine("Cotan");
                            RotateFinish();
                        }
                        else
                        {
                            CoShield.SetActive(true);
                            isLaunching = 6;
                        }
                    }
                    break;

                case 3:
                    Tstate = 0;
                    BaseCircle.SetActive(false);
                    break;
                }
            }

            ClearEdgeActivated();
            switch (Tstate)
            {
            case 0:
                Tri.transform.localScale = StandardScale;
                break;

            case 1:
                HypoActivated.SetActive(true);
                HypoLength.SetActive(true);
                Tri.transform.localScale = StandardScale * 0.807f;
                break;

            case 2:
                HeightActivated.SetActive(true);
                HeightLength.SetActive(true);
                Tri.transform.localScale = StandardScale * 1.365f;
                break;

            case 3:
                BaseActivated.SetActive(true);
                BaseLength.SetActive(true);
                Tri.transform.localScale = StandardScale;
                break;
            }

            // 마우스 떼면 회전종료
            if (Input.GetKeyUp(KeyCode.Mouse0))
            {
                isRotating = false;
                if (isLaunching != 0)
                {
                    switch (isLaunching)
                    {
                    case 1:
                        StartCoroutine("Sin");
                        break;

                    case 2:
                        StartCoroutine("Sec");
                        break;

                    case 3:
                        StartCoroutine("Tan");
                        break;

                    case 4:
                        StartCoroutine("Cos");
                        break;

                    case 5:
                        StartCoroutine("Cosec");
                        break;

                    case 6:
                        StartCoroutine("Cotan");
                        break;
                    }
                    RotateFinish();
                }
            }

            if (isRotating)
            {
                MousePresentPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition) - CoR;   // 마우스 현재위치는 깨다 기준 상대적 위치
                RotateAngle          = Vector2.Angle(MouseStartPosition, MousePresentPosition);     // RotateAngle 계산
                                                                                                    // Vertor2.Angle은 항상 0<=Angle<180이므로 외적을 이용해서 반환
                if (Vector3.Cross(MouseStartPosition, MousePresentPosition).z < 0)
                {
                    RotateAngle = 360f - RotateAngle;
                }
                // 회전 및 삼각형 중심 - 회전 중심 위치 조정
                Tri.transform.rotation = TriStartRotation * Quaternion.Euler(Vector3.forward * RotateAngle);
                // Hypo, Height, Base Length 같이 회전 (역방향)
                HypoLength.transform.rotation   = Quaternion.Euler(-(Tri.transform.rotation * Vector3.forward));
                HeightLength.transform.rotation = Quaternion.Euler(-(Tri.transform.rotation * Vector3.forward));
                BaseLength.transform.rotation   = Quaternion.Euler(-(Tri.transform.rotation * Vector3.forward));

                Tri.transform.position = Quaternion.Euler(Vector3.forward * RotateAngle) * TriStartPosition + CoR;
            }

            if (Input.GetKeyDown(KeyCode.Mouse1))
            {
                Reset();
            }                                                  // 우클릭 시 초기화
        }
    }