Exemplo n.º 1
0
        private List <NotificationObject> GetBuildingNotifications()
        {
            if (!Service.IsSet <CurrentPlayer>() || Service.Get <CurrentPlayer>().CampaignProgress == null)
            {
                return(null);
            }
            if (Service.Get <CurrentPlayer>().CampaignProgress.FueInProgress)
            {
                return(null);
            }
            IState currentState = Service.Get <GameStateMachine>().CurrentState;

            if (!(currentState is HomeState) && !(currentState is ApplicationLoadState))
            {
                return(null);
            }
            List <NotificationObject> list              = new List <NotificationObject>();
            NodeList <SupportNode>    nodeList          = Service.Get <EntityController>().GetNodeList <SupportNode>();
            ISupportController        supportController = Service.Get <ISupportController>();

            for (SupportNode supportNode = nodeList.Head; supportNode != null; supportNode = supportNode.Next)
            {
                BuildingComponent buildingComp = supportNode.BuildingComp;
                string            key          = buildingComp.BuildingTO.Key;
                Contract          contract     = supportController.FindCurrentContract(key);
                if (contract != null)
                {
                    NotificationObject notificationObject = null;
                    DeliveryType       deliveryType       = contract.DeliveryType;
                    int remainingTimeForSim = contract.GetRemainingTimeForSim();
                    switch (deliveryType)
                    {
                    case DeliveryType.Building:
                    case DeliveryType.UpgradeBuilding:
                        notificationObject = this.CreateBuildingNotification(contract.ProductUid, remainingTimeForSim, key);
                        break;

                    case DeliveryType.UpgradeTroop:
                    case DeliveryType.UpgradeStarship:
                    case DeliveryType.UpgradeEquipment:
                        notificationObject = this.CreateResearchNotification(contract.ProductUid, deliveryType, remainingTimeForSim, key);
                        break;
                    }
                    if (notificationObject != null)
                    {
                        list.Add(notificationObject);
                    }
                }
            }
            return(list);
        }
Exemplo n.º 2
0
        private NotificationObject GetUnitsCompleteNotification()
        {
            if (Service.CurrentPlayer == null || Service.CurrentPlayer.CampaignProgress == null)
            {
                return(null);
            }
            if (Service.CurrentPlayer.CampaignProgress.FueInProgress || !(Service.GameStateMachine.CurrentState is HomeState))
            {
                return(null);
            }
            NotificationTypeVO notificationTypeVO = Service.StaticDataController.Get <NotificationTypeVO>("notif2");
            int num = 0;
            NodeList <SupportNode> nodeList           = Service.EntityController.GetNodeList <SupportNode>();
            ISupportController     iSupportController = Service.ISupportController;

            for (SupportNode supportNode = nodeList.Head; supportNode != null; supportNode = supportNode.Next)
            {
                SmartEntity       smartEntity  = (SmartEntity)supportNode.Entity;
                BuildingComponent buildingComp = supportNode.BuildingComp;
                string            key          = buildingComp.BuildingTO.Key;
                if (!ContractUtils.IsBuildingUpgrading(smartEntity) && !ContractUtils.IsBuildingConstructing(smartEntity) && !iSupportController.IsBuildingFrozen(key))
                {
                    Contract contract = iSupportController.FindCurrentContract(key);
                    if (contract != null && iSupportController.IsContractValidForStorage(contract))
                    {
                        int num2 = ContractUtils.CalculateRemainingTimeOfAllTroopContracts(smartEntity);
                        if (num2 > num)
                        {
                            num = num2;
                        }
                    }
                }
            }
            if (num >= notificationTypeVO.MinCompletionTime)
            {
                DateTime time = DateTime.Now.AddSeconds((double)num + 2.0);
                return(this.CreateReengagementNotification("notif2", time, true));
            }
            return(null);
        }