MapSelectPanel.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. public class MapSelectPanel : MonoBehaviour {
  5. public Text title;
  6. public Text description;
  7. public Image tipImg;
  8. public Text[] tipTxtArr;
  9. public Sprite[] tipImages;
  10. private int currentIndex;
  11. private MapData[] mapDataArr;
  12. public MainController mainController;
  13. // Use this for initialization
  14. void Start ()
  15. {
  16. // mapDataArr = MapData.GetMapDataArr();
  17. Show(0);
  18. }
  19. public void Prev()
  20. {
  21. Show(currentIndex - 1);
  22. }
  23. public void Next()
  24. {
  25. Show(currentIndex + 1);
  26. }
  27. public void Show(int index)
  28. {
  29. this.currentIndex = index;
  30. while(currentIndex < 0)
  31. {
  32. currentIndex += mapDataArr.Length;
  33. }
  34. while(currentIndex >= mapDataArr.Length)
  35. {
  36. currentIndex -= mapDataArr.Length;
  37. }
  38. MapData mapData = mapDataArr[currentIndex];
  39. title.text = mapData.name;
  40. description.text = Language.GetStr("MapInfo", "winCondition") + mapData.description;
  41. tipImg.sprite = tipImages[currentIndex];
  42. for(int i=0; i<tipTxtArr.Length; i++)
  43. {
  44. tipTxtArr[i].text = mapData.tips[i];
  45. }
  46. }
  47. public void StartLocalBattle()
  48. {
  49. mainController.StartLocalBattle (mapDataArr [currentIndex].id);
  50. }
  51. public void StartRemoteBattle()
  52. {
  53. mainController.StartRemoteBattle (mapDataArr [currentIndex].id, MapData.Mode.Normal);
  54. }
  55. // Update is called once per frame
  56. void Update ()
  57. {
  58. }
  59. }