public void SetItemInfo(ResourceTypes itemId, BasicDockInfo dockInfo, ConfirmFastItemType type)
 {
     this.itemId = (int) itemId;
     this.dockInfo = dockInfo;
     this.type = type;
     this.InitUI();
 }
    public void SetBackgroundImage(ResourceTypes pResourceType)
    {
        Material backgroundMaterial;

        switch (pResourceType)
        {
            case ResourceTypes.BRICK:
                backgroundMaterial = (Material)Resources.Load("Materials/ClayMaterial");
                GetComponent<MeshRenderer>().material = backgroundMaterial;
                break;
            case ResourceTypes.GRAIN:
                backgroundMaterial = (Material)Resources.Load("Materials/WheatMaterial");
                GetComponent<MeshRenderer>().material = backgroundMaterial;
                break;
            case ResourceTypes.WOOD:
                backgroundMaterial = (Material)Resources.Load("Materials/WoodMaterial");
                GetComponent<MeshRenderer>().material = backgroundMaterial;
                break;
            case ResourceTypes.WOOL:
                backgroundMaterial = (Material)Resources.Load("Materials/SheepMaterial");
                GetComponent<MeshRenderer>().material = backgroundMaterial;
                break;
            default:
                Debug.Log ("Invalid resource type!");
                break;
        }
    }
 public void ShowItem(ResourceTypes itemId)
 {
     string displayNameOfItem = ResourceTypeUtil.GetDisplayNameOfItem(itemId);
     string str2 = string.Format(Localization.Localize("ShopItemNotEnoughContent"), displayNameOfItem);
     this.contentTM.text = str2;
     this.contentTM.Commit();
 }
Exemple #4
0
        public Worker()
        {
            ResourceCount = 0;
            HeldResource = 0;

            SpriteFolder = "Worker";
        }
Exemple #5
0
 public Resources()
 {
     Neutral = true;
     ResourceType = ResourceTypes.Glue;
     ResourcesPerTrip = 0;
     RemainingResources = 0;
 }
Exemple #6
0
        protected override void ParseUpdate(MemoryStream memoryStream)
        {
            base.ParseUpdate(memoryStream);

            var reader = new BinaryReader(memoryStream);
            HeldResource = (ResourceTypes) reader.ReadByte();
            ResourceCount = reader.ReadByte();
        }
 public void SetResource(ResourceTypes type, int amount)
 {
     this.resourceType = type;
     this.amount = amount;
     this.iconSprite.SetSprite(type.ToString());
     this.amountTextMesh.text = amount + string.Empty;
     this.amountTextMesh.Commit();
 }
Exemple #8
0
 public void GiveResource(ResourceTypes type, byte amount)
 {
     if (!IsHoldingResources)
     {
         HeldResource = type;
         ResourceCount = amount;
     }
 }
 public static string GetDisplayNameOfItem(ResourceTypes itemId)
 {
     if (IsResourceCid((int) itemId))
     {
         return Localization.Localize(itemId.ToString());
     }
     return Localization.Localize("Item" + ((int) itemId));
 }
Exemple #10
0
 /// <summary>
 /// Decreases passed resource by the passed amount
 /// </summary>
 /// <param name="res">The resource to decrease</param>
 /// <param name="amount">The amount to decrease it with</param>
 public void DecreaseResource(ResourceTypes res, int amount)
 {
     if (!this.HasResource(res, amount))
     {
         return;
     }
     this.resources[(int)res] -= amount;
 }
Exemple #11
0
 /// <summary>
 /// Constructs a new library based resource identifier
 /// </summary>
 /// <param name="name">The name of the resource, may include path information with the \"/\" character</param>
 /// <param name="type">The type of resource the identifier names</param>
 public ResourceIdentifier(string name, ResourceTypes type)
 {
     if (string.IsNullOrEmpty(name))
         throw new ArgumentNullException("name"); //NOXLATE
     if (name.IndexOf(".") > 0 || name.IndexOf("//") > 0 || name.IndexOf(":") > 0) //NOXLATE
         throw new ArgumentException(Strings.ErrorResourceIdentifierInvalidChars, "name"); //NOXLATE
     if (!Enum.IsDefined(typeof(ResourceTypes), type))
         throw new ArgumentException(Strings.ErrorUnknownResourceType, "type"); //NOXLATE
     m_id = StringConstants.RootIdentifier + name + EnumHelper.ResourceName(type, true);
 }
 public virtual void ChangeResourceAmount(ResourceTypes type, int amount)
 {
     if(resources.ContainsKey(type))
     {
         resources[type] += amount;
     }
     else
     {
         print("resource type not found, something wrong with inventory");
     }
 }
