123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using System;
- using System.Collections.Generic;
- namespace ET.Server
- {
- public static class RobotCaseSystem
- {
-
- public static async ETTask NewRobot(this RobotCase self, int count, List<Scene> scenes)
- {
- ETTask[] tasks = new ETTask[count];
- for (int i = 0; i < count; ++i)
- {
- tasks[i] = self.NewRobot(scenes);
- }
- await ETTaskHelper.WaitAll(tasks);
- }
- private static async ETTask NewRobot(this RobotCase self, List<Scene> scenes)
- {
- try
- {
- scenes.Add(await self.NewRobot());
- }
- catch (Exception e)
- {
- Log.Error(e);
- }
- }
-
- public static async ETTask NewZoneRobot(this RobotCase self, int zone, int count, List<Scene> scenes)
- {
- ETTask[] tasks = new ETTask[count];
- for (int i = 0; i < count; ++i)
- {
- tasks[i] = self.NewZoneRobot(zone + i, scenes);
- }
- await ETTaskHelper.WaitAll(tasks);
- }
-
- private static async ETTask NewZoneRobot(this RobotCase self, int zone, List<Scene> scenes)
- {
- try
- {
- scenes.Add(await self.NewRobot(zone));
- }
- catch (Exception e)
- {
- Log.Error(e);
- }
- }
- public static async ETTask<Scene> NewRobot(this RobotCase self, int zone)
- {
- return await self.NewRobot(zone, $"Robot_{zone}");
- }
- public static async ETTask<Scene> NewRobot(this RobotCase self, int zone, string name)
- {
- Scene clientScene = null;
- try
- {
- clientScene = await Client.SceneFactory.CreateClientScene(zone, name);
- await Client.LoginHelper.Login(clientScene, zone.ToString(), zone.ToString());
- await Client.EnterMapHelper.EnterMapAsync(clientScene);
- Log.Debug($"create robot ok: {zone}");
- return clientScene;
- }
- catch (Exception e)
- {
- clientScene?.Dispose();
- throw new Exception($"RobotCase create robot fail, zone: {zone}", e);
- }
- }
- private static async ETTask<Scene> NewRobot(this RobotCase self)
- {
- int zone = self.GetParent<RobotCaseComponent>().GetN();
- Scene clientScene = null;
- try
- {
- clientScene = await Client.SceneFactory.CreateClientScene(zone, $"Robot_{zone}");
- await Client.LoginHelper.Login(clientScene, zone.ToString(), zone.ToString());
- await Client.EnterMapHelper.EnterMapAsync(clientScene);
- Log.Debug($"create robot ok: {zone}");
- return clientScene;
- }
- catch (Exception e)
- {
- clientScene?.Dispose();
- throw new Exception($"RobotCase create robot fail, zone: {zone}", e);
- }
- }
- }
- }
|