Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        playerPosition = GameObject.Find("Player").GetComponent <Transform>();

        Vector2 mousePos  = MouseUtils.GetMousePosition();
        float   aimAngle  = MouseUtils.GetAimAngle(transform.position) * Mathf.Rad2Deg + 180;
        int     stepAngle = Mathf.RoundToInt(360f / rotationSteps);

        currentStep = Mathf.RoundToInt(aimAngle / stepAngle) % 4 * stepAngle;

        switch (currentStep)
        {
        default:
        case 0:
        case 360:
            playerBody.sprite = rSprite_Torso;
            playerHead.sprite = rSprite_Head;
            break;

        case 45:
            playerBody.sprite = ruSprite_Torso;
            playerHead.sprite = ruSprite_Head;
            break;

        case 90:
            playerBody.sprite = uSprite_Torso;
            playerHead.sprite = uSprite_Head;
            break;

        case 135:
            playerBody.sprite = ulSprite_Torso;
            playerHead.sprite = ulSprite_Head;
            break;

        case 180:
            playerBody.sprite = lSprite_Torso;
            playerHead.sprite = lSprite_Head;
            break;

        case 225:
            playerBody.sprite = ldSprite_Torso;
            playerHead.sprite = ldSprite_Head;
            break;

        case 270:
            playerBody.sprite = dSprite_Torso;
            playerHead.sprite = dSprite_Head;
            break;

        case 315:
            playerBody.sprite = drSprite_Torso;
            playerHead.sprite = drSprite_Head;
            break;
        }
    }
Ejemplo n.º 2
0
        public IEnumerable <int> SelectIndexes(TextEditor textEditor)
        {
            int start = 0;
            int end   = 0;

            if (textEditor.SelectionLength != 0)
            {
                start = textEditor.SelectionStart;
                end   = textEditor.SelectionStart + textEditor.SelectionLength;
            }
            else
            {
                var position = textEditor.GetPositionFromPoint(MouseUtils.GetMousePosition(textEditor));

                if (position != null)
                {
                    start = textEditor.Document.GetOffset(position.Value.Line, position.Value.Column);
                    end   = start;
                }
            }

            var list = new List <int>();

            for (int i = 0; i < _ranges.Count; i++)
            {
                var range = _ranges[i];
                if ((range.Start <= start && range.End <= start) || (range.Start >= end && range.End >= end))
                {
                    continue;
                }

                list.Add(i);
            }

            return(list);
        }