示例#1
0
    private void Update()
    {
        float stepLength = 360f / spells.Length;
        float mouseAngle =
            NormalizeAngle(Vector3.SignedAngle(Vector3.up, Input.mousePosition - transform.position, Vector3.forward) +
                           stepLength / 2f);
        int activeElement      = (int)(mouseAngle / stepLength);
        int activeGraphElement = activeElement + 1 >= spells.Length ? 0 : activeElement + 1;

        spellInfo.InitGraphics(spells[activeElement]);
        for (int i = 0; i < _pieces.Length; i++)
        {
            if (i == activeGraphElement)
            {
                _pieces[i].cakePiece.color = new Color(1f, 1f, 1f, .75f);
            }
            else
            {
                _pieces[i].cakePiece.color = new Color(1f, 1f, 1f, .5f);
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            playerSpells.ChangeSpell(spells[activeElement]);
            playerSpells.CloseMenu();
        }
    }