public virtual int ProductPerHour(ResourcesType type)
        {
            int level = 0;
            switch (type)
            {
                case ResourcesType.Clay:
                    level = this.Village.VillageBuildingData.ClayPit;
                    break;
                case ResourcesType.Wood:
                    level = this.Village.VillageBuildingData.TimberCamp;
                    break;
                case ResourcesType.Iron:
                    level = this.Village.VillageBuildingData.IronMine;
                    break;
                default:
                    break;
            }

            if (level == 0)
                return 0;
            int result = 20;
            for (int i = 0; i < level; i++)
                result += (int)(result * 0.2);
            return result;
        }
 // Invoke the Content Changed event
 public virtual void OnContentChanging(ResourcesType contentType)
 {
     if (ContentChanging != null)
     {
         ContentChanging(contentType);
     }
 }
 private void HandleContentChanging(ResourcesType newContentType)
 {
     switch (newContentType)
     {
         case ResourcesType.MainContent: // clear previous, set to main
             //_currentContent.SaveData();
             _previousContent.Clear();
             _currentContent = _mainPanel;
             UpdateContentInUI();
             break;
         case ResourcesType.DeafHoHResourcesContent: MoveToContentPanel(_deafHohPanel);
             break;
         default: break;
     }
 }
        public virtual Offer CreateOffer(ResourcesType offerType, int offerQuantity, ResourcesType forType, int forQuantity, int maxTransportTime, int offerNumber)
        {
            
            if (this.Village[offerType] < offerQuantity * offerNumber)
                throw new TribalWarsException("Không đủ tài nguyên");
            if (Math.Ceiling((double)(offerQuantity * offerNumber / 1000)) > this.Village.VillageBuildingData.Merchant)
                throw new TribalWarsException("Không đủ thương nhân");
            if (offerType==forType)
                throw new TribalWarsException("Nhập loại tài nguyên");


            Offer offer = new Offer();
            offer.AtVillage = this.Village;
            offer.ForQuantity = forQuantity;
            offer.ForType = forType;
            offer.MaxTransportTime = maxTransportTime;
            offer.OfferNumber = offerNumber;
            offer.OfferQuantity = offerQuantity;
            offer.OfferType = offerType;

            return offer;
        }
        public virtual double SecondPerResourceUnit(ResourcesType type)
        {

            int level = 0;
            switch (type)
            {
                case ResourcesType.Clay:
                    level = this.Village.VillageBuildingData.ClayPit;
                    break;
                case ResourcesType.Wood:
                    level = this.Village.VillageBuildingData.TimberCamp;
                    break;
                case ResourcesType.Iron:
                    level = this.Village.VillageBuildingData.IronMine;
                    break;
                default:
                    break;
            }

            double production = this.ProductPerHour(type);
            if (production == 0)
                return double.MaxValue;
            return (double)3600 / production;
        }
        public virtual IList<Offer> GetOffers(ResourcesType forType, ResourcesType offerType, double maxDuration, double maxRatio, string orderby, ISession session)
        {
            var query = (from offer in session.Linq<Offer>()
                         where offer.AtVillage != this.Village
                         select offer);

            if (forType != ResourcesType.Any)
                query = query.Where<Offer>(offer => offer.ForType == forType);
            if (offerType != ResourcesType.Any)
                query = query.Where<Offer>(offer => offer.OfferType == offerType);
            if (maxDuration >0)
                query = query.Where<Offer>(offer => offer.MaxTransportTime <= maxDuration && Map.RangeCalculator(this.Village.X, this.Village.Y, offer.AtVillage.X, offer.AtVillage.Y) <= maxDuration);
            if (maxRatio > 0)
                query = query.Where<Offer>(offer => offer.OfferQuantity / offer.ForQuantity <= maxRatio);

            if (orderby == "Duration")
                query = query.OrderBy(offer => Map.RangeCalculator(this.Village.X, this.Village.Y, offer.AtVillage.X, offer.AtVillage.Y));
            else if (orderby == "Ration")
                query = query.OrderBy(offer => offer.OfferQuantity / offer.ForQuantity);

            return query.ToList<Offer>();
        }
Example #7
0
        /// <summary>
        /// Formatte et renvoie un dictionnaire contenant une ressource et une quantité
        /// associée (correspondant à une collecte)
        /// </summary>
        /// <param name="resource"></param>
        /// <param name="qty"></param>
        /// <returns></returns>
        public static SerializableDictionary <ResourcesType, int> GetResourcesCollected(ResourcesType resource, int qty)
        {
            var formatedResource = new SerializableDictionary <ResourcesType, int>();

            formatedResource.Add(resource, qty);

            return(formatedResource);
        }
