PoseService.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Sfs2X.Entities.Data;
  5. public class PoseService : GameRoomService
  6. {
  7. public const int SEND_SCORE_INTERVAL = 5*1000;
  8. protected Dictionary<int, CrystalBaseData> crystalBaseMap;
  9. public PoseService (ResponseDelegate callBack):base(callBack)
  10. {
  11. }
  12. override protected void InitGame()
  13. {
  14. freeTime = 0;
  15. }
  16. public override void RemoveStation (int stationId)
  17. {
  18. int numBlue = 0;
  19. int numRed = 0;
  20. int needRemoveKey = -1;
  21. foreach(KeyValuePair<int, ServiceStation> kvp in stationDict)
  22. {
  23. ServiceStation station = kvp.Value;
  24. if(station.id == stationId)
  25. {
  26. needRemoveKey = station.crystalId;
  27. }
  28. else if(station.teamId == TeamUtil.Team.Blue.GetHashCode())
  29. {
  30. numBlue++;
  31. }
  32. else if(station.teamId == TeamUtil.Team.Red.GetHashCode())
  33. {
  34. numRed++;
  35. }
  36. }
  37. if(needRemoveKey != -1)
  38. {
  39. stationDict.Remove(needRemoveKey);
  40. }
  41. }
  42. public SFSObject GetScoreData(int winTeam)
  43. {
  44. SFSObject data = new SFSObject();
  45. if(isGameOver)
  46. {
  47. return data;
  48. }
  49. data.PutInt("b", blueScore);
  50. data.PutInt("r", redScore);
  51. data.PutInt("t", GetGameTime());
  52. data.PutInt("f", 0);
  53. return data;
  54. }
  55. override protected void DoTask()
  56. {
  57. SendBattleInfo(GetScoreData(-1), GetPlayerChangeData(), GetAiTakerChangeData());
  58. }
  59. }