using System; using System.Collections; using System.Collections.Generic; using Random = UnityEngine.Random; public class RobotManager { #region Config public static List Robots = new List(); #endregion public static void AddRobot(int sfsRoomID, int maxRobot) { Robot.Initialize(); Robot robot = new Robot(); robot.Connect(sfsRoomID, maxRobot); Robots.Add(robot); } private static float MinRandomTime = 3f; private static float MaxRandomTime = 10f; public static void DeactivateAllRobots(bool afterRandomTime) { if (afterRandomTime) { foreach (var robot in Robots) { DelayCall.Call(Random.Range(MinRandomTime, MaxRandomTime), robot.Deactivate); } } else { foreach (var robot in Robots) { robot.Deactivate(); } } Robots = new List(); } public static void Update() { for (int i = 0; i < Robots.Count; i++) { if (Robots[i].Update()) { Robots[i--].Deactivate(); } } } }