Example #1
0
        private void InstantianteMovementAreaSprites(int count)
        {
            MovementAreaSprite.transform.localScale = new Vector3(SpriteScale + SpriteScale / 3, SpriteScale, 1); // x needs to be 30% longer then y

            for (int i = 0; i < count; i++)
            {
                var instance = Instantiate(MovementAreaSprite, Vector3.zero, Quaternion.Euler(new Vector3(90, 0, 0))) as Transform;
                instance.parent = transform.GetChild(0);
                instance.gameObject.SetActive(false);
                MovementAreaSprites.Add(instance);
            }
        }
Example #2
0
        private void ChangeColorOfMouseSprite()
        {
            if (Vector3.Distance(transform.position, MouseController.Instance.GetMousePosition()) < MovingDistance + 0.1f) // Moving distance + a small extra distance
            {
                var nearestSprites = MovementAreaSprites.FindAll(s => Vector3.Distance(s.position, MouseController.Instance.GetMousePosition()) < SpriteScale);

                var nearestSprite = GetNearestMovementSprite(nearestSprites);

                if (nearestSprite)
                {
                    nearestSprite.GetComponent <SpriteRenderer>().color = Color.red;
                }
            }
        }
Example #3
0
        private IEnumerator HideAllMovementSprites()
        {
            MovementAreaSprites.ForEach(spriteObject => spriteObject.gameObject.SetActive(false));

            return(null);
        }