Esempio n. 1
0
        public static void Visualize()
        {
            if (CommandManager.sendType == SendState.None)
            {
                return;
            }
            Interfacing.Visualize();
            if (CurrentBuildTile.IsNotNull())
            {
                if (InputManager.GetInformationDown())
                {
                    if (GUIManager.CanInteract)
                    {
                        GUIManager.InformationDown();
                        CurrentBuildTile = null;
                    }
                }
            }

            BuildManager.Visualize();

            if (IsGathering)
            {
                if (InputManager.GetQuickDown())
                {
                    IsGathering = false;
                    return;
                }

                if (InputManager.GetInformationDown() || CurrentInterfacer.InformationGather == InformationGatherType.None)
                {
                    ProcessInterfacer(CurrentInterfacer);
                }
            }
            else
            {
                if (Selector.MainSelectedAgent != null)
                {
                    if (InputManager.GetQuickDown())
                    {
                        LSAgent target;
                        if (Interfacing.MousedAgent.IsNotNull() &&
                            PlayerManager.GetAllegiance(Interfacing.MousedAgent) == AllegianceType.Enemy &&
                            Selector.MainSelectedAgent.Scanner != null)
                        {
                            ProcessInterfacer((QuickTarget));
                        }
                        else
                        {
                            ProcessInterfacer((QuickPos));
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public static void Initialize(GameManager gameManager)
        {
            MainGameManager = gameManager;
            Managers        = gameManager.Managers;

            if (!Loaded)
            {
                Setup();
                Loaded = true;
            }


            SimulationTimer.Reset();
            SimulationTimer.Start();
            LSDatabaseManager.Initialize();
            LSUtility.Initialize(1);
            Interfacing.Initialize();
            InfluenceCount = 0;
            Time.timeScale = 1f;
            Stalled        = true;

            FrameCount          = 0;
            InfluenceFrameCount = 0;

            GridManager.Generate();
            GridManager.Initialize();

            TeamManager.Initialize();

            CoroutineManager.Initialize();
            FrameManager.Initialize();

            CommandManager.Initialize();
            BehaviourHelper.GlobalInitialize();

            AgentController.Initialize();
            TeamManager.LateInitialize();

            PhysicsManager.Initialize();
            PlayerManager.Initialize();
            SelectionManager.Initialize();
            InfluenceManager.Initialize();
            ProjectileManager.Initialize();

            foreach (LSManager manager in Managers)
            {
                manager.Initialize();
            }

            LoadSceneObjects();

            Started = true;
            ClientManager.Initialize();
        }
Esempio n. 3
0
        private static void ProcessInterfacer(AbilityInterfacer facer)
        {
            switch (facer.InformationGather)
            {
            case InformationGatherType.Position:
                curCom          = new Command(facer.ListenInput);
                curCom.Position = Interfacing.GetWorldPosD(Input.mousePosition);
                break;

            case InformationGatherType.Target:
                curCom = new Command(facer.ListenInput);
                if (Interfacing.MousedAgent.IsNotNull())
                {
                    curCom.Target = Interfacing.MousedAgent.LocalID;
                }
                break;

            case InformationGatherType.PositionOrTarget:
                curCom = new Command(facer.ListenInput);
                if (Interfacing.MousedAgent.IsNotNull())
                {
                    curCom.Target = Interfacing.MousedAgent.GlobalID;
                }
                else
                {
                    curCom.Position = Interfacing.GetWorldPosD(Input.mousePosition);
                }
                break;

            case InformationGatherType.None:
                curCom = new Command(facer.ListenInput);
                break;
            }
            if (facer.MarkType != MarkerType.None)
            {
                Interfacing.ActivateMarkerOnMouse(facer.MarkType);
            }
            Send(curCom);
        }
Esempio n. 4
0
 public static void Initialize()
 {
     Interfacing.Initialize();
     IsGathering       = false;
     CurrentInterfacer = null;
 }
        public static void Update()
        {
            MousePosition      = Input.mousePosition;
            MouseWorldPosition = Interfacing.GetWorldPos(MousePosition);
            CanClearSelection  = !Input.GetKey(KeyCode.LeftShift);
            GetMousedAgent();

            if (Boxing)
            {
                BoxingTime += Time.deltaTime;
                if (MousePosition != BoxEnd)
                {
                    Vector2 RaycastTopLeft;
                    Vector2 RaycastTopRight;
                    Vector2 RaycastBotLeft;
                    Vector2 RaycastBotRight;

                    BoxEnd = MousePosition;
                    if (BoxStart.x < BoxEnd.x)
                    {
                        RaycastTopLeft.x  = BoxStart.x;
                        RaycastBotLeft.x  = BoxStart.x;
                        RaycastTopRight.x = BoxEnd.x;
                        RaycastBotRight.x = BoxEnd.x;
                    }
                    else
                    {
                        RaycastTopLeft.x  = BoxEnd.x;
                        RaycastBotLeft.x  = BoxEnd.x;
                        RaycastTopRight.x = BoxStart.x;
                        RaycastBotRight.x = BoxStart.x;
                    }
                    if (BoxStart.y < BoxEnd.y)
                    {
                        RaycastBotLeft.y  = BoxStart.y;
                        RaycastBotRight.y = BoxStart.y;
                        RaycastTopLeft.y  = BoxEnd.y;
                        RaycastTopRight.y = BoxEnd.y;
                    }
                    else
                    {
                        RaycastBotLeft.y  = BoxEnd.y;
                        RaycastBotRight.y = BoxEnd.y;
                        RaycastTopLeft.y  = BoxStart.y;
                        RaycastTopRight.y = BoxStart.y;
                    }

                    Box_TopLeft     = Interfacing.GetWorldPos(RaycastTopLeft);
                    Box_TopRight    = Interfacing.GetWorldPos(RaycastTopRight);
                    Box_BottomLeft  = Interfacing.GetWorldPos(RaycastBotLeft);
                    Box_BottomRight = Interfacing.GetWorldPos(RaycastBotRight);
                }

                ClearBox();
                int lecount = 0;
                if ((BoxEnd - BoxStart).sqrMagnitude >= MinBoxSqrDist)
                {
                    bufferBoxedAgents.Clear();
                    for (int i = 0; i < PlayerManager.AgentControllerCount; i++)
                    {
                        var agentController = PlayerManager.GetAgentController(i);
                        for (int j = 0; j < AgentController.MaxAgents; j++)
                        {
                            if (agentController.LocalAgentActive [j])
                            {
                                curAgent = agentController.LocalAgents [j];
                                if (curAgent.CanSelect)
                                {
                                    if (curAgent.RefEquals(MousedAgent))
                                    {
                                        bufferBoxedAgents.Add(curAgent);
                                    }
                                    else
                                    {
                                        agentPos = curAgent.Position2;
                                        Edge     = Box_TopRight - Box_TopLeft;
                                        Point    = agentPos - Box_TopLeft;
                                        if (DotEdge() < 0)
                                        {
                                            Edge  = Box_BottomRight - Box_TopRight;
                                            Point = agentPos - Box_TopRight;
                                            if (DotEdge() < 0)
                                            {
                                                Edge  = Box_BottomLeft - Box_BottomRight;
                                                Point = agentPos - Box_BottomRight;
                                                if (DotEdge() < 0)
                                                {
                                                    Edge  = Box_TopLeft - Box_BottomLeft;
                                                    Point = agentPos - Box_BottomLeft;
                                                    if (DotEdge() < 0)
                                                    {
                                                        bufferBoxedAgents.Add(curAgent);
                                                        continue;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    bufferBoxable.FastClear();
                    bool noneBoxable = true;
                    if (bufferBoxedAgents.Count > 0)
                    {
                        int peakBoxPriority = bufferBoxedAgents.PeekMax().BoxPriority;
                        while (bufferBoxedAgents.Count > 0)
                        {
                            LSAgent agent = bufferBoxedAgents.PopMax();
                            if (agent.BoxPriority < peakBoxPriority)
                            {
                                break;
                            }
                            BoxAgent(agent);
                        }
                    }
                }
                else
                {
                    BoxAgent(MousedAgent);
                }

                if (Input.GetMouseButtonUp(0))
                {
                    if (CanClearSelection)
                    {
                        ClearSelection();
                    }
                    if (PlayerManager.IsInterfacing == false)
                    {
                        SelectBoxedAgents();
                    }

                    Boxing = false;
                }
            }
            else
            {
                if (PlayerManager.IsInterfacing == false && InputManager.GetInformationDown())
                {
                    CheckBoxDistance = true;
                    Boxing           = true;
                    BoxingTime       = 0f;
                    BoxStart         = MousePosition;
                    BoxEnd           = MousePosition;
                }
            }
        }
 private static void GetMousedAgent()
 {
     MouseOver(Interfacing.GetScreenAgent(Input.mousePosition, (agent) => {
         return(agent.CanSelect && PlayerManager.ContainsController(agent.Controller));
     }));
 }