Exemplo n.º 1
0
 private void CheckStarportFullness(Entity entity)
 {
     if (entity.Get <BuildingComponent>().BuildingType.Type == BuildingType.Starport)
     {
         StorageSpreadUtils.UpdateAllStarportFullnessMeters();
     }
 }
Exemplo n.º 2
0
        private SmartEntity FindIdleStarport(ContractEventData contractData)
        {
            SmartEntity smartEntity = StorageSpreadUtils.FindLeastFullStarport();

            if (smartEntity != null)
            {
                TroopTypeVO troop = this.sdc.Get <TroopTypeVO>(contractData.Contract.ProductUid);
                StorageSpreadUtils.AddTroopToStarportReserve(smartEntity, troop);
            }
            return(smartEntity);
        }
Exemplo n.º 3
0
        private void StarportReached(object cookie)
        {
            KeyValuePair <Entity, ContractEventData> keyValuePair = (KeyValuePair <Entity, ContractEventData>)cookie;
            SmartEntity       starport = (SmartEntity)keyValuePair.Key;
            ContractEventData value    = keyValuePair.Value;

            this.RemoveTransportRequest(value);
            TroopTypeVO troop = this.sdc.Get <TroopTypeVO>(value.Contract.ProductUid);

            StorageSpreadUtils.AddTroopToStarportVisually(starport, troop);
            Service.EventManager.SendEvent(EventId.TransportDeparted, null);
        }
Exemplo n.º 4
0
        private void StarportReached(object cookie)
        {
            KeyValuePair <Entity, ContractEventData> keyValuePair = (KeyValuePair <Entity, ContractEventData>)cookie;
            Entity            key   = keyValuePair.get_Key();
            ContractEventData value = keyValuePair.get_Value();

            this.RemoveTransportRequest(value);
            TroopTypeVO troop = this.sdc.Get <TroopTypeVO>(value.Contract.ProductUid);

            StorageSpreadUtils.AddTroopToStarportVisually(key, troop);
            Service.Get <EventManager>().SendEvent(EventId.TransportDeparted, null);
        }
 private void UpdateAnimations(IState gameMode)
 {
     for (BuildingRenderNode buildingRenderNode = this.nodeList.Head; buildingRenderNode != null; buildingRenderNode = buildingRenderNode.Next)
     {
         this.UpdateAnimation(buildingRenderNode.Entity, gameMode, buildingRenderNode.AnimComp, true);
         BuildingComponent buildingComp = buildingRenderNode.BuildingComp;
         BuildingTypeVO    buildingType = buildingComp.BuildingType;
         if (buildingType.Type == BuildingType.Resource && buildingComp.BuildingTO.CurrentStorage >= buildingType.Storage)
         {
             this.UpdateAnimationOnGeneratorFull((SmartEntity)buildingRenderNode.Entity, gameMode);
         }
     }
     if (gameMode is HomeState)
     {
         StorageSpreadUtils.UpdateAllStarportFullnessMeters();
     }
 }
Exemplo n.º 6
0
        private void UpdateAmountStored(int sliderIndex)
        {
            this.sliders[sliderIndex].DescLabel.Text = this.lang.Get("STORAGE_CAPACITY", new object[0]);
            int     num          = StorageSpreadUtils.CalculateAssumedCurrencyInStorage(this.buildingInfo.Currency, this.selectedBuilding);
            int     storage      = this.buildingInfo.Storage;
            UXLabel currentLabel = this.sliders[sliderIndex].CurrentLabel;

            currentLabel.Text = this.lang.Get("FRACTION", new object[]
            {
                this.lang.ThousandsSeparated(num),
                this.lang.ThousandsSeparated(storage)
            });
            UXSlider currentSlider = this.sliders[sliderIndex].CurrentSlider;
            float    num2          = (storage != 0) ? ((float)num / (float)storage) : 0f;

            currentSlider.Value = num2;
            this.projector.Config.MeterValue = num2;
        }
