Advertisement
Guest User

Shapes1

a guest
Feb 29th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. [System.Serializable]
  6. public class Shape
  7. {
  8. public GameObject Prefab;
  9. public SpriteRenderer[] InnerImages;
  10. public Vector3 Position;
  11. public Quaternion Rotation;
  12.  
  13. public string ShapeTag;
  14.  
  15.  
  16. public void CreateShape(GameObject gameObject, SpriteRenderer[] images, Vector3 pos, Quaternion rot, string tag)
  17. {
  18. Prefab = gameObject;
  19. InnerImages = images;
  20. Position = pos;
  21. Rotation = rot;
  22. ShapeTag = tag;
  23. }
  24.  
  25. Shape GetShape()
  26. {
  27. return this;
  28. }
  29.  
  30. void SetShapePosition(Vector3 pos)
  31. {
  32. Position = pos;
  33. }
  34.  
  35. public Shape SetShapeRandomColours(Color[] colors, Shape shape)
  36. {
  37. if(colors.Length != 0)
  38. {
  39. foreach(SpriteRenderer sr in shape.InnerImages)
  40. {
  41. sr.color = colors[GetRandom(colors.Length)];
  42. }
  43. }else{
  44. Debug.Log("NO COLOURS TO RANDOMISE>..");
  45. }
  46.  
  47. return shape;
  48.  
  49. }
  50. //GENERIC RETURN RANDOM METHOD.
  51. private int GetRandom(int itemLength)
  52. {
  53. int random = Random.Range(0, itemLength);
  54. return random;
  55. }
  56.  
  57.  
  58.  
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement