Scene_Anime_MultiUnit.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using CrossgateToolkit;
  5. using UnityEngine;
  6. using Random = UnityEngine.Random;
  7. public class Scene_MultiUnit : MonoBehaviour
  8. {
  9. public Transform UnitContainer;
  10. public Prefeb_Unit unitPrefeb;
  11. List<Prefeb_Unit> units = new List<Prefeb_Unit>();
  12. private void Awake()
  13. {
  14. Util.Init();
  15. }
  16. void Start()
  17. {
  18. int x = 18;
  19. int y = 5;
  20. int width = x * 60;
  21. int height = y * 100;
  22. for (int i = 0; i < x; i++)
  23. {
  24. for (int j = 0; j < y; j++)
  25. {
  26. Prefeb_Unit unit = Instantiate(unitPrefeb, UnitContainer);
  27. unit.name = "Unit_" + i + "_" + j;
  28. unit.RectTransform.anchoredPosition =
  29. new Vector2(-width / 2f + i * 60, -height / 2f + j * 100 + 10);
  30. unit.animePlayer.Serial = Util.GetRandomSerial();
  31. unit.animePlayer.DirectionType = Util.GetRandomDirection();
  32. unit.animePlayer.ActionType = (Anime.ActionType)Random.Range(0, 21);
  33. units.Add(unit);
  34. }
  35. }
  36. }
  37. public void ChangeSerial()
  38. {
  39. foreach (var unit in units)
  40. {
  41. unit.animePlayer.Serial = Util.GetRandomSerial();
  42. }
  43. }
  44. public void ChangeDirection()
  45. {
  46. foreach (var unit in units)
  47. {
  48. unit.animePlayer.DirectionType = Util.GetRandomDirection();
  49. }
  50. }
  51. public void ChangeAction()
  52. {
  53. foreach (var unit in units)
  54. {
  55. unit.animePlayer.ActionType = (Anime.ActionType)Random.Range(0, 21);
  56. }
  57. }
  58. // Update is called once per frame
  59. void Update()
  60. {
  61. }
  62. }