ResultDrop.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. public class ResultDrop : MonoBehaviour
  5. {
  6. public ResultPanel resultPanel;
  7. public Animator animator;
  8. public ResultDropItem[] itemArr;
  9. private List<int> dropList;
  10. private int extraPrice;
  11. public bool mixed;
  12. private bool waitingReward;
  13. // Use this for initialization
  14. void Start ()
  15. {
  16. }
  17. public void Show(List<int> dropList, int extraPrice)
  18. {
  19. this.dropList = dropList;
  20. this.extraPrice = extraPrice;
  21. List<int> list = new List<int> ();
  22. for(int i=0; i<dropList.Count; i++)
  23. {
  24. int index = Random.Range (0, list.Count);
  25. list.Insert (index, dropList[i]);
  26. }
  27. for(int i=0; i<list.Count; i++)
  28. {
  29. itemArr [i].data = list [i];
  30. itemArr [i].HideOpen ();
  31. }
  32. animator.Play ("DropShow");
  33. }
  34. public void Mix()
  35. {
  36. for(int i=0; i<dropList.Count; i++)
  37. {
  38. itemArr [i].data = 0;
  39. }
  40. animator.Play ("DropMix");
  41. }
  42. public void MixComplete()
  43. {
  44. mixed = true;
  45. for(int i=0; i<itemArr.Length; i++)
  46. {
  47. itemArr [i].ShowOpen (0);
  48. }
  49. }
  50. public void Select(int index)
  51. {
  52. if(mixed && !waitingReward && (int)(itemArr[index].data) == 0)
  53. {
  54. waitingReward = true;
  55. itemArr [index].Shake (true);
  56. resultPanel.SelectDrop (index);
  57. }
  58. }
  59. public void Reward(int index, int dropIndex)
  60. {
  61. waitingReward = false;
  62. for(int i=0; i<itemArr.Length; i++)
  63. {
  64. ResultDropItem item = itemArr [i];
  65. if(i == index)
  66. {
  67. item.Shake (false);
  68. item.data = dropList [dropIndex];
  69. item.HideOpen ();
  70. }
  71. else if((int)(item.data) == 0)
  72. {
  73. item.ShowOpen (extraPrice);
  74. }
  75. }
  76. }
  77. public void RewardFaild(int index)
  78. {
  79. waitingReward = false;
  80. itemArr [index].Shake (false);
  81. }
  82. }