Exemple #13
0
 /// <summary>
 /// Determines whether the specified resource types has validator.
 /// </summary>
 /// <param name="resourceTypes">The resource types.</param>
 /// <param name="version">The version.</param>
 /// <returns>
 /// 	<c>true</c> if the specified resource types has validator; otherwise, <c>false</c>.
 /// </returns>
 public static bool HasValidator(ResourceTypes resourceTypes, Version version)
 {
     bool found = false;
     var find = new ResourceTypeDescriptor(resourceTypes, version.ToString());
     foreach (var v in m_validators)
     {
         if (v.SupportedResourceAndVersion.Equals(find))
         {
             found = true;
             break;
         }
     }
     return found;
 }
    //Exports level data
    public static void Export(ResourceTypes[] tile)
    {
        if (levelName != null && authorName != null)
        {
            tiles = new string[tile.Length];
            int numLines = 2;
            int line = 0;

            for (int i = 0; i < tile.Length; i++)
            {
                tiles[i] = tile[i].ToString();
            }

            string path = Application.dataPath + "/Maps/Custom/" + levelName + ".txt";

            //Writes all data to the given file under that name declared in the levelName variable
            StreamWriter sw = new StreamWriter(path);
            for (int i = 0; i <= numLines; i++)
            {
                Debug.Log(line);
                if (line == 0)
                {
                    sw.WriteLine(levelName);
                }
                if (line == 1)
                {
                    sw.WriteLine(authorName);
                }
                if (line == 2)
                {
                    for (int j = 0; j < tiles.Length; j++)
                    {
                        sw.Write(tiles[j] + " ");
                    }
                }
                line++;
            }
            sw.Close();

            AssetDatabase.Refresh();
        }
        else
        {
            Debug.Log("No level name and/or no author name");
        }
    }
 private int GetAmountOf(ResourceTypes type)
 {
     int num = (int) type;
     if ((this.levelConfig.productAward != null) && this.levelConfig.productAward.ContainsKey(num + string.Empty))
     {
         int num2 = this.levelConfig.productAward[num + string.Empty];
         if (num2 > 200)
         {
             return 1;
         }
         if (num2 > 100)
         {
             return 2;
         }
     }
     return 3;
 }
 public void SetResources(Dictionary<string, int> res)
 {
     tk2dTextMesh[] meshArray = new tk2dTextMesh[] { this.oilText, this.ammoText, this.steelText, this.aluminumText };
     ResourceTypes[] typesArray = new ResourceTypes[] { ResourceTypes.Oil, ResourceTypes.Ammo, ResourceTypes.Steel, ResourceTypes.Aluminium };
     for (int i = 0; i < meshArray.Length; i++)
     {
         string key = ((int) typesArray[i]) + string.Empty;
         if (res.ContainsKey(key))
         {
             meshArray[i].text = res[key] + string.Empty;
         }
         else
         {
             meshArray[i].text = "0";
         }
         meshArray[i].Commit();
     }
 }
 //Edits the resource type
 public static void MapEdit(ResourceTypes type)
 {
     switch (type)
     {
         case ResourceTypes.BRICK:
             type = ResourceTypes.GRAIN;
             break;
         case ResourceTypes.GRAIN:
             type = ResourceTypes.WOOD;
             break;
         case ResourceTypes.WOOD:
             type = ResourceTypes.WOOL;
             break;
         case ResourceTypes.WOOL:
             type = ResourceTypes.BRICK;
             break;
     }
 }
Exemple #18
0
        /// <summary>
        /// Extracts the raw data of the resource from the module.
        /// </summary>
        /// <param name="hModule">The module handle.</param>
        /// <param name="resrouceName">The name of the resource.</param>
        /// <param name="resourceType">The type of the resource.</param>
        /// <returns>The resource raw data.</returns>
        private static byte[] GetResourceData(IntPtr hModule, ResourceName resourceName, ResourceTypes resourceType)
        {
            //Find the resource in the module.
            IntPtr hResInfo = IntPtr.Zero;

            try { hResInfo = Win32.FindResource(hModule, resourceName.Value, resourceType); }
            finally { resourceName.Free(); }
            if (hResInfo == IntPtr.Zero)
            {
                throw new Win32Exception();
            }
            //Load the resource.
            IntPtr hResData = Win32.LoadResource(hModule, hResInfo);

            if (hResData == IntPtr.Zero)
            {
                throw new Win32Exception();
            }
            //Lock the resource to read data.
            IntPtr hGlobal = Win32.LockResource(hResData);

            if (hGlobal == IntPtr.Zero)
            {
                throw new Win32Exception();
            }
            //Get the resource size.
            int resSize = Win32.SizeofResource(hModule, hResInfo);

            if (resSize == 0)
            {
                throw new Win32Exception();
            }
            //Allocate the requested size.
            byte[] buf = new byte[resSize];
            //Copy the resource data into our buffer.
            Marshal.Copy(hGlobal, buf, 0, buf.Length);

            return(buf);
        }
 internal static extern bool EnumResourceNames(IntPtr hModule, ResourceTypes lpszType,
                                               EnumResNameProcDelegate lpEnumFunc,
                                               IntPtr lParam);
Exemple #20
0
 public static string getresourcetype(ResourceTypes st)
 {
     switch (st)
     {
        case ResourceTypes.Aluminium:
          return "铝材";
         case ResourceTypes.Ammo:
          return "弹药";
         case ResourceTypes.BigShip:
          return "大舰";
         case ResourceTypes.BuildEquipItem:
          return "开发材料";
         case ResourceTypes.BuildMaterial:
          return "建材";
         case ResourceTypes.BuildShipItem:
          return "建造材料";
         case ResourceTypes.Equipment:
          return "装备";
         case ResourceTypes.Exp:
          return "经验";
         case ResourceTypes.FastBuild:
          return "快速建造";
         case ResourceTypes.FastRepair:
          return "快速修理";
         case ResourceTypes.Gold:
          return "钻石";
         case ResourceTypes.LoveRing:
          return "婚戒";
         case ResourceTypes.MainQuest:
          return "主线任务";
         case ResourceTypes.MediumShip:
          return "中型舰艇";
         case ResourceTypes.NormalQuest:
          return "普通任务";
         case ResourceTypes.Oil:
          return "燃油";
         case ResourceTypes.ShipEnemy:
          return "船体力";
         case ResourceTypes.ShipExp:
          return "船经验";
         case ResourceTypes.SmallShip:
          return "小型舰艇";
         case ResourceTypes.Steel:
          return "钢铁";
         case ResourceTypes.Submarine:
          return "潜艇";
         case ResourceTypes.WeekQuest:
          return "每周任务";
         default:
          return "未知";
     }
 }