Exemplo n.º 7
0
    public void UpdateFillState(Entity entity, BuildingTypeVO buildingVO)
    {
        SmartEntity smartEntity = (SmartEntity)entity;

        if (buildingVO.Storage <= 0 || string.IsNullOrEmpty(buildingVO.FillStateAssetName) || string.IsNullOrEmpty(buildingVO.FillStateBundleName))
        {
            return;
        }
        if (!entity.Has <GameObjectViewComponent>())
        {
            return;
        }
        int num = 0;
        IResourceFillable resourceFillable = null;

        if (buildingVO.Type == BuildingType.Resource)
        {
            GeneratorComponent generatorComponent = entity.Get <GeneratorComponent>();
            BuildingComponent  buildingComponent  = entity.Get <BuildingComponent>();
            num = buildingComponent.BuildingTO.AccruedCurrency;
            resourceFillable = generatorComponent;
        }
        else if (buildingVO.Type == BuildingType.Storage)
        {
            num = StorageSpreadUtils.CalculateAssumedCurrencyInStorage(buildingVO.Currency, entity);
            resourceFillable = entity.Get <StorageComponent>();
        }
        if (resourceFillable == null)
        {
            return;
        }
        float num2 = (float)num / (float)buildingVO.Storage;
        float currentFullnessPercentage = resourceFillable.CurrentFullnessPercentage;

        resourceFillable.CurrentFullnessPercentage  = num2;
        resourceFillable.PreviousFullnessPercentage = currentFullnessPercentage;
        this.UpdateFillStateFX(entity, buildingVO, num2, currentFullnessPercentage);
        if (smartEntity.BuildingComp.BuildingType.Type == BuildingType.Storage && smartEntity.BuildingComp.BuildingType.Currency == CurrencyType.Credits)
        {
            Service.EventManager.SendEvent(EventId.StorageDoorEvent, smartEntity);
        }
    }
Exemplo n.º 8
0
        private void UpdateCapacity(int sliderIndex)
        {
            BuildingUpgradeCatalog buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>();
            int storage  = this.buildingInfo.Storage;
            int storage2 = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo).Storage;
            int storage3 = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup).Storage;

            this.sliders[sliderIndex].DescLabel.Text    = this.lang.Get("STORAGE_CAPACITY", new object[0]);
            this.sliders[sliderIndex].CurrentLabel.Text = this.lang.ThousandsSeparated(storage);
            this.sliders[sliderIndex].NextLabel.Text    = this.lang.Get("PLUS", new object[]
            {
                this.lang.ThousandsSeparated(storage2 - storage)
            });
            this.sliders[sliderIndex].CurrentSlider.Value = ((storage3 == 0) ? 0f : ((float)storage / (float)storage3));
            this.sliders[sliderIndex].NextSlider.Value    = ((storage3 == 0) ? 0f : ((float)storage2 / (float)storage3));
            int   num        = StorageSpreadUtils.CalculateAssumedCurrencyInStorage(this.buildingInfo.Currency, this.selectedBuilding);
            int   storage4   = this.buildingInfo.Storage;
            float meterValue = (storage4 == 0) ? 0f : ((float)num / (float)storage4);

            this.projector.Config.MeterValue = meterValue;
        }
Exemplo n.º 9
0
        public Dictionary <string, int> RemoveAllDeployables()
        {
            Dictionary <string, int>            dictionary      = new Dictionary <string, int>();
            Dictionary <string, InventoryEntry> internalStorage = base.Inventory.Troop.GetInternalStorage();

            foreach (KeyValuePair <string, InventoryEntry> current in internalStorage)
            {
                dictionary.Add(current.Key, 0);
                base.Inventory.Troop.ClearItemAmount(current.Key);
            }
            Dictionary <string, InventoryEntry> internalStorage2 = base.Inventory.SpecialAttack.GetInternalStorage();

            foreach (KeyValuePair <string, InventoryEntry> current2 in internalStorage2)
            {
                dictionary.Add(current2.Key, 0);
                base.Inventory.SpecialAttack.ClearItemAmount(current2.Key);
            }
            Dictionary <string, InventoryEntry> internalStorage3 = base.Inventory.Hero.GetInternalStorage();

            foreach (KeyValuePair <string, InventoryEntry> current3 in internalStorage3)
            {
                dictionary.Add(current3.Key, 0);
                base.Inventory.Hero.ClearItemAmount(current3.Key);
            }
            Dictionary <string, InventoryEntry> internalStorage4 = base.Inventory.Champion.GetInternalStorage();

            foreach (KeyValuePair <string, InventoryEntry> current4 in internalStorage4)
            {
                dictionary.Add(current4.Key, 0);
                base.Inventory.Champion.ClearItemAmount(current4.Key);
            }
            IState currentState = Service.GameStateMachine.CurrentState;

            if (currentState is HomeState || currentState is EditBaseState)
            {
                StorageSpreadUtils.UpdateAllStarportFullnessMeters();
            }
            return(dictionary);
        }
