Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (IsPushed == false && Input.GetMouseButtonDown(0))
        {
            IsPushed      = true;
            pushTime      = 0f;
            CurrentStatus = SwordStatus.SwordStatus_Up;
            StartUpLength = transform.localScale.y;
        }

        if (IsPushed)
        {
            pushTime += Time.deltaTime;
        }
        else
        {
            if (CurrentStatus == SwordStatus.SwordStatus_Down)
            {
                downTime += Time.deltaTime;
            }
        }

        if (IsPushed && Input.GetMouseButtonUp(0))
        {
            IsPushed        = false;
            StartDownLength = transform.localScale.y;

            downTime      = 0;
            CurrentStatus = SwordStatus.SwordStatus_Down;
        }

        UpdateSword();
    }
Пример #2
0
 void UpdateSword()
 {
     pushTime += Time.deltaTime;
     if (CurrentStatus == SwordStatus.SwordStatus_Up
         )
     {
         float l = StartUpLength + pushTime * UpSpeed + pushTime * pushTime * UpAccSpeed / 2;
         UpdateSwordLength(l);
     }
     else if (CurrentStatus == SwordStatus.SwordStatus_Freeze)
     {
         float l = StartUpLength + pushTime * UpSpeed + pushTime * pushTime * UpAccSpeed / 2;
         UpdateSwordLength(l);
     }
     else if (CurrentStatus == SwordStatus.SwordStatus_Down)
     {
         float l = StartDownLength - downTime * DownSpeed - downTime * downTime * DownAccSpeed / 2;
         if (l <= SwordLength)
         {
             CurrentStatus = SwordStatus.SwordStatus_Normal;
             l             = SwordLength;
         }
         UpdateSwordLength(l);
     }
     else if (CurrentStatus == SwordStatus.SwordStatus_GameOver)
     {
         return;
     }
     else
     {
         UpdateSwordLength(SwordLength);
     }
 }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        if (CurrentStatus == SwordStatus.SwordStatus_GameOver)
        {
            return;
        }

        if (CurrentStatus == SwordStatus.SwordStatus_Freeze)
        {
            CurrentFreezeTime += Time.deltaTime;
            if (CurrentFreezeTime >= TotalFreezeTime)
            {
                CurrentStatus     = SwordStatus.SwordStatus_Up;
                CurrentFreezeTime = 0;
            }
        }

        Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, -Camera.main.transform.position.z);
        Vector3 pos      = Camera.main.ScreenToWorldPoint(mousePos);

        DrawAimLine(pos);

        if (Input.GetMouseButtonDown(0))
        {
            if (pos.y > transform.position.y + transform.localScale.y ||
                pos.y < transform.position.y)
            {
                return;
            }
            //Debug.Log("Input.mousePosition " + mousePos + " world click pos " + pos);
            float dis = Mathf.Abs(pos.y - transform.position.y) - 0.5f;

            pushTime = 0f;
            if (CurrentStatus != SwordStatus.SwordStatus_Freeze)
            {
                CurrentStatus = SwordStatus.SwordStatus_Up;
            }

            GameMgr.Instance.AddCurrentSwordCount();
            StartUpLength = dis;//transform.localScale.y;

            //Debug.Log("StartUpLength " + dis);
        }

        UpdateSword();
    }
Пример #4
0
    void UpdateSword()
    {
        if (CurrentStatus == SwordStatus.SwordStatus_Up)
        {
            float l = StartUpLength + pushTime * UpSpeed + pushTime * pushTime * UpAccSpeed / 2;
            UpdateSwordLength(l);
        }
        else if (CurrentStatus == SwordStatus.SwordStatus_Down)
        {
            float l = StartDownLength - downTime * DownSpeed - downTime * downTime * DownAccSpeed / 2;
            if (l <= SwordLength)
            {
                CurrentStatus = SwordStatus.SwordStatus_Normal;
                l             = SwordLength;
            }
            UpdateSwordLength(l);
        }

        else
        {
            UpdateSwordLength(SwordLength);
        }
    }
Пример #5
0
 // Start is called before the first frame update
 void Start()
 {
     StartUpLength = SwordLength;
     CurrentStatus = SwordStatus.SwordStatus_Up;
 }
Пример #6
0
 public void Freeze()
 {
     CurrentStatus     = SwordStatus.SwordStatus_Freeze;
     CurrentFreezeTime = 0;
 }
Пример #7
0
 // Start is called before the first frame update
 void Start()
 {
     CurrentStatus = SwordStatus.SwordStatus_Normal;
 }