WoodenDummyManager.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. public class WoodenDummyManager : MonoBehaviour {
  5. public Vector2[] bluePosArr;
  6. public float checkInterval = 1.5f;
  7. private float lastCheckTime;
  8. private int index = 0;
  9. // Use this for initialization
  10. void Start ()
  11. {
  12. // lastCheckTime = GameTime.time;
  13. }
  14. // Update is called once per frame
  15. void Update ()
  16. {
  17. if(GameTime.time - lastCheckTime < checkInterval)
  18. return;
  19. lastCheckTime = GameTime.time;
  20. List<CraftConfigData> list = CraftManager.GetInstance ().GetDataList ();
  21. if (index >= list.Count)
  22. {
  23. enabled = false;
  24. return;
  25. }
  26. Create(list[index].id, index, TeamUtil.Team.Blue, bluePosArr[index]);
  27. index++;
  28. }
  29. private int Create(int craftId, int index, TeamUtil.Team team, Vector2 pos)
  30. {
  31. BattleSession battleSession = Session.GetInstance().GetBattleSession();
  32. if (battleSession == null || battleSession.myPlayer == null)
  33. return 0;
  34. float x = pos.x;
  35. float y = pos.y;
  36. CraftData craftData = new CraftData(craftId);
  37. craftData.id = 1000 + index;
  38. craftData.userId = battleSession.myPlayer.userId;
  39. craftData.position = new Vector3(x, 0, y);
  40. craftData.team = team;
  41. craftData.aiType = AI.AIType.Show;
  42. craftData.nick = "";
  43. craftData.isHero = true;
  44. battleSession.GetBattleController().CreateCapsule(craftData);
  45. return 1;
  46. }
  47. }