Example #8
0
 public int this[ResourcesType Type]
 {
     get
     {
         return list[Type];
     }
     set
     {
         list[Type] = value;
     }
 }
Example #9
0
 public Resources(int countValue, ResourcesType typeValue)
 {
     count = countValue;
     type  = typeValue;
 }
Example #10
0
 private void SetupLocalizationOptions(string resourcesPath, ResourcesType resourcesType = ResourcesType.TypeBased)
 => _localizationOptions.Setup(o => o.Value)
 .Returns(() => new JsonLocalizationOptions {
     ResourcesPath = resourcesPath,
     ResourcesType = resourcesType
 });
 public static T GetResources <T> (ResourceRoleType roleType, ResourcesType type, string resourceName)
     where T : UnityEngine.Object
 {
     return(ResourcesLoadManager.Instance.GetResources <T> (roleType.ToString(), type.ToString(), resourceName));
 }
Example #12
0
 public static string GetFileExtension(ResourcesType type)
 {
     return(GetResourcePath(type, ResourcesPathMode.Extension));
 }
Example #13
0
        public static string GetResourcePath(ResourcesType type, ResourcesPathMode mode)
        {
            int index = (int)mode;

            string[] path = null;
            switch (type)
            {
            case ResourcesType.UIWnd:
                path = UIWndPath;
                break;

            case ResourcesType.UIWndItem:
                path = UIWndItemPath;
                break;

            case ResourcesType.UIAtlas:
                path = UIAtlasPath;
                break;

            case ResourcesType.UIPublicWndAtlas:
                path = UIPublicAtlasPath;
                break;

            case ResourcesType.SceneItem:
                path = SceneItemPath;
                break;

            // hero
            case ResourcesType.ActorHero:
                path = ActorHeroPath;
                break;

            case ResourcesType.ActorShowHero:
                path = ActorHeroShowPath;
                break;

            case ResourcesType.HeroAnim:
                path = HeroAnimPath;
                break;

            // soldier
            case ResourcesType.ActorSoldier:
                path = ActorSoldierPath;
                break;

            case ResourcesType.ActorSoldierMaterial:
                path = ActorSoldierMaterialPath;
                break;

            case ResourcesType.ActorSoldierMesh:
                path = ActorSoldierMeshPath;
                break;

            case ResourcesType.ActorSoldierAnim:
                path = ActorSoldierAnimPath;
                break;

            case ResourcesType.Building:
                path = BuildingPath;
                break;

            case ResourcesType.BuildingModel:
                path = BuildingModelPath;
                break;

            case ResourcesType.BuildingSite:
                path = BuildingSitePath;
                break;

            case ResourcesType.CityTree:
                path = CityTreePath;
                break;

            case ResourcesType.BuildingTexture:
                path = BuildingTexturePath;
                break;

            case ResourcesType.PngTexture:
                path = PngTexturePath;
                break;

            case ResourcesType.Effect:
                path = EffectPath;
                break;

            case ResourcesType.Skill:
                path = SkillPath;
                break;

            case ResourcesType.Audio:
                path = AudioPath;
                break;

            case ResourcesType.Shader:
                path = ShaderPath;
                break;

            case ResourcesType.Map:
                path = MapPath;
                break;

            case ResourcesType.Scene:
                path = ScenePath;
                break;

            case ResourcesType.MapData:
                path = MapDataPath;
                break;

            case ResourcesType.LuaData:
                path = LuaDataPath;
                break;

            case ResourcesType.ComMaterial:
                path = ComMaterialPath;
                break;

            case ResourcesType.Depend:      //LightMapPath
                path = DependPath;
                break;

            case ResourcesType.Config:
                path = ConfigPath;
                break;
            }

            if (null == path)
            {
                return(string.Empty);
            }

            return(path[index]);
        }
 public virtual int TimeTillFullWarehouse(DateTime from, ResourcesType type)
 {
     int canStore = this.Village.MaxResources - this.Village[type];
     return (int)(canStore * this.SecondPerResourceUnit(type));
 }
Example #15
0
 protected void VillageResourceData_ResourceChanged(ResourcesType type, int value, int max)
 {
     switch (type)
     {
         case ResourcesType.Clay:
             this.ClayLabel.Text = value.ToString();
             //if (value == max)
             //this.ClayLabel.CssClass
             break;
         case ResourcesType.Wood:
             this.WoodLabel.Text = value.ToString();
             break;
         case ResourcesType.Iron:
             this.IronLabel.Text = value.ToString();
             break;
         default:
             break;
     }
     
 }
