private void Update()
 {
     if (this.enabled)
     {
         if (selectedGameobject != null)
         {
             currentGameObjectScript = selectedGameobject.GetComponent <ResourceBase>();
         }
         if (currentGameObjectScript != selectedGameobject.GetComponent <ResourceBase>())
         {
             currentGameObjectScript = selectedGameobject.GetComponent <ResourceBase>();
         }
         else
         {
             if (!ObjectName.Equals(GetObjectName(selectedGameobject.name)))
             {
                 ObjectName = currentGameObjectScript.ResourceName;
                 this.transform.Find("ObjectName").GetComponent <TextMeshProUGUI>().SetText(ObjectName);
             }
             if (!PatchSize.Equals(currentGameObjectScript.SizeOfTheResource))
             {
                 PatchSize = currentGameObjectScript.SizeOfTheResource;
                 this.transform.Find("PatchSize").GetComponent <TextMeshProUGUI>().SetText(PatchSize.ToString());
             }
             if (!PatchQuantity.Equals(currentGameObjectScript.QuantityOfTheResource))
             {
                 PatchQuantity = currentGameObjectScript.QuantityOfTheResource;
                 this.transform.Find("PatchQuantity").GetComponent <TextMeshProUGUI>().SetText(PatchQuantity.ToString());
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void InitializeCustomFields(ResourceBase resource)
        {
            var resourceName = ResourceTypeToNameMapping[resource.GetType()];

            foreach (var field in fieldList.Where(x => ((string)x.Key).Contains($"_{((resourceName == "Person") ? "Candidate" : resourceName)}_")))
            {
                var data = fields.Data[field.Key];
                var type = (Enums.FieldType)Enum.Parse(typeof(Enums.FieldType), ((string)field.Key).Split('_')[1]); //key format: "id_SingleLineText_Candidate_0"
                switch (type)
                {
                case Enums.FieldType.SingleLineText:
                    resource.DictionaryValues[$"{resourceName}.{data.Name}"] = Util.GetUniqueString(10, false);
                    break;

                case Enums.FieldType.MultiLinesText:
                    resource.DictionaryValues[$"{resourceName}.{data.Name}"] = Util.GetUniqueString(20, false);
                    break;

                case Enums.FieldType.Number:
                    resource.DictionaryValues[$"{resourceName}.{data.Name}"] = random.Next();
                    break;

                default:
                    resource.DictionaryValues[$"{resourceName}.{data.Name}"] = Util.GetUniqueString(10, false);
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        //进入写入模式锁定状态,,如果缓存中已存在该键则退出写入模式
        private static ResourceBase DetectResource(string resourceLocation, string resourceName, CultureInfo culture)
        {
            string       cacheKey = resourceName + ":" + culture;
            ResourceBase resource;

            // using (syncLock.ReadAndWrite())
            // {
            //     if (!cache.TryGetValue(cacheKey, out resource))
            //     {
            //         using (syncLock.Write())
            //         {
            //             if (!cache.TryGetValue(cacheKey, out resource))
            //             {
            //                 resource = CreateResource(resourceName, culture, resourceLocation);
            //                 cache.Add(cacheKey, resource);
            //             }
            //         }
            //     }
            // }
            syncLock.EnterReadLock();
            if (!cache.TryGetValue(cacheKey, out resource))
            {
                syncLock.EnterWriteLock();
                if (!cache.TryGetValue(cacheKey, out resource))
                {
                    resource = CreateResource(resourceName, culture, resourceLocation);
                    cache.Add(cacheKey, resource);
                }
                syncLock.ExitWriteLock();
            }
            syncLock.ExitReadLock();
            return(resource);
        }
Ejemplo n.º 4
0
    //播放声音,会根据type类型和名字自动去加载声音
    public void PlaySound(string soundType, string soundName, bool loop, float vol = 1, float inOrOutTime = 1f)
    {
        soundName = soundName.ToLower();
        this.currentPlaySoundName = soundName;
        this.currentVol           = vol;
        this.loop        = loop;
        this.inOrOutTime = inOrOutTime;
        this.soundType   = soundType;

        string       path;
        ResourceBase resourceBase = null;

        if (soundType == SoundType.BGM)
        {
            path = "Sound/BGM/" + soundName;
        }
        else if (soundType == SoundType.SE_UI)
        {
            path = "Sound/UI/" + soundName;
        }
        else
        {
            path = "Sound/SE/" + MonoSingleton <GameLoader> .GetInstance().CurSceneName + "/" + soundName;
        }
        resourceBase = Singleton <ResourceManager> .GetInstance().GetResource(path, typeof(AudioClip), enResourceType.Sound, false, false);

        if (resourceBase != null)
        {
            PlaySound(resourceBase.content as AudioClip, loop, currentVol, inOrOutTime);
        }
    }
Ejemplo n.º 5
0
        /// <summary>
        /// Create the specified resource.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="mode">The mode.</param>
        /// <returns>FhirOperationResult.</returns>
        /// <exception cref="System.ArgumentNullException">target</exception>
        /// <exception cref="System.IO.InvalidDataException"></exception>
        /// <exception cref="System.Data.SyntaxErrorException"></exception>
        public virtual ResourceBase Create(ResourceBase target, TransactionMode mode)
        {
            this.traceSource.TraceInfo("Creating resource {0} ({1})", this.ResourceName, target);

            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            else if (!(target is TFhirResource))
            {
                throw new InvalidDataException();
            }

            // We want to map from TFhirResource to TModel
            var modelInstance = this.MapToModel(target as TFhirResource, RestOperationContext.Current);

            if (modelInstance == null)
            {
                throw new ArgumentException("Model invalid");
            }

            var result = this.Create(modelInstance, mode);

            // Return fhir operation result
            return(this.MapToFhir(result, RestOperationContext.Current));
        }
Ejemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        if (spawnQueue.Count == 0)
        {
            return;
        }

        int i = 0;

        while (i < spawnQueue.Count)
        {
            spawnQueue[i].Timer -= Time.deltaTime;
            //Debug.Log(spawnQueue[i].Timer);
            if (spawnQueue[i].Timer <= 25)
            {
                var resc       = Instantiate(spawnQueue[i].Object);
                var spawnPoint = ResourceBase.GetRandomSpawnPoint();
                spawnPoint = new Vector3(spawnPoint.x, 2 + Terrain.activeTerrain.SampleHeight(spawnPoint), spawnPoint.z);
                resc.transform.position = spawnPoint;
                spawnQueue.Remove(spawnQueue[i]);
            }
            else
            {
                i++;
            }
        }
    }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets a value from cache by name or null if not cached or if not found
        /// </summary>
        /// <typeparam name="T">Type of object to get</typeparam>
        /// <param name="name">Name of the resource</param>
        /// <returns>The cached object or null if not found</returns>
        public T Get <T>(string name) where T : ResourceBase
        {
            System.Type  type         = typeof(T);
            PropertyInfo nameProperty = type.GetProperties()
                                        .FirstOrDefault(property => property.Name.Equals("Name"));

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

            ResourceBase matchingObject = null;

            foreach (ResourceBase cacheObj in _allCaches[type].Cache.Values)
            {
                // we wouldn't be here without knowing that T has a Name property
                string value = nameProperty.GetValue(cacheObj) as string;
                if (value.Equals(name, StringComparison.InvariantCultureIgnoreCase))
                {
                    matchingObject = cacheObj;
                    break;
                }
            }

            return(matchingObject as T);
        }
        private MovieItem GetMovieItem(IImageComponent component, ResourceBase resource)
        {
            var item = this.current.FirstOrDefault(x => x.id == resource.GetId());

            //Debug.Log("GetMovieItem: " + (item != null) + " :: " + resource.GetId() + " :: " + component, component as MonoBehaviour);
            if (item != null)
            {
                var c = component as IResourceReference;
                if (item.components.Contains(c) == false)
                {
                    item.components.Add(c);
                }
            }
            else
            {
                //Debug.Log("new MOVIE ITEM: " + resource.GetId());
                item = new MovieItem()
                {
                    resource = WindowSystemResources.GetItem(resource),
                    state    = MovieItem.State.Stopped,
                };

                this.current.Add(item);
            }

            return(item);
        }
Ejemplo n.º 9
0
    public bool CheckCachedResource(string fullPathInResources)
    {
        string       s            = FileManager.EraseExtension(fullPathInResources);
        ResourceBase resourceInfo = null;

        return(m_cachedResourceMap.TryGetValue(s.JavaHashCodeIgnoreCase(), out resourceInfo));
    }
Ejemplo n.º 10
0
        /// <summary>
        /// Adds a resource to the Localization Table
        /// </summary>
        /// <param name="resourceId"></param>
        /// <param name="value"></param>
        /// <param name="resourceSet"></param>
        /// <param name="valueIsFileName">if true the Value property is a filename to import</param>
        public static int AddResource(string resourceId, object value, CultureInfo culture, string resourceSet, bool valueIsFileName)
        {
            string type = GetTypeForObject(value);

            byte[] binFile  = null;
            var    fileName = "";

            value = value ?? String.Empty;
            ResourceBase newResource = null;

            if (valueIsFileName)
            {
                newResource = new ImageResource {
                    FileName = fileName,
                    BinData  = binFile
                };
            }
            else
            {
                newResource = new StringResource {
                    ResourceId  = resourceId,
                    Value       = value as string,
                    Culture     = culture,
                    ResourceSet = resourceSet,
                };
            }
            ctx.Localization.Add(newResource);
            ctx.SaveChanges();
            ResetCache();
            return(1);
        }
		protected override IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, ResourceBase resource) {

			var filePath = resource.GetStreamPath();

			var task = new WWW(filePath);
			while (task.isDone == false) {

				asyncOperation.SetValues(isDone: false, progress: task.progress, asset: null);
				yield return false;

			}

			var movie = task.movie;

			asyncOperation.SetValues(isDone: false, progress: 1f, asset: movie);

			task.Dispose();
			task = null;
			System.GC.Collect();

			//Debug.LogWarning("GetTexture_YIELD: " + filePath + " :: " + movie.isReadyToPlay);

			while (movie.isReadyToPlay == false) {

				yield return false;

			}

			asyncOperation.SetValues(isDone: true, progress: 1f, asset: movie);

		}
Ejemplo n.º 12
0
    public void RemoveCachedResources(enResourceType resourceType, bool clearImmediately = true)
    {
        List <int> list = new List <int>();

        Dictionary <int, ResourceBase> .Enumerator enumerator = m_cachedResourceMap.GetEnumerator();
        while (enumerator.MoveNext())
        {
            KeyValuePair <int, ResourceBase> current = enumerator.Current;
            ResourceBase value = current.Value;
            if (value.resourceType == resourceType)
            {
                value.Unload();
                list.Add(value.key);
            }
        }
        for (int i = 0; i < list.Count; i++)
        {
            m_cachedResourceMap.Remove(list[i]);
        }
        if (clearImmediately)
        {
            UnloadAllAssetBundles();
            UnloadUnusedAssets();
        }
    }
Ejemplo n.º 13
0
        public static ResourceBase ParseToResource(XElement resourceNode)
        {
            var resource   = new ResourceBase(resourceNode.Attribute("Name").Value, Model.Resources.ResourceType.Unknown);
            var skillsNode = resourceNode?.Element("SkillDefinitions");

            if (skillsNode != null)
            {
                var skillNodes = skillsNode?.Elements("SkillDefinition");

                int i = 0;
                foreach (var node in skillNodes)
                {
                    var skill = SkillXmlParser.ParseToSkill(node, resource);
                    resource.Skills.Add(resource.Name + "." + skill.Name, skill);
                    i++;
                }
            }

            return(resource);

            /*   <Resource Name="Gripper" Type="Tool">
             * <SkillDefinitions>
             * <SkillDefinition Name="Open" TimeRequired="100">
             * <StartConditions>
             * <Condition Resource="Self" State="Error" BoolValue="false" />
             * </StartConditions>
             * <FinishedConditions>
             * <Condition Resource="Self" State="Closed" BoolValue="false" />
             * <Condition Resource="Self" State="Open" BoolValue="true" />
             * <!--Same as 2 above conditions-->
             * <Condition Statement="Self|Closed==false
             *                   AND Self|Open==true"/>
             * </FinishedConditions>
             * </SkillDefinition>
             * <SkillDefinition Name="Close" TimeRequired="100">
             * <StartConditions>
             * <Condition Resource="Self" State="Error" BoolValue="false" />
             * </StartConditions>
             * <FinishedConditions>
             * <Condition Resource="Self" State="Closed" BoolValue="true" />
             * <Condition Resource="Self" State="Open" BoolValue="false" />
             * </FinishedConditions>
             * </SkillDefinition>
             * <SkillDefinition Name="ErrorQuit" TimeRequired="500">
             * <StartConditions>
             * <Condition Resource="Self" State="Error" BoolValue="true"/>
             * </StartConditions>
             * <FinishedConditions>
             * <Condition Resource="Self" State="Error" BoolValue="false"/>
             * </FinishedConditions>
             * </SkillDefinition>
             * </SkillDefinitions>
             * <States>
             * <State ID="-1" Name="Error"/>
             * <State ID="0" Name="Undefined"/>
             * <State ID="1" Name="Opened"/>
             * <State ID="2" Name="Closed"/>
             * </States>
             * </Resource>*/
        }
Ejemplo n.º 14
0
        public void InstallByNodeName(string farmName, InstallationTicket ticket)
        {
            Resource[] resources = ResourceBase.GetAllResources();

            var resource =
                resources.First(x => (farmName == null? true: x.Controller.FarmId == farmName) &&
                                x.ResourceName == ticket.ResourceName &&
                                x.Nodes.Any(y => y.NodeName == ticket.NodeName)
                                );

            if (resource == null)
            {
                throw new InvalidDataException(string.Format("Node wasn't found with FarmName: {0}, ResourceName: {1}, NodeName: {2}", farmName, ticket.ResourceName, ticket.NodeName));
            }

            Common.Utility.ExceptionablePlaceWrapper(() =>
            {
                var address = resource.Controller.Url + "PackageInstaller";

                using (var client = PackageFactoryImpl.GetInstallationServiceClient(address))
                {
                    client.InstallPackage(ticket);
                }
            });
        }
Ejemplo n.º 15
0
        public static string Get(string key, UnityEngine.SystemLanguage language, bool forced = false)
        {
            if (LocalizationSystem.IsReady() == true || forced == true)
            {
                string[] values;
                if (string.IsNullOrEmpty(key) == false && LocalizationSystem.valuesByLanguage.TryGetValue((int)language, out values) == true)
                {
                    var keyHash   = ResourceBase.GetJavaHash(key.ToLower());
                    var keyHashes = LocalizationSystem.GetKeyHashes();
                    //Debug.Log("lang: " + language + ", keyHash: " + keyHash + " << " + key);
                    if (keyHashes != null)
                    {
                        var index = System.Array.IndexOf(keyHashes, keyHash);
                        if (index >= 0 && index < values.Length)
                        {
                            return(values[index]);
                        }
                    }
                }
            }
            else
            {
                if (Application.isPlaying == true)
                {
                    WindowSystemLogger.Warning(LocalizationSystem.GetName(), string.Format("System not ready. Do not use `LocalizationSystem.Get()` method while/before system starting. You can check it's state by `LocalizationSystem.IsReady()` call. Key: `{0}`.", key));
                }
            }

            if (string.IsNullOrEmpty(key) == true)
            {
                return(string.Empty);
            }

            return(string.Format(LocalizationSystem.NO_KEY_STRING, key));
        }
        public BasicResponseBase(ResourceBase resource, string propertyNameToExpand)
        {
            Id       = resource.Id;
            Location = resource.Location;
            Tags     = resource.Tags;
            Type     = resource.Type;
            Name     = resource.Name;

            Type inputType  = resource.GetType();
            Type outPutType = this.GetType();

            PropertyInfo propertiesPropertyInfo = inputType.GetProperty(propertyNameToExpand);

            if (propertiesPropertyInfo != null)
            {
                var            propertiesValue = propertiesPropertyInfo.GetValue(resource);
                PropertyInfo[] properties      = propertiesValue.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
                foreach (var property in properties)
                {
                    object propertyValue = property.GetValue(propertiesValue);
                    if (propertyValue != null)
                    {
                        PropertyInfo propertyInfoInResponse = outPutType.GetProperty(property.Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                        if (propertyInfoInResponse != null)
                        {
                            propertyInfoInResponse.SetValue(this, propertyValue);
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
        public static IEnumerable <NodeTotals> FromSchedule(TaskSchedule schedule)
        {
            if (schedule == null || String.IsNullOrEmpty(schedule.ResourceName) ||
                schedule.Nodes == null || !schedule.Nodes.Any())
            {
                return(null);
            }
            IEnumerable <NodeTotals> totals = null;

            try
            {
                var resource = ResourceBase.GetResourceByName(schedule.ResourceName);

                var res = schedule.Nodes.Select(nodeConf => new NodeTotals()
                {
                    NodeName               = nodeConf.NodeName,
                    NodeAddress            = resource.Nodes.First(n => n.NodeName == nodeConf.NodeName).NodeAddress,
                    CoresUsed              = (int)nodeConf.Cores,
                    SupportedArchitectures = resource.Nodes.First(n => n.NodeName == nodeConf.NodeName).SupportedArchitectures,
                });

                totals = res.ToArray();
            }
            catch (Exception e)
            {
                Log.Warn("Can't make NodeTotals: " + e.ToString());
                totals = null;
            }

            return(totals);
        }
Ejemplo n.º 18
0
    public float GetLength(string soundType, string name)
    {
        AudioClip clip = null;

        if (m_seSoundClips.TryGetValue(name, out clip))
        {
            return(clip.length);
        }
        else
        {
            string path = "";
            if (soundType == SoundType.BGM)
            {
                path = "Sound/BGM/" + name;
            }
            else if (soundType == SoundType.SE_UI)
            {
                path = "Sound/UI/" + name;
            }
            else
            {
                path = "Sound/SE/" + MonoSingleton <GameLoader> .GetInstance().CurSceneName + "/" + name;
            }
            ResourceBase resourceBase = Singleton <ResourceManager> .GetInstance().GetResource(path, typeof(AudioClip), enResourceType.Sound, false, false);

            return((resourceBase.content as AudioClip).length);
        }
    }
Ejemplo n.º 19
0
        public static ResourceTotals FromSchedule(TaskSchedule schedule)
        {
            if (schedule == null || String.IsNullOrEmpty(schedule.ResourceName))
            {
                return(null);
            }
            ResourceTotals totals = null;

            try
            {
                var resource = ResourceBase.GetResourceByName(schedule.ResourceName);

                totals = new ResourceTotals()
                {
                    ProviderName           = resource.Controller.Type, // resource.ProviderName,
                    ResourceName           = resource.ResourceName,
                    ResourceDescription    = resource.ResourceDescription,
                    Location               = resource.Location,
                    NodesTotal             = resource.Nodes.Length,
                    SupportedArchitectures = resource.SupportedArchitectures,
                };
            }
            catch (Exception e)
            {
                Log.Warn("Can't make ResourceTotals: " + e.ToString());
                totals = null;
            }

            return(totals);
        }
Ejemplo n.º 20
0
 // Remove resource from inventory
 public void Remove(ResourceBase resourceItem)
 {
     if (_resources.Contains(resourceItem))
     {
         _resources.Remove(resourceItem);
     }
 }
Ejemplo n.º 21
0
 // Add resource to inventory
 public void Add(ResourceBase resourceItem)
 {
     if (_resources.Count < _MaxInventorySize)
     {
         _resources.Add(resourceItem);
     }
 }
Ejemplo n.º 22
0
        public ResourceBase CreateResource(string resourceType, ResourceBase target)
        {
            this.ThrowIfNotReady();
            try
            {
                // Setup outgoing content

                // Create or update?
                var handler = FhirResourceHandlerUtil.GetResourceHandler(resourceType);
                if (handler == null)
                {
                    throw new FileNotFoundException(); // endpoint not found!
                }
                var result = handler.Create(target, TransactionMode.Commit);
                RestOperationContext.Current.OutgoingResponse.StatusCode = (int)HttpStatusCode.Created;


                AuditUtil.AuditDataAction <ResourceBase>(EventTypeCodes.Import, ActionType.Create, AuditableObjectLifecycle.Creation, EventIdentifierType.Import, OutcomeIndicator.Success, null, result);

                String baseUri = MessageUtil.GetBaseUri();
                RestOperationContext.Current.OutgoingResponse.Headers.Add("Content-Location", String.Format("{0}/{1}/{2}/_history/{3}", baseUri, resourceType, result.Id, result.VersionId));
                RestOperationContext.Current.OutgoingResponse.SetLastModified(result.Timestamp);
                RestOperationContext.Current.OutgoingResponse.SetETag($"W/\"{result.VersionId}\"");


                return(result);
            }
            catch (Exception e)
            {
                this.m_tracer.TraceError("Error creating FHIR resource {0}: {1}", resourceType, e);
                AuditUtil.AuditDataAction <ResourceBase>(EventTypeCodes.Import, ActionType.Create, AuditableObjectLifecycle.Creation, EventIdentifierType.Import, OutcomeIndicator.EpicFail, null);
                throw;
            }
        }
Ejemplo n.º 23
0
    /// <summary>
    /// 加载资源,优先保证从AB包里面(Resources文件夹外部),其次是通过C#IO流加
    /// 载(Resources文件夹外部),最后通过Resources加载((Resources文件夹内存)).
    /// </summary>
    /// <param name="resourceBase">资源基本数据</param>
    private void LoadResource(ResourceBase resourceBase)
    {
        ResourcePackerInfo resourceBelongedPackerInfo = GetResourceBelongedPackerInfo(resourceBase);

        if (resourceBelongedPackerInfo != null)
        {
            if (resourceBelongedPackerInfo.isAssetBundle)
            {
                if (!resourceBelongedPackerInfo.IsAssetBundleLoaded())
                {
                    resourceBelongedPackerInfo.LoadAssetBundle(FileManager.GetIFSExtractPath());
                }

                resourceBase.LoadFromAssetBundle(resourceBelongedPackerInfo);
                if (resourceBase.unloadBelongedAssetBundleAfterLoaded)
                {
                    resourceBelongedPackerInfo.UnloadAssetBundle(false);
                }
            }
            else
            {
                resourceBase.Load(FileManager.GetIFSExtractPath());
            }
        }
        else
        {
            resourceBase.Load();
        }
    }
Ejemplo n.º 24
0
    /// <summary>
    ///  获取资源基本数据结构对象
    /// </summary>
    /// <param name="fullPathInResources">资源在Resource文件夹下完整路径</param>
    /// <param name="resourceContentType">数据类型</param>
    /// <param name="resourceType">资源类型</param>
    /// <param name="needCached">是否需要缓存</param>
    /// <param name="unloadBelongedAssetBundleAfterLoaded">加载资源后是否卸载资源所在的AB包</param>
    /// <returns>资源基本数据</returns>
    public ResourceBase GetResource(string fullPathInResources, Type resourceContentType, enResourceType resourceType, bool needCached = false, bool unloadBelongedAssetBundleAfterLoaded = false)
    {
        if (string.IsNullOrEmpty(fullPathInResources))
        {
            return(new ResourceBase(0, string.Empty, null, resourceType, unloadBelongedAssetBundleAfterLoaded));
        }
        string       s            = FileManager.EraseExtension(fullPathInResources);
        int          key          = s.JavaHashCodeIgnoreCase();
        ResourceBase resourceBase = null;

        if (m_cachedResourceMap.TryGetValue(key, out resourceBase))
        {
            if (resourceBase.resourceType != resourceType)
            {
                resourceBase.resourceType = resourceType;
            }
            return(resourceBase);
        }
        resourceBase = new ResourceBase(key, fullPathInResources, resourceContentType, resourceType, unloadBelongedAssetBundleAfterLoaded);
        try
        {
            LoadResource(resourceBase);
        }
        catch (Exception exception)
        {
            object[] inParameters = new object[] { s };
            Debug.AssertFormat(false, "Failed Load Resource {0}", inParameters);
            throw exception;
        }
        if (needCached)
        {
            m_cachedResourceMap.Add(key, resourceBase);
        }
        return(resourceBase);
    }
Ejemplo n.º 25
0
 public static void KillResourcesOf(ResourceBase resource)
 {
     foreach (MapInstance map in MapInstance.Lookup.Values)
     {
         map?.DespawnResourcesOf(resource);
     }
 }
        public static IEnumerable <ResourceElement> GetResourceElements(string fullPath)
        {
            string pathOrig = Path.Combine(fullPath, Constants.OutputDirOriginal);
            string pathEdit = Path.Combine(fullPath, Constants.OutputDirEdit);

            //loop through all folders
            foreach (string directory in Directory.GetDirectories(pathOrig))
            {
                //get factory for this folder
                string      cat = directory.Split(Path.DirectorySeparatorChar).Last();
                FactoryBase b   = Factories.Single(f => f.Category == cat);

                Logger.Info($"Packing {b.Category} files...");

                //loop through files and read them from disk
                foreach (string filePath in Directory.GetFiles(directory))
                {
                    string fileName = Path.GetFileName(filePath);
                    Logger.Debug($"Reading resource {fileName}");

                    //get change path to edit folder if possible
                    string edit = filePath.Replace(pathOrig, pathEdit);

                    //read the file using the approperiate name
                    ResourceBase res = b.ReadResource(File.OpenRead(File.Exists(edit) ? edit : filePath));

                    //if ResourceName is not set, take the file name and remove the extensions
                    //then, serialize it back into an IResourceData and return it
                    yield return(new ResourceElement {
                        Name = res.ResourceName ?? fileName.Remove(fileName.Length - res.FileExtension.Length),
                        ResourceData = res.Serialize()
                    });
                }
            }
        }
Ejemplo n.º 27
0
 /// <summary>
 /// 追加します。すでに同じキーがある場合は上書きされます
 /// </summary>
 /// <param name="resourceName"></param>
 /// <param name="resource"></param>
 /// <returns></returns>
 public ResourceBase AddAndOverride(string resourceName, ResourceBase resource)
 {
     lock (resources)
     {
         resources[resourceName] = resource;
         return(resource);
     }
 }
Ejemplo n.º 28
0
 // Remove resource from list
 public void Remove(ResourceBase resource)
 {
     if (resources.Count > 0)
     {
         resources.Remove(resource);
         SubstractResourceCount(resource);
     }
 }
Ejemplo n.º 29
0
        protected override void OnPlay(ResourceBase resource, Texture movie, System.Action onComplete)
        {
            var m = movie as MovieTexture;

            if (m != null)
            {
                m.Play();
            }
        }
Ejemplo n.º 30
0
        protected override void OnStop(ResourceBase resource, Texture movie)
        {
            var m = movie as MovieTexture;

            if (m != null)
            {
                m.Stop();
            }
        }
Ejemplo n.º 31
0
        protected override void OnPause(ResourceBase resource, Texture movie)
        {
            var instance = this.FindInstance(resource);

            if (instance != null)
            {
                instance.player.Pause();
            }
        }
		protected override void OnStop(ResourceBase resource, Texture movie) {

			var m = movie as MovieTexture;
			if (m != null) {

				m.Stop();

			}

		}
		protected override void OnPlay(ResourceBase resource, Texture movie, bool loop) {

			var m = movie as MovieTexture;
			if (m != null) {

				m.loop = loop;
				m.Play();

			}

		}
    void Init()
    {
        slider = GetComponentInChildren<Slider>();
        shake = GetComponent<UiShake>();

        res = ShipResources.GetResource(resource);

        if (transform.parent.GetComponentInChildren<Text>()) {
            transform.parent.GetComponentInChildren<Text>().text = res.displayName;
        }
    }
Ejemplo n.º 35
0
        public ResponseBase(ResourceBase resource, string propertyNameToExpand)
        {
            Id = resource.Id;
            Location = resource.Location;
            Tags = resource.Tags;
            Type = resource.Type;
            Name = resource.Name;

            // Id is in the following format:
            // /subscriptions/{subid}/resourceGroups/{resourceGroupName}/providers/{providerName}/farms/{farmId}/nodes/{nodeId}
            string[] ids = resource.Id.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            ResourceGroupName = ids[3];
            FarmName = ids[7];

            Type inputType = resource.GetType();
            Type outPutType = this.GetType();

            PropertyInfo propertiesPropertyInfo = inputType.GetProperty(propertyNameToExpand);

            if (propertiesPropertyInfo != null)
            {
                var propertiesValue = propertiesPropertyInfo.GetValue(resource);
                PropertyInfo[] properties = propertiesValue.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
                foreach (var property in properties)
                {
                    object propertyValue = property.GetValue(propertiesValue);
                    if (propertyValue != null)
                    {
                        PropertyInfo propertyInfoInResponse = outPutType.GetProperty(property.Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                        if (propertyInfoInResponse != null)
                        {
                            propertyInfoInResponse.SetValue(this, propertyValue);
                        }
                    }
                }
            }
        }
Ejemplo n.º 36
0
		protected virtual void OnStop(ResourceBase resource, Texture movie) {
			
			WindowSystemLogger.Log(this.system, "`Stop` method not supported on current platform");
			
		}
 public RoleInstanceResponseBase(ResourceBase resource) : base(resource)
 {
 }
Ejemplo n.º 38
0
		public static long GetKey(ResourceBase resource, IImageComponent component) {

			return resource.GetId();

		}
 public ServiceResponseBase(ResourceBase resource, string propertyNameToExpand) : base(resource, propertyNameToExpand)
 {
 }
Ejemplo n.º 40
0
 public ResponseBase(ResourceBase resource) : this(resource, "Properties")
 {
     
 }
		public AutoResourceItem(ResourceBase source) : base(source) {
		}
			public IImageComponent Unload(ResourceBase resource) {
	
				WindowSystemResources.Unload(this, resource);
	
				return this;
	
			}
		protected override bool IsPlaying(ResourceBase resource, Texture movie) {

			var m = movie as MovieTexture;
			if (m != null) {

				return m.isPlaying;

			}

			return false;

		}
Ejemplo n.º 44
0
		protected override void OnPlay(ResourceBase resource, Texture movie, bool loop) {
			
			var path = resource.GetStreamPath();
			var instance = this.FindInstance(resource);
			if (instance == null) {

				Debug.Log("CREATE NEW VideoPlayerInterface");
				var video = new VideoPlayerInterface(this.system);
				if (video.Play(path, loop) == true) {
					
					this.playingInstances.Add(path, video);
					
				}
				
			}

		}
Ejemplo n.º 45
0
		protected override IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, ResourceBase resource) {
			
			var filePath = resource.GetStreamPath();
			
			var instance = this.FindInstance(resource);
			if (instance != null) {

				instance.Load(asyncOperation, filePath);

			} else {

				var item = new VideoPlayerInterface(this.system);
				this.playingInstances.Add(filePath, item);
				item.Load(asyncOperation, filePath);

			}

			yield return false;

		}
Ejemplo n.º 46
0
		protected override void OnPause(ResourceBase resource, Texture movie) {
			
			var instance = this.FindInstance(resource);
			if (instance != null) {

				instance.Pause();

			}

		}
Ejemplo n.º 47
0
		protected override void OnStop(ResourceBase resource, Texture movie) {
			
			var instance = this.FindInstance(resource);
			if (instance != null) {
				
				instance.Stop();
				this.playingInstances.Remove(resource.GetStreamPath());
				
			}

			
		}
Ejemplo n.º 48
0
		protected override bool IsPlaying(ResourceBase resource, Texture movie) {

			var instance = this.FindInstance(resource);
			if (instance != null) {
				
				return instance.IsPlaying();
				
			}

			return false;
			
		}
Ejemplo n.º 49
0
		protected virtual IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, ResourceBase resource) {

			yield return false;

		}
Ejemplo n.º 50
0
		private VideoPlayerInterface FindInstance(ResourceBase resource) {

			VideoPlayerInterface value;
			if (this.playingInstances.TryGetValue(resource.GetStreamPath(), out value) == true) {

				return value;

			}

			return null;

		}
Ejemplo n.º 51
0
		protected virtual void OnPlay(ResourceBase resource, Texture movie, bool loop) {
			
			WindowSystemLogger.Log(this.system, "`Play` method not supported on current platform");
			
		}
Ejemplo n.º 52
0
		protected virtual bool IsPlaying(ResourceBase resource, Texture texture) {
			
			WindowSystemLogger.Log(this.system, "`IsPlaying` method not supported on current platform");
			return false;

		}