Exemple #1
0
        /// <summary>This will return the transformation matrix used to convert between world space and slice sprite space.</summary>
        public static Matrix4x4 CalculateMatrix(Vector2 startPos, Vector2 endPos, float thickness)
        {
            var mid   = (startPos + endPos) / 2.0f;
            var vec   = endPos - startPos;
            var size  = new Vector2(thickness, vec.magnitude);
            var angle = D2dHelper.Atan2(vec) * -Mathf.Rad2Deg;

            return(D2dStamp.CalculateMatrix(mid, size, angle));
        }
Exemple #2
0
        protected virtual void Update()
        {
            cooldown -= Time.deltaTime;

            if (cooldown <= 0.0f)
            {
                cooldown = Delay;

                var angle = Random.Range(0.0f, 360.0f);

                D2dStamp.All(Paint, transform.position, Size, angle, Shape, Color, Layers);
            }
        }
Exemple #3
0
        protected virtual void Start()
        {
            if (Stamp == true)
            {
                var stampPosition = transform.position;
                var stampAngle    = StampRandomDirection == true?Random.Range(-180.0f, 180.0f) : 0.0f;

                D2dStamp.All(StampPaint, stampPosition, StampSize, stampAngle, StampShape, StampColor, Mask);
            }

            if (Raycast == true && RaycastCount > 0)
            {
                StartCoroutine(DelayForce());
            }
        }
        protected virtual void Update()
        {
            // Main camera exists?
            var mainCamera = Camera.main;

            if (mainCamera != null)
            {
                // World position of the mouse
                var position = D2dHelper.ScreenToWorldPosition(Input.mousePosition, Intercept, mainCamera);

                // Begin dragging
                if (Input.GetKey(Requires) == true && down == false)
                {
                    down = true;
                }

                // End dragging
                if (Input.GetKey(Requires) == false && down == true)
                {
                    down = false;

                    // Stamp at that point
                    D2dStamp.All(Paint, position, Size, Angle, Shape, Color, Layers);
                }

                // Update indicator?
                if (down == true && IndicatorPrefab != null)
                {
                    if (indicatorInstance == null)
                    {
                        indicatorInstance = Instantiate(IndicatorPrefab);
                    }

                    indicatorInstance.transform.position = position;
                }
                // Destroy indicator?
                else if (indicatorInstance != null)
                {
                    Destroy(indicatorInstance.gameObject);
                }
            }
        }
Exemple #5
0
 public static void All(D2dDestructible.PaintType paint, Vector2 startPos, Vector2 endPos, float thickness, Texture2D shape, Color color, int layerMask = -1)
 {
     D2dStamp.All(paint, CalculateMatrix(startPos, endPos, thickness), shape, color, layerMask);
 }