void Update()
    {
        if (state != eState.GAME)
        {
            //turnDisplay.SetActive(false);

            forceOnce = false;
        }

        //Game is running
        if (state == eState.GAME)
        {
            if (nationController == null)
            {
                nationController = menuController.nationController;
                if (nationController == menuController.nationController && menuController.nationController != null)
                {
                    forceOnce = true;
                }
            }

            if (forceOnce == true)
            {
                GameSession();

                forceOnce = false;
            }
        }
    }
Beispiel #2
0
 private void Start()
 {
     gameController   = GameObject.Find("Controllers").GetComponent <GameController>();
     eventSystem      = GameObject.Find("Systems").GetComponent <EventSystems>();
     menuController   = GameObject.Find("Controllers").GetComponent <MenuController>();
     nationController = GameObject.Find("Systems").GetComponent <NationController>();
     menuController.topUI.SetActive(true);
     if (GameObject.Find("Date") != null)
     {
         text = GameObject.Find("Date").GetComponent <TextMeshProUGUI>();
     }
     Money            = GameObject.Find("Money");
     Manpower         = GameObject.Find("Manpower");
     Prestiege        = GameObject.Find("Prestiege");
     MilitarySupplies = GameObject.Find("Military Supplies");
     CivilianSupplies = GameObject.Find("Civilian Supplies");
     BuildingSupplies = GameObject.Find("Building Supplies");
     menuController.topUI.SetActive(false);
     eventSystem.Welcome();
     updateText();
     menuController.topUI.SetActive(false);
     menuController.calandar.SetActive(false);
     menuController.flagStuff.SetActive(false);
     menuController.timeScaler.SetActive(false);
 }
Beispiel #3
0
        public NationController CreateNationController(String userId)
        {
            NationController controller = new NationController(AzureNationRepository, AzureSessionRepository);

            controller.ControllerContext.RequestContext.Principal = controller.ControllerContext.RequestContext.Principal = UserRepository.GetPrincipal(userId);
            return(controller);
        }
Beispiel #4
0
        internal static async Task RandomlyDeployReinforcements(GameController game, NationController nations, WorldController world, RegionController regions, Guid sessionId, String ownerId)
        {
            Random   rand    = new Random();
            ISession session = await game.GetSession(sessionId);

            // Get owned regions
            IEnumerable <Guid> ownedRegions = await GetCurrentlyOwnedRegions(world, sessionId, ownerId);

            // Get number of available troops
            UInt32 numberOfAvailableTroops = await nations.GetReinforcements(sessionId);

            Assert.AreNotEqual(0U, numberOfAvailableTroops);

            // Distribute troops over available regions
            Dictionary <Guid, UInt32> regionsToReinforce = new Dictionary <Guid, UInt32>();

            while (numberOfAvailableTroops > 0 && ownedRegions.Count() > 0)
            {
                int  index        = rand.Next(0, ownedRegions.Count());
                Guid targetRegion = ownedRegions.ElementAt(index);
                if (regionsToReinforce.ContainsKey(targetRegion))
                {
                    regionsToReinforce[targetRegion] += 1;
                }
                else
                {
                    regionsToReinforce.Add(targetRegion, 1);
                }
                numberOfAvailableTroops -= 1;
            }

            // Perform the deployment
            foreach (var pair in regionsToReinforce)
            {
                await regions.PostDeployTroops(sessionId, pair.Key, pair.Value);
            }

            // End deployment
            await game.PostEndPhase(session.GameId, session.PhaseId);
        }
    public IEnumerator BuildRegiment(ArmyController army, NationController nation)
    {
        var day = TimeController.Instance.Date;

        if (nation.ResourceManagement.Manpower < Constants.RegimentTroops ||
            nation.ResourceManagement.Gold < Constants.RegimentCost)
        {
            yield break;
        }

        nation.ResourceManagement.Manpower -= Constants.RegimentTroops;
        nation.ResourceManagement.Gold     -= Constants.RegimentCost;

        while (!TimeController.Instance.Date.Equals(day.AddDays(Constants.RegimentBuildTime)))
        {
            yield return(null);
        }

        army.Regiments++;
        army.troops += Constants.RegimentTroops;
        army.RestoreStrength();
    }