Example #16
0
 public float this[ResourcesType i]
 {
     get => this[(int)i];
Example #17
0
 public ResourceOverallItem(ResourcesType type)
 {
     Type = type;
 }
Example #18
0
 public static string ReturnResourceTypeAsString(ResourcesType resourcesType)
 {
     return(resourcesType == ResourcesType.ThumbUpLocation ? "Location" : resourcesType.ToString());
 }
Example #19
0
 public void AddResources(ResourcesType type, int qty)
 {
     PlayerPrefs.SetInt(type.ToString(), PlayerPrefs.GetInt(type.ToString()) + qty);
     UpdateUI();
 }
Example #20
0
        public static int AddAdhocResource(string fileNameFullPathToConfigFile, TemplateData templateData, out string errorMessage)
        {
            List <AdhocTemplate> listWithAdhocTemplates;
            Resource             resource, newResource;

            try
            {
                errorMessage           = null;
                listWithAdhocTemplates = ReturnListWithAdhocTemplates(fileNameFullPathToConfigFile, out errorMessage);

                if (errorMessage != null)
                {
                    return(-1);
                }

                int    resourceId    = ResourceUtility.ReturnNextResourceId();
                string filePrefix    = "R";
                string fileExtension = templateData.Id == 1 ? ".cs" : ".html";
                string fileNameFullPathCjProjFile = listWithAdhocTemplates[templateData.Id - 1].CsProjFileFullPath;
                string folderPrefix = "Nr";
                int    currentResourceFolderIndex = listWithAdhocTemplates[templateData.Id - 1].CurrentResourceFolderIndex;
                int    maxNumberOfFilesInAFolder  = listWithAdhocTemplates[templateData.Id - 1].MaxNumberOfFilesInFolder;
                string resourceFolder             = listWithAdhocTemplates[templateData.Id - 1].ResourceFolder;
                string textForNonIncludeFileToCreate;

                if (templateData.Id == 1)
                {
                    textForNonIncludeFileToCreate = templateData.CodeText.Replace("\n", "\r\n").Replace("#####", resourceId.ToString());
                }
                else
                {
                    textForNonIncludeFileToCreate = templateData.CodeText.Replace("\n", "\r\n");
                }

                int nextResourceFolderIndex;

                Utility.InsertNoneIncludeFileInCsProj(
                    resourceId,
                    filePrefix,
                    fileExtension,
                    fileNameFullPathCjProjFile,
                    folderPrefix,
                    currentResourceFolderIndex,
                    maxNumberOfFilesInAFolder,
                    resourceFolder,
                    textForNonIncludeFileToCreate,
                    out nextResourceFolderIndex,
                    out errorMessage
                    );

                if (errorMessage != null)
                {
                    return(-1);
                }

                if (nextResourceFolderIndex != currentResourceFolderIndex)
                {
                    listWithAdhocTemplates[templateData.Id - 1].CurrentResourceFolderIndex = nextResourceFolderIndex;
                    SaveListWithAdhocTemplates(fileNameFullPathToConfigFile, listWithAdhocTemplates);
                }

                int           id               = 0;
                ResourcesType resourcesType    = templateData.Id == 1 ? ResourcesType.Self : ResourcesType.Html;
                string        created          = null;
                string        title            = templateData.Title;
                string        keyWords         = templateData.KeyWords;
                string        note             = templateData.Note;
                int           previousResource = 0;
                int           nextResource     = 0;
                string        thumbUpLocation  = null;
                string        htmlFile         = templateData.Id == 1 ? null : string.Format("{0}\\Nr{1}\\R{2}.html", listWithAdhocTemplates[templateData.Id - 1].Href, currentResourceFolderIndex.ToString(), resourceId.ToString());
                string        files            = templateData.Id == 1 ? string.Format("{0}\\Nr{1}\\R{2}.cs", listWithAdhocTemplates[templateData.Id - 1].ResourceFolder, currentResourceFolderIndex.ToString(), resourceId.ToString()) : null;
                string        links            = null;

                resource = new Resource(
                    id,
                    resourcesType,
                    created,
                    title,
                    keyWords,
                    note,
                    previousResource,
                    nextResource,
                    thumbUpLocation,
                    htmlFile,
                    files,
                    links);

                newResource = ResourceUtility.AddResource(resource, out errorMessage);

                if (errorMessage != null)
                {
                    return(-1);
                }
            }
            catch (Exception e)
            {
                errorMessage = string.Format("ERROR!! An Exception occured in method AddAdhocResource! e.Message:\r\n{0}", e.Message);
                return(-1);
            }

            return(newResource.Id);
        }
Example #21
0
 public int GetResourcesQty(ResourcesType type)
 {
     return PlayerPrefs.GetInt(type.ToString());
 }
Example #22
0
 public void Set(int countValue, ResourcesType typeValue)
 {
     count = countValue;
     type  = typeValue;
 }
Example #23
0
 public static float GetCource(ResourcesType bye, ResourcesType sell) => Mathf.Min(Cource[(int)bye] / Cource[(int)sell], 1000);
Example #24
0
        public void InstallServer()
        {
            //Find Server
            if (string.IsNullOrEmpty(ServerPath))
            {
                bool foundServer = TryFindWarewolfServerExe(out string serverPath);
                if (foundServer)
                {
                    ServerPath = serverPath;
                }
                else
                {
                    throw new ArgumentException($"No server found. Make sure your server is compiled and try again.");
                }
            }
            else
            {
                if (!File.Exists(ServerPath))
                {
                    throw new ArgumentException($"No server found at {ServerPath}. Make sure your server is compiled and try again.");
                }
            }
            Console.WriteLine("Will now stop any currently running Warewolf servers and studios. Resources will be backed up to " + TestRunner.TestsResultsPath + ".");
            if (string.IsNullOrEmpty(ResourcesType))
            {
                Console.WriteLine("\nWhat type of resources would you like to install the server with?");
                var options = new[] {
                    "[u]UITests: Use these resources for running UI Tests. (This is the default)",
                    "[s]ServerTests: Use these resources for running everything except unit tests and Coded UI tests.",
                    "[r]Release: Use these resources for Warewolf releases.",
                    "[l]Load: Use these resources for Desktop UI Load Testing."
                };
                foreach (var option in options)
                {
                    Console.WriteLine();
                    var originalColour = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.Write(option.Substring(0, 3));
                    Console.ForegroundColor = originalColour;
                    Console.Write(option.Substring(3, option.Length - 3));
                }
                Console.WriteLine("\n\nOr Press Enter to use default (UITest)...");

                ResourcesType = WindowUtils.PromptForUserInput();
                if (ResourcesType == "" || ResourcesType.ToLower() == "u")
                {
                    ResourcesType = "UITests";
                }
                if (ResourcesType.ToLower() == "s")
                {
                    ResourcesType = "ServerTests";
                }
                if (ResourcesType.ToLower() == "r")
                {
                    ResourcesType = "Release";
                }
                if (ResourcesType.ToLower() == "l")
                {
                    ResourcesType = "Load";
                }
            }

            string resourcesPath = Path.Combine(Path.GetDirectoryName(ServerPath), $"Resources - {ResourcesType}");

            if (!Directory.Exists(resourcesPath))
            {
                throw new ArgumentException($"Invalid resource type. Folder not found {resourcesPath}");
            }

            if (!StartServerAsConsole)
            {
                var ServerService = ServiceController.GetServices().Any(serviceController => serviceController.ServiceName.Equals("Warewolf Server"));
                if (!ApplyDotCover)
                {
                    if (!ServerService)
                    {
                        Process.Start("sc.exe", "create \"Warewolf Server\" binPath= \"" + ServerPath + "\" start= demand");
                    }
                    else
                    {
                        Console.WriteLine("Configuring service to " + ServerPath);
                        Process.Start("sc.exe", "config \"Warewolf Server\" binPath= \"" + ServerPath + "\" start= demand");
                    }
                }
                else
                {
                    var ServerBinDir = Path.GetDirectoryName(ServerPath);
                    var RunnerXML    = @"<AnalyseParams>
    <TargetExecutable>" + ServerPath + @"</TargetExecutable>
    <Output>" + Environment.ExpandEnvironmentVariables("%ProgramData%") + @"\Warewolf\Server Log\dotCover.dcvr</Output>
    <Scope>
	    <ScopeEntry>"     + ServerBinDir + @"\*.dll</ScopeEntry>
	    <ScopeEntry>"     + ServerBinDir + @"\*.exe</ScopeEntry>
    </Scope>
    <Filters>
        <ExcludeFilters>
            <FilterEntry>
                <ModuleMask>*.tests</ModuleMask>
                <ModuleMask>*.specs</ModuleMask>
            </FilterEntry>
        </ExcludeFilters>
        <AttributeFilters>
            <AttributeFilterEntry>
                <ClassMask>System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute</ClassMask>
            </AttributeFilterEntry>
        </AttributeFilters>
    </Filters>
</AnalyseParams>";

                    var DotCoverRunnerXMLPath = TestRunner.TestsResultsPath + "\\Server DotCover Runner.xml";
                    TestCleanupUtils.CopyOnWrite(DotCoverRunnerXMLPath);
                    File.WriteAllText(DotCoverRunnerXMLPath, RunnerXML);
                    RunServerWithDotcoverScript = "\\\"" + DotCoverPath + "\\\" cover \\\"" + DotCoverRunnerXMLPath + "\\\" /LogFile=\\\"" + TestRunner.TestsResultsPath + "\\ServerDotCover.log\\\"";
                    if (!ServerService)
                    {
                        Process.Start("sc.exe", "create \"Warewolf Server\" binPath= \"" + RunServerWithDotcoverScript + "\" start= demand");
                    }
                    else
                    {
                        Console.WriteLine("Configuring service to " + RunServerWithDotcoverScript);
                        Process.Start("sc.exe", "config \"Warewolf Server\" binPath= \"" + RunServerWithDotcoverScript + "\"");
                    }
                }
            }
            if (!string.IsNullOrEmpty(ServerUsername) && string.IsNullOrEmpty(ServerPassword))
            {
                Process.Start("sc.exe", "config \"Warewolf Server\" obj= \"" + ServerUsername + "\"");
            }
            if (!string.IsNullOrEmpty(ServerUsername) && !string.IsNullOrEmpty(ServerPassword))
            {
                Process.Start("sc.exe", "config \"Warewolf Server\" obj= \"" + ServerUsername + "\" password= \"" + ServerPassword + "\"");
            }

            var ResourcePathSpecs = new List <string>();

            foreach (var ServerPathSpec in ServerPathSpecs)
            {
                if (ServerPathSpec.EndsWith(ServerExeName))
                {
                    ResourcePathSpecs.Add(ServerPathSpec.Replace(ServerExeName, "Resources - " + ResourcesType));
                }
            }
            var ResourcesDirectory = FindFileInParent(ResourcePathSpecs);

            if (ResourcesDirectory != "" && ResourcesDirectory != Path.GetDirectoryName(ServerPath) + "\\" + Path.GetFileName(ResourcesDirectory))
            {
                RecursiveFolderCopy(ResourcesDirectory, Path.GetDirectoryName(ServerPath));
            }
        }
Example #25
0
 public static bool WantToBuy(State state, ResourcesType type) => wantToBuy[(int)type].Contains(state.stateAI);
Example #26
0
 public LocalizedDisplayNameAttribute(ResourcesType resourceType, string resourceName) : base(resourceName)
 {
     this.resourceType = resourceType;
     this.resourceName = resourceName;
 }
Example #27
0
 public TradeDeal(State seller, ResourcesType sellres, float sell, State byer, ResourcesType byeres, float bye) =>
 (State1, ResType1, Res1, State2, ResType2, Res2) = (seller, sellres, sell, byer, byeres, bye);
Example #28
0
 public Deal(State state, ResourcesType sellres, float sell, ResourcesType byeres, float bye) =>
 (State, SellRes, Sell, BuyRes, Buy) = (state, sellres, sell, byeres, bye);
Example #29
0
 public void ChangeResourcesType(ResourcesType type)
 {
     showResource = type;
     ShowStates();
 }
Example #30
0
 public ResourceOverallItem( ResourcesType type )
 {
     Type = type;
 }
Example #31
0
 public virtual int this[ResourcesType resource]
 {
     get
     {
         switch (resource)
         {
             case ResourcesType.Clay:
                 return this.VillageResourceData.Clay;
             case ResourcesType.Wood:
                 return this.VillageResourceData.Wood;
             case ResourcesType.Iron:
                 return this.VillageResourceData.Iron;
             default:
                 return 0;
         }
     }
     set
     {
         switch (resource)
         {
             case ResourcesType.Clay:
                 this.VillageResourceData.Clay = value;
                 break;
             case ResourcesType.Wood:
                 this.VillageResourceData.Wood = value;
                 break;
             case ResourcesType.Iron:
                 this.VillageResourceData.Iron = value;
                 break;
             default:
                 break;
         }
     }
 }