1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using Random = UnityEngine.Random;
- public class RobotManager
- {
- #region Config
- public static List<Robot> Robots = new List<Robot>();
- #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<Robot>();
- }
- public static void Update()
- {
- for (int i = 0; i < Robots.Count; i++)
- {
- if (Robots[i].Update())
- {
- Robots[i--].Deactivate();
- }
- }
- }
- }
|