Exemplo n.º 1
0
    private void SpawnArmy()
    {
        IGameService service = Services.GetService <IGameService>();

        if (service.Game == null)
        {
            return;
        }
        if (WorldCursor.HighlightedWorldPosition.IsValid)
        {
            IPlayerControllerRepositoryService service2 = service.Game.Services.GetService <IPlayerControllerRepositoryService>();
            string value = Amplitude.Unity.Runtime.Runtime.Registry.GetValue <string>("Debug/GodCursor/SpawnArmy", string.Empty);
            int    index = service2.ActivePlayerController.Empire.Index;
            if (string.IsNullOrEmpty(value))
            {
                return;
            }
            string[] array = value.Split(new char[]
            {
                ','
            });
            if (array.Length == 0)
            {
                return;
            }
            StaticString[] unitDesignsByName = Array.ConvertAll <string, StaticString>(array, (string input) => input);
            OrderSpawnArmy orderSpawnArmy    = new OrderSpawnArmy(index, WorldCursor.HighlightedWorldPosition, unitDesignsByName);
            service2.ActivePlayerController.PostOrder(orderSpawnArmy);
            Diagnostics.Log("Posting order: {0}.", new object[]
            {
                orderSpawnArmy.ToString()
            });
        }
    }
Exemplo n.º 2
0
    private void SpawnMinorArmy()
    {
        IGameService service = Services.GetService <IGameService>();

        if (service.Game == null)
        {
            return;
        }
        if (WorldCursor.HighlightedWorldPosition.IsValid && WorldCursor.HighlightedRegion.MinorEmpire != null)
        {
            IPlayerControllerRepositoryService service2 = service.Game.Services.GetService <IPlayerControllerRepositoryService>();
            UnitDesign          unitDesign = WorldCursor.HighlightedRegion.MinorEmpire.GetAgency <DepartmentOfDefense>().UnitDesignDatabase.UserDefinedUnitDesigns[0];
            List <StaticString> list       = new List <StaticString>();
            for (int i = 0; i < 3; i++)
            {
                list.Add(unitDesign.Name);
            }
            OrderSpawnArmy orderSpawnArmy = new OrderSpawnArmy(WorldCursor.HighlightedRegion.MinorEmpire.Index, WorldCursor.HighlightedWorldPosition, list.ToArray());
            service2.ActivePlayerController.PostOrder(orderSpawnArmy);
            Diagnostics.Log("Posting order: {0}.", new object[]
            {
                orderSpawnArmy.ToString()
            });
        }
    }
Exemplo n.º 3
0
 private void UnitSpawnWorldCursor_Click(object sender, CursorTargetMouseEventArgs e)
 {
     if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.LeftControl))
     {
         this.SpawnEnnemyArmy();
         return;
     }
     if (Input.GetKey(KeyCode.LeftAlt) && Input.GetKey(KeyCode.LeftShift))
     {
         IGameService service = Services.GetService <IGameService>();
         if (service.Game == null || GodWorldCursor.EditorSelectedEmpire == null || GodWorldCursor.EditorSelectedUnitDesigns == null || GodWorldCursor.EditorSelectedUnitDesigns.Length == 0)
         {
             return;
         }
         if (WorldCursor.HighlightedWorldPosition.IsValid)
         {
             OrderSpawnArmy orderSpawnArmy = new OrderSpawnArmy(GodWorldCursor.EditorSelectedEmpire.Index, WorldCursor.HighlightedWorldPosition, GodWorldCursor.EditorSelectedUnitDesigns);
             service.Game.Services.GetService <IPlayerControllerRepositoryService>().ActivePlayerController.PostOrder(orderSpawnArmy);
             Diagnostics.Log("Posting order: {0}.", new object[]
             {
                 orderSpawnArmy.ToString()
             });
             return;
         }
     }
     else
     {
         if (Input.GetKey(KeyCode.RightControl))
         {
             this.SpawnWildlingArmy();
             return;
         }
         if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.LeftAlt))
         {
             this.SpawnMinorArmy();
             return;
         }
         if (Input.GetKey(KeyCode.LeftShift))
         {
             this.SpawnArmy();
             return;
         }
         if (Input.GetKey(KeyCode.LeftAlt))
         {
             this.SpawnCity();
             return;
         }
         if (Input.GetKey(KeyCode.RightShift))
         {
             this.SpawnCamp();
             return;
         }
         if (Input.GetKey(KeyCode.C))
         {
             Amplitude.Unity.View.IViewService service2 = Services.GetService <Amplitude.Unity.View.IViewService>();
             if (service2.CurrentView != null && service2.CurrentView.CameraController is IWorldViewCameraController)
             {
                 (service2.CurrentView.CameraController as IWorldViewCameraController).FocusCameraAt(WorldCursor.HighlightedWorldPosition, false, true);
             }
         }
     }
 }