Skip to content

Commit 304df27

Browse files
committed
add BuyTimeTrialClassCommand
1 parent d367def commit 304df27

File tree

3 files changed

+45
-29
lines changed

3 files changed

+45
-29
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using LitJson;
2+
using System.Text;
3+
using UnityEngine;
4+
using Utils;
5+
using QFramework;
6+
7+
public class BuyTimeTrialClassCommand : AbstractCommand {
8+
private TimeTrialInfo mTimeTrialInfo;
9+
10+
public BuyTimeTrialClassCommand(TimeTrialInfo timeTrialInfo) {
11+
mTimeTrialInfo = timeTrialInfo;
12+
}
13+
14+
protected override void OnExecute() {
15+
StringBuilder sb = new StringBuilder();
16+
JsonWriter w = new JsonWriter(sb);
17+
w.WriteObjectStart();
18+
w.WritePropertyName("cid");
19+
w.Write(mTimeTrialInfo.cid);
20+
w.WriteObjectEnd();
21+
Debug.Log("++++++ " + sb.ToString());
22+
byte[] bytes = Encoding.UTF8.GetBytes(sb.ToString());
23+
CoroutineController.manager.StartCoroutine(this.GetSystem<INetworkSystem>().POSTHTTP(url: this.GetSystem<INetworkSystem>().HttpBaseUrl + RequestUrl.buyTimeTrialClassUrl,
24+
data: bytes,
25+
token: this.GetModel<IGameControllerModel>().Token.Value,
26+
succData: (data) => {
27+
this.GetModel<IUserModel>().Star.Value = (int)data["star"];
28+
mTimeTrialInfo.isHas = true;
29+
this.GetModel<IUserModel>().MapNum.Value++;
30+
this.SendEvent<UnlockTimeTrialEvent>();
31+
this.SendEvent<UpdateHomepageUIEvent>();
32+
}));
33+
}
34+
}

CrazyCar/Assets/Scripts/Command/BuyTimeTrialClassCommand.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CrazyCar/Assets/Scripts/Command/CommandHub.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,6 @@
44
using Utils;
55
using QFramework;
66

7-
public class BuyTimeTrialClassCommand : AbstractCommand {
8-
private TimeTrialInfo mTimeTrialInfo;
9-
10-
public BuyTimeTrialClassCommand(TimeTrialInfo timeTrialInfo) {
11-
mTimeTrialInfo = timeTrialInfo;
12-
}
13-
14-
protected override void OnExecute() {
15-
StringBuilder sb = new StringBuilder();
16-
JsonWriter w = new JsonWriter(sb);
17-
w.WriteObjectStart();
18-
w.WritePropertyName("cid");
19-
w.Write(mTimeTrialInfo.cid);
20-
w.WriteObjectEnd();
21-
Debug.Log("++++++ " + sb.ToString());
22-
byte[] bytes = Encoding.UTF8.GetBytes(sb.ToString());
23-
CoroutineController.manager.StartCoroutine(this.GetSystem<INetworkSystem>().POSTHTTP(url: this.GetSystem<INetworkSystem>().HttpBaseUrl + RequestUrl.buyTimeTrialClassUrl,
24-
data: bytes,
25-
token: this.GetModel<IGameControllerModel>().Token.Value,
26-
succData: (data) => {
27-
this.GetModel<IUserModel>().Star.Value = (int)data["star"];
28-
mTimeTrialInfo.isHas = true;
29-
this.GetModel<IUserModel>().MapNum.Value++;
30-
this.SendEvent<UnlockTimeTrialEvent>();
31-
this.SendEvent<UpdateHomepageUIEvent>();
32-
}));
33-
}
34-
}
35-
367
public class SavaSettingsCommand : AbstractCommand {
378
protected override void OnExecute() {
389
this.SendEvent<ChangeSettingEvent>();

0 commit comments

Comments
 (0)