Exemple #21
0
        /// <summary>
        /// Selects the two resources after the YearOfPlenty card is played. Can only be called by the active player.
        /// </summary>
        public ActionResult PlayerSelectResourcesForYearOfPlenty(int playerId, ResourceTypes res1, ResourceTypes res2)
        {
            var validation = ValidatePlayerAction(PlayerTurnState.YearOfPlentySelectingResources, playerId);
            if (validation.Failed) return validation;

            var pr = GetPlayerFromId(playerId);
            if (pr.Failed) return pr;
            var activePlayer = pr.Data;

            activePlayer.ResourceCards[res1]++;
            activePlayer.ResourceCards[res2]++;

            _playerTurnState = PlayerTurnState.TakeAction;

            return ActionResult.CreateSuccess();
        }
 protected void OnCategoryProcessing( ResourceTypes aCategory )
 {
     if ( CategoryProcessing != null )
     CategoryProcessing( this, new CategoryProcessEventArgs( aCategory ) );
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="AuthorizationRule"/> class.
        /// </summary>
        /// <param name="resources">The resources that the rule applies to as a list of one or more names (names with *, % for wildcards supported).</param>
        /// <param name="resourceTypes">The resource types.</param>
        /// <param name="permissionType">Type of the permission.</param>
        /// <param name="identities">The identities that the rule applies to as a list of one or more names (names with *, % for wildcards supported).</param>
        public AuthorizationRule(IEnumerable <string> resources, ResourceTypes resourceTypes, PermissionType permissionType, IEnumerable <string> identities)
        {
            // Argument checking
            if (resources == null)
            {
                throw new ArgumentNullException("resources");
            }
            if (identities == null)
            {
                throw new ArgumentNullException("identities");
            }


            this.Resources        = new HashSet <string>(identities, StringComparer.OrdinalIgnoreCase);
            this.ResourcePatterns = new List <Regex>();
            foreach (var resource in resources)
            {
                if (resource.IndexOfAny(new char[] { '*', '%' }) >= 0)
                {
                    var resourcePattern =
                        "^" +                         // Begining of the string
                        Regex.Escape(resource)
                        .Replace("\\*", "(.)+")       // Any length wild-card
                        .Replace("%", "(.)+")         // Any length wild-card
                        + "$";                        // End of the string

                    this.ResourcePatterns.Add(new Regex(resourcePattern, RegexOptions.Compiled | RegexOptions.IgnoreCase));
                }
                else
                {
                    this.Resources.Add(resource);
                }
            }

            // Sanity check
            if (this.Resources.Count == 0 && this.ResourcePatterns.Count == 0)
            {
                throw new ArgumentException(Properties.Resources.AtLeastOneResourceNameOrPatternIsRequired);
            }

            this.ResourceTypes  = resourceTypes;
            this.PermissionType = permissionType;

            this.Identities       = new HashSet <string>(identities, StringComparer.OrdinalIgnoreCase);
            this.IdentityPatterns = new List <Regex>();
            foreach (var identity in identities)
            {
                if (identity.IndexOfAny(new char[] { '*', '%' }) >= 0)
                {
                    var identityPattern =
                        "^" +                         // Begining of the string
                        Regex.Escape(identity)
                        .Replace("\\*", "(.)+")       // Any length wild-card
                        .Replace("%", "(.)+")         // Any length wild-card
                        + "$";                        // End of the string

                    this.IdentityPatterns.Add(new Regex(identityPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase));
                }
                else
                {
                    this.Identities.Add(identity);
                }
            }

            // Sanity check
            if (this.Identities.Count == 0 && this.IdentityPatterns.Count == 0)
            {
                throw new ArgumentException(Properties.Resources.AtLeastOneIdentityNameOrPatternIsRequired);
            }
        }
Exemple #24
0
 public PlayMonopolyCardAction(Guid initiatingPlayerId, ResourceTypes resourceType) : base(initiatingPlayerId)
     => this.ResourceType = resourceType;
Exemple #25
0
 private BitmapRef GetIf(ResourceTypes flag)
 {
     return(Types.HasFlag(flag) ? Get(flag, Scale) : null);
 }
Exemple #26
0
        /// <summary>
        /// Initializes a new instance of <see cref="IResource" /> using the specified parameters.
        /// </summary>
        /// <param name="etpAdapter">The ETP adapter.</param>
        /// <param name="uuid">The UUID.</param>
        /// <param name="uri">The URI.</param>
        /// <param name="resourceType">The resource type.</param>
        /// <param name="name">The name.</param>
        /// <param name="count">The count.</param>
        /// <param name="lastChanged">The last changed in microseconds.</param>
        /// <returns>The resource instance.</returns>
        public static IResource CreateResource(this IEtpAdapter etpAdapter, string uuid, EtpUri uri, ResourceTypes resourceType, string name, int count = 0, long lastChanged = 0)
        {
            if (etpAdapter.SupportedVersion == EtpVersion.v11)
            {
                return(Discovery11StoreProvider.New(uuid, uri, resourceType, name, count, lastChanged));
            }

            return(Discovery12StoreProvider.New(uuid, uri, resourceType, name, count, lastChanged));
        }
Exemple #27
0
 public void store_resource(ResourceTypes resource, int amount)
 {
     _resourcesInWarehouse[resource] += amount;
 }
Exemple #28
0
        /// <summary>
        /// Extracts the raw data of the resource from the module.
        /// </summary>
        /// <param name="hModule">The module handle.</param>
        /// <param name="resourceId">The identifier of the resource.</param>
        /// <param name="resourceType">The type of the resource.</param>
        /// <returns>The resource raw data.</returns>
        private static byte[] GetResourceData(SafeModuleHandle hModule, int resourceId, ResourceTypes resourceType)
        {
            //Find the resource in the module.
            IntPtr hResInfo = DllImports.FindResource(hModule, (IntPtr)resourceId, resourceType);

            if (hResInfo == IntPtr.Zero)
            {
                throw new Win32Exception();
            }
            //Load the resource.
            IntPtr hResData = DllImports.LoadResource(hModule, hResInfo);

            if (hResData == IntPtr.Zero)
            {
                throw new Win32Exception();
            }
            //Lock the resource to read data.
            IntPtr hGlobal = DllImports.LockResource(hResData);

            if (hGlobal == IntPtr.Zero)
            {
                throw new Win32Exception();
            }
            //Get the resource size.
            int resSize = DllImports.SizeofResource(hModule, hResInfo);

            if (resSize == 0)
            {
                throw new Win32Exception();
            }
            //Allocate the requested size.
            byte[] buf = new byte[resSize];
            //Copy the resource data into our buffer.
            Marshal.Copy(hGlobal, buf, 0, buf.Length);

            return(buf);
        }
 public GatherResourceGoal(ResourceTypes type, int priority) : base(priority)
 {
     resourceType = type;
 }
 public static float GetResourceQuantityFromType(ResourceTypes resourceType)
 {
     return(GetResources()[resourceType]);
 }
Exemple #31
0
 /// <summary>
 /// Increases passed resource by the passed amount
 /// </summary>
 /// <param name="res">The resource to increase</param>
 /// <param name="amount">The amount to increase it with</param>
 public void IncreaseResource(ResourceTypes res, int amount)
 {
     this.resources[(int)res] += amount;
 }
Exemple #32
0
 public static extern bool EnumResourceNames(IntPtr hModule, ResourceTypes lpszType, EnumResNameProc lpEnumFunc, IntPtr lParam);
Exemple #33
0
 /// <summary>
 /// Sets a resource to a certain amount
 /// </summary>
 /// <param name="res">The resource to set</param>
 /// <param name="amount">The amount to set it to</param>
 public void SetResource(ResourceTypes res, int amount)
 {
     this.resources[(int)res] = amount;
 }
Exemple #34
0
 public static string GetResource(DivergenceScale scale, ResourceTypes type)
 {
     return(Embedding.Combine("Resources", $"{scale}", $"Nixie{type}.png"));
 }
Exemple #35
0
 public void PlayYearOfPlentyCard(ResourceTypes firstResource, ResourceTypes secondResource)
 {
     this.SendAction(new PlayYearOfPlentyCardAction(this.playerId, firstResource, secondResource));
 }
Exemple #36
0
 public void SetHexResourceType(ResourceTypes pResourceType)
 {
     hexResourceType = pResourceType;
     GetComponentInChildren <BackgroundHandlerScript>().SetBackgroundImage(pResourceType);
 }
		/// <summary>
		/// GetDocuments
		/// </summary>
		/// <param name="userInfo"></param>
		/// <param name="className"></param>
		/// <param name="treeProvider"></param>
		/// <param name="where"></param>
		/// <param name="orderby"></param>
		/// <param name="columnNames"></param>
		/// <param name="whereTextClause"></param>
		/// <param name="lookupDataSet"></param>
		/// <param name="pResourceType"></param>
		/// <returns>List</returns>
        protected List<Resource> GetDocuments(UserInfo userInfo, string className, TreeProvider treeProvider,
            string where,
			string orderby, string[] columnNames, string whereTextClause, DataSet lookupDataSet,
			ResourceTypes pResourceType = ResourceTypes.All)
		{
			if (whereTextClause != "")
			{
				where += where == "" ? columnNames[1] + whereTextClause : " AND " + columnNames[1] + whereTextClause;
			}
            DataSet resourceDs = KenticoHelper.ExpandedSearchDocumentType(userInfo, className, treeProvider,
                pResourceType, where,
				orderby, filterUsageRightExpiredContent);

			List<Resource> lstResource = new List<Resource>();

			if (resourceDs != null)
			{

				lstResource = (from res in resourceDs.Tables[0].AsEnumerable()
                    join ctdtl in lookupDataSet.Tables[0].AsEnumerable() on Convert.ToInt32(res["type"].ToString())
                        equals
								   Convert.ToInt32(ctdtl["enum"].ToString())
                    join stdtl in lookupDataSet.Tables[0].AsEnumerable() on Convert.ToInt32(res["subtype"].ToString())
                        equals
								   Convert.ToInt32(stdtl["enum"].ToString())
							   select
								   new Resource
								   {
									   NodeAliasPath = res["NodeAliasPath"].ToString(),
									   ResourceName = res[columnNames[1]].ToString(),
									   Description = res[columnNames[0]].ToString(),
									   Type = ctdtl["Description"].ToString(),
									   Subtype = stdtl["Description"].ToString(),
									   ViewLink =
										   columnNames[2] != ""
                                    ? string.IsNullOrEmpty(res[columnNames[2]].ToString())
                                        ? ""
                                        : res[columnNames[2]].ToString()
											   : string.Empty,
									   ID = Convert.ToInt32(res["DocumentID"]),
									   DocumentForeignKeyValue = Convert.ToInt32(res["DocumentForeignKeyValue"].ToString()),
									   DocumentType = res["ClassName"].ToString(),
									   DocumentNodeID = Convert.ToInt32(res["DocumentNodeID"]),
                                       ExpirationDate = res["ExpirationDate"] == DBNull.Value ? default(DateTime) : Convert.ToDateTime(res["ExpirationDate"]),
									   AverageRating = res["AverageRating"] == DBNull.Value ? default(decimal) : Convert.ToDecimal(res["AverageRating"])		  
								   }).ToList<Resource>();

				return lstResource;

			}
			return lstResource;
		}
Exemple #38
0
 public static extern IntPtr FindResource(IntPtr hModule, IntPtr lpName, ResourceTypes lpType);
Exemple #39
0
        // --------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Adds a resource to a view if it has not been added yet.
        /// </summary>
        /// <param name="name">An name to use to represent this resource.  Typically this should be the file name and extension of the resource (minus any path information).</param>
        /// <param name="resourcePath">A URI to the script to add to the page.</param>
        /// <param name="resourceType">The type of the resource returned from the given resource path.</param>
        /// <param name="renderTarget">Where to render the resource.</param>
        public virtual ResourceInfo RequireResource(string name, string resourcePath, ResourceTypes resourceType, RenderTargets renderTarget = RenderTargets.Header)
        {
            var context = Page.Context;

            if (context == null)
            {
                throw new InvalidOperationException("RequireScript: No valid '{CDS}.View.Context' exists.");
            }

            // ... find the file location so we can validate based on the actual location of the file, and not a virtual path ...

            var actionContext = View.ViewContext;

            // ... next, update the global content resource list ...

            var resourceList = GetService <IResourceList>();

            if (resourceList == null)
            {
                throw new InvalidOperationException("The service type 'IResourceList' has no implementation (this is usually 'ResourceList').");
            }

            var resource = resourceList.Find(name, resourcePath, actionContext);

            if (resource == null)
            {
#if DEBUG
                var debug = true;
#else
                var debug = false;
#endif
                resource = resourceList.Add(name, resourcePath, resourceType, renderTarget, 0 /*x View.ActivationSequence*/, null, debug);
            }

            return(resource);
        }
Exemple #40
0
        /// <summary>
        /// Save resource data from given sds data.
        /// </summary>
        /// <param name="xml"></param>
        public void SaveResources(FileInfo file)
        {
            XPathDocument doc = null;

            if (string.IsNullOrEmpty(ResourceInfoXml) == false)
            {
                using (var reader = new StringReader(ResourceInfoXml))
                    doc = new XPathDocument(reader);
            }
            else
            {
                int type = -1;
                for (int i = 0; i != ResourceTypes.Count; i++)
                {
                    if (ResourceTypes[i].Name == "")
                    {
                        type = (int)ResourceTypes[i].Id;
                    }
                }

                if (type != -1)
                {
                    for (int i = 0; i < ResourceEntries.Count; i++)
                    {
                        if (ResourceEntries[i].TypeId == type)
                        {
                            using (MemoryStream stream = new MemoryStream(ResourceEntries[i].Data))
                            {
                                ushort authorLen = stream.ReadValueU16();
                                stream.ReadBytes(authorLen);
                                int fileSize = stream.ReadValueS32();
                                int password = stream.ReadValueS32();

                                using (var reader = new StringReader(Encoding.UTF8.GetString(stream.ReadBytes(fileSize))))
                                {
                                    doc = new XPathDocument(reader);
                                }
                            }
                            ResourceEntries.RemoveAt(i);
                            ResourceTypes.RemoveAt(type);
                        }
                    }
                }
            }

            if (doc != null)
            {
                var nav   = doc.CreateNavigator();
                var nodes = nav.Select("/xml/ResourceInfo/SourceDataDescription");
                while (nodes.MoveNext() == true)
                {
                    _ResourceNames.Add(nodes.Current.Value);
                }
                Log.WriteLine("Found all items; count is " + nodes.Count);
            }


            if (_ResourceNames.Count == 0)
            {
                //Fix for friends for life SDS files.
                //MessageBox.Show("Detected SDS with no ResourceXML. I do not recommend repacking this SDS. It could cause crashes!", "Toolkit", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Log.WriteLine("Detected SDS with no ResourceXML. I do not recommend repacking this SDS. It could cause crashes!", LoggingTypes.WARNING);
                for (int i = 0; i != ResourceEntries.Count; i++)
                {
                    ResourceEntry Entry    = ResourceEntries[i];
                    string        Typename = _ResourceTypes[Entry.TypeId].Name;

                    // TODO: Find a new place for this.
                    string Extension = ".bin";
                    if (Typename == "Texture")
                    {
                        Extension = ".dds";
                    }
                    else if (Typename == "Generic")
                    {
                        Extension = ".genr";
                    }
                    else if (Typename == "Flash")
                    {
                        Extension = ".fla";
                    }
                    else if (Typename == "hkAnimation")
                    {
                        Extension = ".hkx";
                    }

                    string FileName = string.Format("File_{0}{1}", i, Extension);
                    _ResourceNames.Add(FileName);
                }
            }

            if (Version == 19)
            {
                SaveResourcesVersion19(file, _ResourceNames);
            }
            else if (Version == 20)
            {
                SaveResourcesVersion20(file, _ResourceNames);
            }
        }
Exemple #41
0
        public static ManagementObject NewResource(this ManagementObject VM, ResourceTypes ResType, string SubType, ManagementScope Scope)
        {
            var pool = new ManagementObjectSearcher(Scope, new SelectQuery(VMStrings.ResourcePool,
                                                                           "ResourceType = " + (ushort) ResType +
                                                                           " and ResourceSubType = '" + SubType + "'"))
                .Get().Cast<ManagementObject>().ToArray();

            return !pool.Any()
                       ? null
                       : new ManagementObject(pool.SelectMany(
                           item =>
                           item.GetRelated("MSVM_AllocationCapabilities")
                               .Cast<ManagementObject>()
                               .SelectMany(
                                   cap =>
                                   cap.GetRelationships("MSVM_SettingsDefineCapabilities")
                                      .Cast<ManagementObject>()
                                      .Where(defCap => uint.Parse(defCap["ValueRole"].ToString()) == 0))).First()["PartComponent"].ToString());

            /*
            if (!pool.Any())
                       return null;
            var var1 = pool.SelectMany(item => item.GetRelated("MSVM_AllocationCapabilities").Cast<ManagementObject>());
            var var2 = var1.SelectMany(cap =>cap.GetRelationships("MSVM_SettingsDefineCapabilities").Cast<ManagementObject>());
            var var3 = var2.Where(defCap => uint.Parse(defCap["ValueRole"].ToString()) == 0);
            var var4 = var3.First();
            return var4;
            */

            /*
            var AllocQuery = new SelectQuery("MSVM_AllocationCapabilities",
                    "ResourceType = " + (ushort)ResType +" and ResourceSubType = '" + SubType + "'");
            var AllocResult = new ManagementObjectSearcher(Scope, AllocQuery).Get().Cast<ManagementObject>().FirstOrDefault();
            var objQuery = new SelectQuery("MSVM_SettingsDefineCapabilities",
                    "ValueRange = 0");
            var objOut = new ManagementObjectSearcher(Scope, objQuery).Get().Cast<ManagementObject>();
            objOut = objOut.Where(each => {
                                            return each == null ? false
                                                 : each["GroupComponent"] == null ? false
                                                 : each["GroupComponent"].ToString().Equals(AllocResult["__Path"].ToString());
                                           });
            var Out = objOut.First();
            var MC = GetObject(Out["PartComponent"].ToString());

            return MC;
            /*
            var MgmtSvc = GetServiceObject(Scope, ServiceNames.VSManagement);
            ManagementBaseObject inputs = MgmtSvc.GetMethodParameters("AddVirtualSystemResources");
            inputs["TargetSystem"] = VM.Path.Path;
            inputs["ResourceSettingData"] = new []{MC.GetText(TextFormat.WmiDtd20)};

            var result = MgmtSvc.InvokeMethod("AddVirtualSystemResources", inputs, null);

            switch (Int32.Parse(result["ReturnValue"].ToString()))
            {
                case (int)ReturnCodes.OK:
                    var tmp = result["NewResources"];
                    return GetObject(((ManagementObject[])result["NewResources"]).First()["__Path"].ToString());
                case (int)ReturnCodes.JobStarted:
                    var job = GetObject(result["Job"].ToString());
                    var r = WaitForJob(job);
                    if (r == 0)
                    {
                        var res = result["NewResources"];
                        var arr = (ManagementBaseObject[])res;
                        var fir = arr.First();
                        var path = fir["__Path"].ToString();
                        var o = GetObject(path);
                        return GetObject(((ManagementObject[])result["NewResources"]).First()["__Path"].ToString());
                    }
                    return null;
                default:
                    return null;
            }
            */
        }
Exemple #42
0
 public void PlayMonopolyCard(ResourceTypes resourceType)
 {
     this.SendAction(new PlayMonopolyCardAction(this.playerId, resourceType));
 }
Exemple #43
0
 /// <summary>
 ///     A well-known resource-type identifier.
 /// </summary>
 /// <param name="value">A well known resource type.</param>
 public ResourceId(ResourceTypes value)
 {
     Id = (IntPtr)value;
 }
        public void readInformations(ref int offset)
        {
            UInt32 nameOffset = (UInt32)this.Name.getValue();

            // the directory is named
            if (nameOffset >= 0x80000000)
            {
                isNamedDirectory = true;

                // insure the size
                UInt32 nameDefinitionBlock = (nameOffset - (UInt32)0x80000000);

                int nameBlockOffset = (int)nameDefinitionBlock + resources.resourceBaseAddress;

                // read the name length
                int unicodeStringSize = reader.readByte(nameBlockOffset);

                // read the unicode name
                directoryName = reader.readUnicodeString(nameBlockOffset + 1, unicodeStringSize);
            }

            // the directory has a common id
            else
            {
                // the directory id is typed
                if (firstNode)
                {
                    // don't know how I can handle properly exceptions here
                    directoryType = (ResourceTypes)Enum.Parse(typeof(ResourceTypes), Enum.GetName(typeof(ResourceTypes), (int)nameOffset), true);
                    directoryId   = (int)nameOffset;
                }

                // the directory id is an ordinal
                else
                {
                    directoryId = (int)nameOffset;
                }
            }

            UInt32 tableOffset = (UInt32)this.OffsetToData.getValue();

            if (tableOffset >= 0x80000000)
            {
                // insure the size
                UInt32 nextResourceDirectoryTable = (tableOffset - (UInt32)0x80000000);

                // probably the wrost way to do it
                offset = (int)nextResourceDirectoryTable + resources.resourceBaseAddress;

                ResourceDirectoryTable newEntry = new ResourceDirectoryTable(this.resources, this.reader, entries, ref offset);

                this.resourceTables.Add(newEntry);
            }
            else
            {
                // probably the wrost way to do it
                offset = (int)tableOffset + resources.resourceBaseAddress;

                this.dataEntry = new ResourceDataEntry(this.resources, this.reader, entries, ref offset);
            }
        }
Exemple #45
0
 /// <summary>
 /// Gets the image icon index for the given resource type
 /// </summary>
 /// <param name="resType">Type of the resource.</param>
 /// <returns></returns>
 public static int GetImageIndexForResourceType(ResourceTypes resType)
 {
     switch (resType)
     {
         case ResourceTypes.ApplicationDefinition:
             return RES_APPLICATIONDEFINITION;
         case ResourceTypes.DrawingSource:
             return RES_DRAWINGSOURCE;
         case ResourceTypes.FeatureSource:
             return RES_FEATURESOURCE;
         case ResourceTypes.Folder:
             return RES_FOLDER;
         case ResourceTypes.LayerDefinition:
             return RES_LAYERDEFINITION;
         case ResourceTypes.LoadProcedure:
             return RES_LOADPROCEDURE;
         case ResourceTypes.MapDefinition:
             return RES_MAPDEFINITION;
         case ResourceTypes.PrintLayout:
             return RES_PRINTLAYOUT;
         case ResourceTypes.SymbolDefinition:
             return RES_SYMBOLDEFINITION;
         case ResourceTypes.SymbolLibrary:
             return RES_SYMBOLLIBRARY;
         case ResourceTypes.WatermarkDefinition:
             return RES_WATERMARK;
         case ResourceTypes.WebLayout:
             return RES_WEBLAYOUT;
         default:
             throw new ArgumentException();
     }
 }
Exemple #46
0
        public ScenarioRunner ReceivesYearOfPlentyCardPlayedEvent(ResourceTypes firstResource, ResourceTypes secondResource, string playerName = null)
        {
            var playerId  = playerName != null ? this.playerAgentsByName[playerName].Id : this.currentPlayerAgent.Id;
            var gameEvent = new YearOfPlentyCardPlayedEvent(playerId, firstResource, secondResource);

            this.AddEventInstruction(gameEvent);
            return(this);
        }
Exemple #47
0
 public static ManagementObject NewResource(this ManagementObject VM, ResourceTypes ResType, string SubType, string Server = null)
 {
     return NewResource(VM, ResType, SubType, Server==null?VM.GetScope():GetScope(Server));
 }
Exemple #48
0
 public ScenarioRunner ThenPlayMonopolyCard(ResourceTypes resourceType)
 {
     this.AddActionInstruction(ActionInstruction.OperationTypes.PlayMonopolyCard,
                               new object[] { resourceType });
     return(this);
 }
		/// <summary>
		/// Get all plans from kentico based on search criteria
		/// </summary>
		/// <param name="ui"></param>
		/// <param name="treeProvider"></param>
		/// <param name="whereClauseIp"></param>
		/// <param name="whereClauseUp"></param>
		/// <param name="whereClauseLp"></param>
		/// <param name="whereClauseMu"></param>
		/// <param name="whereTextSearch"></param>
		/// <param name="lookupDataSet"></param>
		/// <param name="districtParms"></param>
		/// <param name="resUnitType"></param>
		/// <returns>List</returns>
        private List<Resource> GetPlans(UserInfo ui, TreeProvider treeProvider, string whereClauseIp,
            string whereClauseUp,
			string whereClauseLp, string whereClauseMu, string whereTextSearch, DataSet lookupDataSet,
			DistrictParms districtParms, ResourceTypes resUnitType)
		{

			List<Resource> buildList = new List<Resource>();
			buildList.AddRange(GetDocumentResource(ui, IpClassName, treeProvider, whereClauseIp, string.Empty,
				whereTextSearch, lookupDataSet, resUnitType));
			buildList.AddRange(GetDocumentResource(ui, UpClassName, treeProvider, whereClauseUp, string.Empty,
				whereTextSearch, lookupDataSet, resUnitType));
			buildList.AddRange(GetDocumentResource(ui, LpClassName, treeProvider, whereClauseLp, string.Empty,
				whereTextSearch, lookupDataSet, resUnitType));
			if (districtParms.State.ToUpper() == "OH")
				buildList.AddRange(GetDocumentResource(ui, GetKenticoCurricumumUnitTypeName(districtParms),
					treeProvider, whereClauseMu, string.Empty, whereTextSearch, lookupDataSet, resUnitType));
			return buildList;
		}
Exemple #50
0
 public ScenarioRunner ThenPlayYearOfPlentyCard(ResourceTypes firstResource, ResourceTypes secondResource)
 {
     this.AddActionInstruction(ActionInstruction.OperationTypes.PlayYearOfPlentyCard,
                               new object[] { firstResource, secondResource });
     return(this);
 }
		/// <summary>
		/// GetDocumentResource
		/// </summary>
		/// <param name="ui"></param>
		/// <param name="className"></param>
		/// <param name="treeProvider"></param>
		/// <param name="whereClause"></param>
		/// <param name="orderby"></param>
		/// <param name="whereTextClause"></param>
		/// <param name="lookupDataSet"></param>
		/// <param name="pResourceType"></param>
		/// <returns>List</returns>
		protected List<Resource> GetDocumentResource(UserInfo ui, string className, TreeProvider treeProvider,
			string whereClause, string orderby, string whereTextClause, DataSet lookupDataSet,
			ResourceTypes pResourceType = ResourceTypes.All)
		{

            int lookupval = GetDocTypeValueFromTileMap(className, ui);
			CustomTableItemProvider tp = new CustomTableItemProvider((UserInfo)Session["KenticoUserInfo"]);
			string filtercriteria = "LookupValue = " + lookupval + " and (ISNULL(StateLEA,'')='' or StateLEA = '" +
									DistrictParms.LoadDistrictParms().ClientID + "' or StateLEA = '" +
									DistrictParms.LoadDistrictParms().State + "')";
			DataSet resourcesToShow = tp.GetItems("thinkgate.TileMap_Lookup", filtercriteria, string.Empty);

			List<Resource> lstResource = new List<Resource>();
			foreach (DataRow dr in resourcesToShow.Tables[0].Select().OrderBy(p => p["ItemOrder"].ToString()))
			{
                if (isInstructionMaterial == true && dr["KenticoDocumentTypeToShow"].ToString().ToLower() == "thinkgate.competencylist")
                {
                    continue;
                }
				string[] columnNames =
				{
					dr["DescriptionColumnName"].ToString(), dr["NameColumnName"].ToString(),
					dr["AttachmentColumnName"].ToString(), dr["FriendlyName"].ToString()
				};
				List<Resource> resource =
					(from s in
                        GetDocuments(ui, dr["KenticoDocumentTypeToShow"].ToString(), treeProvider, whereClause,
                            string.Empty, columnNames,
							 whereTextClause, lookupDataSet, pResourceType)
					 select new Resource
					 {
						 Source =
							 s.NodeAliasPath.IndexOf(_districts.ToString(), StringComparison.Ordinal) >= 0
								 ? District
                                    : s.NodeAliasPath.IndexOf(_stateDocuments.ToString(), StringComparison.Ordinal) >= 0
                                        ? State
                                            : s.NodeAliasPath.IndexOf(_sharedDocuments.ToString(), StringComparison.Ordinal) >= 0
                                            ? SharedDocument //US15667
                                                : MyDocuments,
						 ID = s.ID,
						 DocumentType = s.DocumentType,
						 ID_Encrypted = "",
						 NodeAliasPath = s.NodeAliasPath,
						 ResourceName = s.ResourceName,
						 Description = s.Description,
						 Type = s.Type,
						 Subtype = s.Subtype,
						 ViewLink = s.ViewLink,
						 DocumentForeignKeyValue = s.DocumentForeignKeyValue,
						 DocumentNodeID = Convert.ToInt32(s.DocumentNodeID),
                         ExpirationDate = s.ExpirationDate,
                         AverageRating = s.AverageRating
												  
					 }).ToList<Resource>();
				if (resource.Count == 0)
				{
					resource = new List<Resource>();
				}
				lstResource.AddRange(resource);
			}
			return lstResource;
		}
Exemple #52
0
        /// <summary>
        /// Adds a child KmlItem to this nodes lists of children, depending of its
        /// derived class KmlNode, KmlPart, KmlAttrib or further derived from these.
        /// When an KmlAttrib "Name", "Type" or "Root" are found, their value
        /// will be used for the corresponding property of this node.
        /// </summary>
        /// <param name="beforeItem">The KmlItem where the new item should be inserted before</param>
        /// <param name="newItem">The KmlItem to add</param>
        protected override void Add(KmlItem beforeItem, KmlItem newItem)
        {
            if (newItem is KmlAttrib)
            {
                KmlAttrib attrib = (KmlAttrib)newItem;
                if (attrib.Name.ToLower() == "type")
                {
                    Type = attrib.Value;

                    // Get notified when Type changes
                    attrib.AttribValueChanged += Type_Changed;
                    attrib.CanBeDeleted        = false;
                }
                else if (attrib.Name.ToLower() == "sit")
                {
                    Situation = attrib.Value;

                    // Get notified when Type changes
                    attrib.AttribValueChanged += Situation_Changed;
                    attrib.CanBeDeleted        = false;
                }
                else if (attrib.Name.ToLower() == "root")
                {
                    SetRootPart(attrib.Value);

                    // Get notified when Type changes
                    attrib.AttribValueChanged += Root_Changed;
                    attrib.CanBeDeleted        = false;
                }
            }
            else if (newItem is KmlPart)
            {
                KmlPart part = (KmlPart)newItem;
                if (beforeItem != null)
                {
                    KmlPart beforePart = null;
                    int     allIndex   = AllItems.IndexOf(beforeItem);
                    for (int i = allIndex; i < AllItems.Count; i++)
                    {
                        if (AllItems[i] is KmlPart && Parts.Contains((KmlPart)AllItems[i]))
                        {
                            beforePart = (KmlPart)AllItems[i];
                            break;
                        }
                    }
                    if (beforePart != null)
                    {
                        beforePart.InsertionPreparation();
                        Parts.Insert(Parts.IndexOf(beforePart), part);
                        beforePart.InsertionFinalization();
                    }
                    else
                    {
                        Parts.Add(part);
                    }
                }
                else
                {
                    Parts.Add(part);
                }
                if (Parts.Count == rootPartIndex + 1)
                {
                    RootPart = Parts[rootPartIndex];
                }
                if (part.Flag != "" && !Flags.Any(x => x.ToLower() == part.Flag.ToLower()))
                {
                    Flags.Add(part.Flag);
                }
                if (part.HasResources)
                {
                    foreach (string resType in part.ResourceTypes)
                    {
                        ResourceTypes.Add(resType);
                    }
                }
                KmlAttrib flag = part.GetAttrib("flag");
                if (flag != null)
                {
                    flag.AttribValueChanged += Flag_Changed;
                }
            }
            base.Add(beforeItem, newItem);
        }
Exemple #53
0
 public ResourceItem(ResourceTypes resourceType, int amount)
 {
     ResourceType = resourceType;
     Amount       = amount;
 }
Exemple #54
0
 //Checks if there is at least one material for the queried resource type in the warehouse
 public bool HasResourceInWarehoues(ResourceTypes resource)
 {
     return(_resourcesInWarehouse[resource] >= 1);
 }
Exemple #55
0
        /// <summary>
        /// Selects the resource type after the Monopoly card is played. Can only be called by the active player.
        /// </summary>
        public ActionResult PlayerSelectResourceForMonopoly(int playerId, ResourceTypes resource)
        {
            var validation = ValidatePlayerAction(PlayerTurnState.MonopolySelectingResource, playerId);
            if (validation.Failed) return validation;

            var pr = GetPlayerFromId(playerId);
            if (pr.Failed) return pr;
            var activePlayer = pr.Data;

            // Remove all the resources of the specified type from
            // the other players and give them to the active player.
            var otherPlayers = Players.Where(p => p.Id != playerId);
            var resCount = 0;
            foreach (var otherPlayer in otherPlayers)
            {
                resCount += otherPlayer.RemoveAllResources(resource);
            }
            activePlayer.ResourceCards[resource] += resCount;

            _playerTurnState = PlayerTurnState.TakeAction;

            return ActionResult.CreateSuccess();
        }
Exemple #56
0
        /// <summary>
        /// Adds local file storage
        /// </summary>
        /// <param name="serviceCollection"></param>
        /// <returns></returns>
        public static IServiceCollection AddLocalFileStorage(this IServiceCollection serviceCollection)
        {
            ResourceTypes.Add <LocalLocator>();

            return(serviceCollection.AddSingleton <IFileStorage, LocalFileStorage>());
        }
Exemple #57
0
        public static string getQuestRewardStr(UserQuest q)
        {
            string r = "";
             ResourceTypes[] typesArray = new ResourceTypes[] { ResourceTypes.Oil, ResourceTypes.Ammo, ResourceTypes.Steel, ResourceTypes.Aluminium };
             for (int i = 0; i < 4 && i < q.award.Count; i++)
             {
                 string key = ((int)typesArray[i]) + string.Empty;
                 if (q.award.ContainsKey(key))
                 {
                     r += tools.helper.getresourcetype(typesArray[i]) + ":" + q.award[key] + " ";
                 }
             }
             r += "\r\n";
             if (q.AwardShipId > 0)
             {
                 ShipConfig config = AllShipConfigs.instance.getShip(q.AwardShipId);
                 if (config != null)
                 {
                     r += tools.helper.getshiptype(config.type) + ":" + config.title;
                 }
             }
             else
             {
                 if (q.AwardItemId > 0)
                 {
                     r += tools.helper.getItemtypestr(q.AwardItemId) + " X" + q.GetItemAmount(q.AwardItemId);

                 }
                 else
                 {
                     if (q.AwardEquipId > 0)
                     {
                         EquipmentConfig ec = GameConfigs.instance.GetEquipmentByCid(q.AwardEquipId);
                         if (ec != null)
                         {
                             r += tools.helper.getEquipmentTypeString(ec.type) + ":" + ec.title;
                         }
                     }
                 }
             }
             return r;
        }
Exemple #58
0
        public ResourceCollection(ResourceTypes resourceType)
        {
            this.resourceType = resourceType;

            resources = new Dictionary <string, Resource>();
        }
Exemple #59
0
 /// <summary>
 /// Sets the XML content and the type of resource this XML content is supposed to represent
 /// </summary>
 /// <param name="xml"></param>
 /// <param name="type"></param>
 public void SetXmlContent(string xml, ResourceTypes type)
 {
     _ed.XmlContent = xml;
     this.ResourceType = type;
 }
 public int GetResourceAmount(ResourceTypes type)
 {
     return(resources[type]);
 }