Exemplo n.º 1
0
 public static ResourcesWrapper CrossProduct(ResourcesWrapper current, float factor, float divider)
 {
     return(new ResourcesWrapper(
                Mathf.RoundToInt((float)current.food * factor / divider),
                Mathf.RoundToInt((float)current.wood * factor / divider),
                Mathf.RoundToInt((float)current.stone * factor / divider)
                ));
 }
    public Stream LoadAsSteam(string filePath)
    {
        TextAsset textAsset = ResourcesWrapper.Load <TextAsset>(filePath);

        if (textAsset == null)
        {
            return(null);
        }

        return(new MemoryStream(textAsset.bytes));
    }
    public SecurityElement LoadAsXML(string filePath)
    {
        TextAsset textAsset = ResourcesWrapper.Load <TextAsset>(filePath);

        if (textAsset == null)
        {
            return(null);
        }

        SecurityParser xmlParser = new SecurityParser();

        xmlParser.LoadXml(textAsset.text);

        return(xmlParser.ToXml());
    }
Exemplo n.º 4
0
        private void RemoveEntity(Entity entity)
        {
            if (!entity.Data.CanCreateResources)
            {
                return;
            }

            if (entity.Data.GenerationType == GenerationType.PerCell)
            {
                Debug.LogErrorFormat("Income Calculator : Can't calculate income of building '{0}' because its generation is 'PerCell'.", entity.EntityID);
                return;
            }

            _incomeGeneratorEntities.Remove(entity);

            _currentIncome -= ResourcesWrapper.CrossProduct(entity.Data.ConstantResourcesGeneration, _incomeTick, entity.Data.GenerationTick);
            OnIncomeChanged?.Invoke(_currentIncome);
        }
        protected override void ConstructBuilding()
        {
            ResourcesWrapper constructionCost = GetConstructionCost();

            if (!_owner.HasEnoughtResources(constructionCost))
            {
                SucessfulBuild = false;
                LeaveState();
                return;
            }

            bool canConstruct = CanConstructAllBuildings();

            if (canConstruct)
            {
                ConstructAllBuildings();
            }

            SucessfulBuild = canConstruct;
            LeaveState();
        }
Exemplo n.º 6
0
 private void GameManager_HasNotEnoughtResources(GameManager gameManager, ResourcesWrapper cost) => _audioManager.PlayOneShotRandomClip(Sound2D.NotEnoughResources);
Exemplo n.º 7
0
 void Start()
 {
     _gameManagerResourcesBeforeInfiniteResources = GameManager.Instance.Resources;
     ManageActivation_InfiniteResources();
     ManageActive_FogOfWar();
 }
Exemplo n.º 8
0
        void Active_InfiniteResources()
        {
            _gameManagerResourcesBeforeInfiniteResources = GameManager.Instance.Resources;

            GameManager.Instance.Resources = new ResourcesWrapper(1, 1, 1) * 99999;
        }
Exemplo n.º 9
0
 private void UpdateIncomeLabel(ResourcesWrapper incomeLabel)
 => UpdateIncomeLabel(incomeLabel.wood, incomeLabel.food, incomeLabel.stone);
Exemplo n.º 10
0
 private void UpdateResourcesLabel(ResourcesWrapper currentResources)
 {
     _resourcesLabel[(int)Resource.Food].text  = currentResources.food.ToString();
     _resourcesLabel[(int)Resource.Wood].text  = currentResources.wood.ToString();
     _resourcesLabel[(int)Resource.Stone].text = currentResources.stone.ToString();
 }
Exemplo n.º 11
0
    public Object LoadAsset(string assetName, bool noCache)
    {
#if ENABLE_RESOURCE_MANAGER_METRICS
        totalLoadCount++;
#endif

        // Convert to lowercase name
        //assetName = WeihuaGames.PathUtility.UnifyPath(assetName);

        // Check if Need load from cache
        //        if (ConfigDatabase.DefaultCfg.ClientManifest != null)
        //        {
        //            ClientManifest.FileInfo fileInfo = ConfigDatabase.DefaultCfg.ClientManifest.GetFileByName(assetName);
        //            if (fileInfo != null)
        //            {
        //#if ENABLE_RESOURCE_MANAGER_METRICS
        //				assetBundleLoadCount++;
        //#endif

        //                // Try to load from resource cache
        //                ResourceCache resCache = ResourceCache.Instance;
        //                if (resCache != null && resCache.Contains(assetName))
        //                {
        //                    return resCache.GetAsset(assetName);
        //                }

        //                // Load from asset bundle and add to resource cache
        //                string abPath = GetLocalFilePath(fileInfo.fileName);
        //#if ENABLE_RESOURCE_MANAGER_LOG
        //				Debug.Log("[ResourceManager] Load asset from AB : " + abPath);
        //#endif

        //                AssetBundle ab = AssetBundle.LoadFromFile(abPath);
        //                if (ab == null)
        //                {
        //                    Debug.LogError("Load AB failed : " + abPath);
        //                    return null;
        //                }

        //                // Load object from AB
        //                Object obj = ab.mainAsset;
        //                ab.Unload(false);
        //                ab = null;

        //                // Add to resource cache
        //                if (resCache != null && noCache == false)
        //                {
        //                    resCache.AddAsset(assetName, obj);
        //                    return resCache.GetAsset(assetName);
        //                }
        //                else
        //                {
        //                    return obj;
        //                }
        //            }



#if ENABLE_RESOURCE_MANAGER_METRICS
        resourceLoadCount++;
#endif

        // Load from resources folder
        return(ResourcesWrapper.Load(assetName));
    }
Exemplo n.º 12
0
 public bool HasEnoughResources(ResourcesWrapper b)
 {
     return(this >= b);
 }