예제 #1
0
 private void OnMouseDown()
 {
     if (board.currentState == GameState.MOVE && dataTracker.GetSessionState() != SessionState.FINISHED)
     {
         firstTouchPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         mouseDown          = true;
     }
 }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (powerLevel != healthBar.fillAmount)
        {
            healthBar.fillAmount = Mathf.Lerp(healthBar.fillAmount, powerLevel * .01f, Time.deltaTime * lerpSpeed);
        }
        if (healthBar.fillAmount == 1f)
        {
            if (!powerReady)
            {
                red        = 255;
                isUp       = false;
                powerReady = true;
                currentAlert.SetActive(true);
            }
            if (isUp)
            {
                float tempRed = red + Time.deltaTime * 300f;
                red             = Convert.ToByte(Mathf.RoundToInt(Mathf.Min(tempRed, 255)));
                healthBar.color = new Color32(255, red, red, 255);
                if (red == 255)
                {
                    isUp = false;
                }
            }
            else
            {
                float tempRed = red - Time.deltaTime * 300f;
                red             = Convert.ToByte(Mathf.RoundToInt(Mathf.Max(tempRed, 0)));
                healthBar.color = new Color32(255, red, red, 255);
                if (red == 0)
                {
                    isUp = true;
                }
            }
        }

        if (Input.GetMouseButtonDown(1) && healthBar.fillAmount == 1f)
        {
            Activate();
        }

        if (dataTracker.GetSessionState() != SessionState.NOTSTARTED)
        {
            if (isLeft)
            {
                Quaternion quar = Quaternion.Euler(0, 0, 6.2f);
                icon.transform.localRotation = Quaternion.Lerp(icon.transform.localRotation, quar, Time.deltaTime * 1.2f);
                if (icon.transform.localRotation.z > .05f)
                {
                    isLeft = false;
                }
            }
            else
            {
                Quaternion quar = Quaternion.Euler(0, 0, -6.2f);
                icon.transform.localRotation = Quaternion.Lerp(icon.gameObject.transform.localRotation, quar, Time.deltaTime * 1.2f);
                if (icon.transform.localRotation.z < -.05f)
                {
                    isLeft = true;
                }
            }
        }
    }