Exemplo n.º 1
0
 private void Awake()
 {
     image        = GetComponent <Image>();
     spriteScript = transform.parent.GetComponent <CustomisableSprite>();
     image.color  = defaultState;
     rect         = transform.parent.GetComponent <RectTransform>();
 }
 public virtual void OnPointerDown()
 {
     item = Instantiate(spawnedItem, transform.position, Quaternion.identity, CanvasScript.ItemsNode.transform);
     item.movingAnchor.OnPointerDown(null);
     item.movingAnchor.SetSize(spawnedSize);
     isDragged = true;
 }
Exemplo n.º 3
0
    public void MoveDoDie(CustomisableSprite targetRect, Reaction reaction)
    {
        var target = new Vector2(Random.Range(targetRect.leftbottom.x + padding, targetRect.righttop.x - padding),
                                 Random.Range(targetRect.leftbottom.y + padding, targetRect.righttop.y - padding));

        target += new Vector2(0, -0.5f);
        StartCoroutine(MoveAnimate(target, reaction));
    }
Exemplo n.º 4
0
    public void SpawnCoursors(CustomisableSprite sprite, Coursor.Reaction reaction
                              = Coursor.Reaction.random)
    {
        if (sprite == null)
        {
            return;
        }

        StartCoroutine(Creator(sprite, reaction));
    }
Exemplo n.º 5
0
    private IEnumerator Creator(CustomisableSprite sprite, Coursor.Reaction reaction)
    {
        var i = 0;
        var m = Random.Range(1, TaskManager.instance.tasksDone / 8f);

        while (i < m)
        {
            i++;
            Instantiate(coursorPrefab, transform)
            .MoveDoDie(sprite, reaction);
            yield return(new WaitForSeconds(Random.value));
        }
    }
Exemplo n.º 6
0
    public static float Intersection(CustomisableSprite item, CustomisableSprite sprite)
    {
        var a             = item;
        var b             = sprite;
        var xIntersection = 0f;
        var yIntersection = 0f;

        if (a.leftbottom.x > b.leftbottom.x)
        {
            var c = a;
            a = b;
            b = c;
        }

        if (a.righttop.x > b.leftbottom.x)
        {
            var lowerVal   = (a.leftbottom.x > b.leftbottom.x) ? a.leftbottom.x : b.leftbottom.x;
            var highterVal = (a.righttop.x > b.righttop.x) ? b.righttop.x : a.righttop.x;

            xIntersection = highterVal - lowerVal;
        }
        else
        {
            return(0);
        }

        if (a.leftbottom.y > b.leftbottom.y)
        {
            var d = a;
            a = b;
            b = d;
        }

        if (a.righttop.y > b.leftbottom.y)
        {
            var lowerVal   = (a.leftbottom.y > b.leftbottom.y) ? a.leftbottom.y : b.leftbottom.y;
            var highterVal = (a.righttop.y > b.righttop.y) ? b.righttop.y : a.righttop.y;

            yIntersection = highterVal - lowerVal;
        }

        return(xIntersection * yIntersection);
    }