Exemplo n.º 10
0
 public void OnTroopReachedPathEnd()
 {
     this.pathReached = true;
     StorageSpreadUtils.AddTroopToStarportVisually(this.starportEntity, this.troopVO);
     this.TryShowEffect();
 }
Exemplo n.º 11
0
        private void OnAssetSuccess(object asset, object cookie)
        {
            GameObject  gameObject  = (GameObject)asset;
            ShuttleAnim shuttleAnim = (ShuttleAnim)cookie;

            shuttleAnim.GameObj = gameObject;
            SmartEntity smartEntity = (SmartEntity)shuttleAnim.Starport;

            if (this.shuttles.ContainsKey(smartEntity))
            {
                shuttleAnim.Anim = gameObject.GetComponent <Animation>();
                GameObjectViewComponent gameObjectViewComponent = smartEntity.Get <GameObjectViewComponent>();
                Transform transform = gameObject.transform;
                AssetMeshDataMonoBehaviour component;
                if (shuttleAnim.IsContrabandShuttle)
                {
                    bool flag = shuttleAnim.Percentage < 1f || shuttleAnim.State == ShuttleState.Landing || shuttleAnim.State == ShuttleState.Idle;
                    if (smartEntity.GameObjectViewComp == null || smartEntity.GameObjectViewComp.MainGameObject == null)
                    {
                        this.UnloadShuttle(shuttleAnim);
                        StorageSpreadUtils.UpdateAllStarportFullnessMeters();
                        return;
                    }
                    component = smartEntity.GameObjectViewComp.MainGameObject.GetComponent <AssetMeshDataMonoBehaviour>();
                    for (int i = 0; i < component.OtherGameObjects.Count; i++)
                    {
                        if (component.OtherGameObjects[i].name.Contains("locator_vehicle"))
                        {
                            transform.position = component.OtherGameObjects[i].transform.position;
                            break;
                        }
                    }
                    if (flag)
                    {
                        this.AnimateContrabandShuttle(shuttleAnim, shuttleAnim.Percentage);
                    }
                }
                else if (shuttleAnim.IsArmoryShuttle)
                {
                    if (smartEntity.GameObjectViewComp == null || smartEntity.GameObjectViewComp.MainGameObject == null)
                    {
                        this.UnloadShuttle(shuttleAnim);
                        return;
                    }
                    transform.position = gameObjectViewComponent.MainTransform.position;
                    this.AnimateArmoryShuttle(shuttleAnim);
                }
                else
                {
                    transform.position = gameObjectViewComponent.MainTransform.position;
                    this.AnimateShuttle(shuttleAnim, shuttleAnim.Percentage);
                }
                transform.rotation = Quaternion.AngleAxis(-90f, Vector3.up);
                component          = gameObject.GetComponent <AssetMeshDataMonoBehaviour>();
                if (component != null && component.OtherGameObjects != null)
                {
                    shuttleAnim.ShadowGameObject = component.ShadowGameObject;
                    for (int j = 0; j < component.OtherGameObjects.Count; j++)
                    {
                        if (component.OtherGameObjects[j].name.Contains("center_of_mass"))
                        {
                            shuttleAnim.CenterOfMass = component.OtherGameObjects[j];
                            break;
                        }
                    }
                }
                if (shuttleAnim.ShadowGameObject != null)
                {
                    shuttleAnim.ShadowMaterial        = UnityUtils.EnsureMaterialCopy(shuttleAnim.ShadowGameObject.GetComponent <Renderer>());
                    shuttleAnim.ShadowMaterial.shader = Service.Get <AssetManager>().Shaders.GetShader("TransportShadow");
                }
            }
            else
            {
                this.UnloadShuttle(shuttleAnim);
            }
            StorageSpreadUtils.UpdateAllStarportFullnessMeters();
        }
Exemplo n.º 12
0
        public void OnPlayerActionSuccess(SquadAction actionType, SquadMsg msg)
        {
            Squad currentSquad = this.StateManager.GetCurrentSquad();

            switch (actionType)
            {
            case SquadAction.Create:
                GameUtils.SpendCurrency(GameConstants.SQUAD_CREATE_COST, 0, 0, true);
                this.StateManager.SetCurrentSquad(msg.RespondedSquad);
                this.ClearPrefsForNewSquad(0);
                break;

            case SquadAction.Join:
                this.StateManager.SetCurrentSquad(msg.RespondedSquad);
                this.StateManager.OnSquadJoined(msg.BISource);
                this.SetLastViewedSquadLevelUp(msg.RespondedSquad.Level);
                break;

            case SquadAction.Leave:
            {
                string message = Service.Lang.Get("LEAVE_A_SQUAD", new object[]
                    {
                        currentSquad.SquadName
                    });
                this.LeaveSquad(message);
                break;
            }

            case SquadAction.Edit:
            {
                SqmSquadData squadData = msg.SquadData;
                this.StateManager.EditSquad(squadData.Open, squadData.Icon, squadData.Desc, squadData.MinTrophies);
                break;
            }

            case SquadAction.ApplyToJoin:
                if (!this.StateManager.SquadJoinRequestsPending.Contains(msg.SquadData.Id))
                {
                    this.StateManager.SquadJoinRequestsPending.Add(msg.SquadData.Id);
                }
                break;

            case SquadAction.AcceptApplicationToJoin:
                SquadUtils.AddSquadMember(currentSquad, msg.SquadMemberResponse);
                this.UpdateCurrentSquad();
                this.StateManager.OnSquadJoinApplicationAcceptedByCurrentPlayer(msg.BISource);
                break;

            case SquadAction.SendInviteToJoin:
                this.StateManager.PlayersInvitedToSquad.Add(msg.FriendInviteData.PlayerId);
                break;

            case SquadAction.AcceptInviteToJoin:
                this.StateManager.RemoveInviteToSquad(msg.SquadData.Id);
                this.UpdateCurrentSquad();
                this.StateManager.OnSquadJoinInviteAccepted();
                break;

            case SquadAction.RejectInviteToJoin:
                this.StateManager.RemoveInviteToSquad(msg.SquadData.Id);
                break;

            case SquadAction.PromoteMember:
                SquadUtils.SetSquadMemberRole(currentSquad, msg.MemberData.MemberId, msg.MemberData.MemberRole);
                break;

            case SquadAction.DemoteMember:
                SquadUtils.SetSquadMemberRole(currentSquad, msg.MemberData.MemberId, msg.MemberData.MemberRole);
                break;

            case SquadAction.RemoveMember:
                SquadUtils.RemoveSquadMember(currentSquad, msg.MemberData.MemberId);
                break;

            case SquadAction.RequestTroops:
                this.StateManager.TroopRequestDate = Service.ServerAPI.ServerTime;
                this.StateManager.OnSquadTroopsRequested();
                break;

            case SquadAction.DonateTroops:
            case SquadAction.DonateWarTroops:
            {
                Dictionary <string, int> donations     = msg.DonationData.Donations;
                CurrentPlayer            currentPlayer = Service.CurrentPlayer;
                int num = 0;
                foreach (KeyValuePair <string, int> current in donations)
                {
                    string key   = current.Key;
                    int    value = current.Value;
                    currentPlayer.Inventory.Troop.ModifyItemAmount(key, -value);
                    num += value;
                }
                StorageSpreadUtils.UpdateAllStarportFullnessMeters();
                Service.ISupportController.UnfreezeAllBuildings(ServerTime.Time);
                this.StateManager.NumTroopDonationsInSession += num;
                this.StateManager.OnSquadTroopsDonated(donations);
                break;
            }

            case SquadAction.RequestWarTroops:
                this.StateManager.WarTroopRequestDate = Service.ServerAPI.ServerTime;
                this.StateManager.OnSquadWarTroopsRequested();
                break;

            case SquadAction.ShareReplay:
                this.StateManager.OnSquadReplayShared(msg.ReplayData);
                break;
            }
        }