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); } }
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; } } }
private IEnumerator HideAllMovementSprites() { MovementAreaSprites.ForEach(spriteObject => spriteObject.gameObject.SetActive(false)); return(null); }