private void StartHarvest(Resource resource) { resourceDeposit = resource; StartMove(resource.transform.position); if (type != resource.GetResourceType()) { type = resource.GetResourceType(); currentLoad = 0; } state = WOState.Harvesting; }
/* Private Methods */ private void StartHarvest(Resource resource) { resourceDeposit = resource; StartMove(resource.transform.position, resource.gameObject); //we can only collect one resource at a time, other resources are lost if (harvestType == ResourceType.Unknown || harvestType != resource.GetResourceType()) { harvestType = resource.GetResourceType(); currentLoad = 0.0f; } harvesting = true; emptying = false; }
private void StartHarvest(Resource resource) { resourceDeposit = resource; resourceStores = player.GetComponentsInChildren <Building>(); MoveToLocation(resource.transform.position); //we can only collect one resource at a time, other resources are lost if (harvestType != resource.GetResourceType()) { harvestType = resource.GetResourceType(); currentLoad = 0.0f; } harvesting = true; emptying = false; }
private string GetReturnTypeFromResourceType(Method method, Resource resource, string key, string responseCode, string fullUrl) { var returnType = string.Empty; if (resource.Type == null || !resource.Type.Any() || !raml.ResourceTypes.Any(rt => rt.ContainsKey(resource.GetResourceType()))) { return(returnType); } var verb = GetResourceTypeVerb(method, resource); if (verb == null || verb.Responses == null || !verb.Responses.Any(r => r != null && r.Body != null && r.Body.Values.Any(m => !string.IsNullOrWhiteSpace(m.Schema)))) { return(returnType); } var response = verb.Responses.FirstOrDefault(r => r.Code == responseCode); if (response == null) { return(returnType); } var resourceTypeMimeType = GeneratorServiceHelper.GetMimeType(response); if (resourceTypeMimeType != null) { returnType = GetReturnTypeFromResponseWithoutCheckingResourceTypes(method, resource, resourceTypeMimeType, key, responseCode, fullUrl); } return(returnType); }
private void StartHarvest(Resource resource) { if (audioElement != null) { audioElement.Play(startHarvestSound); } resourceDeposit = resource; StartMove(resource.transform.position, resource.gameObject); if (harvestType == ResourceType.Unknown || harvestType != resource.GetResourceType()) { harvestType = resource.GetResourceType(); currentLoad = 0.0f; } harvesting = true; emptying = false; }
private static string ReplaceCustomParameters(Resource resource, string res) { var regex = new Regex(@"\<\<([^>]+)\>\>", RegexOptions.IgnoreCase); var matchCollection = regex.Matches(res); foreach (Match match in matchCollection) { if (resource.Type == null) { continue; } var paramFound = match.Groups[1].Value; var type = resource.GetResourceType(); if (string.IsNullOrWhiteSpace(type) || !resource.Type.ContainsKey(type) || resource.Type[type] == null || !resource.Type[type].ContainsKey(paramFound)) { continue; } var value = resource.Type[type][paramFound]; res = res.Replace("<<" + paramFound + ">>", value); } return(res); }
public ActionAdjustResources(Resource _resource) { resource = _resource; // check if enough resources inventory = Player.Instance.GetInventory(); isAdjustmentPossible = ((inventory.GetResource(resource.GetResourceType()) + resource.GetAmount()) >= 0); }
public HarvestCommand(Unit unit, Resource resource) { if (unit.canharvest) { //sanity check (I don't think this is need though) this.unit = unit; this.resource = resource; if(harvesttype == ResourceType.None || harvesttype !=resource.GetResourceType()) { //ensure we are carrying the right resource harvesttype = resource.GetResourceType(); unit.currentload = 0.0f; } harvesting = true; moveCommand = new MoveCommand (unit, resource.transform.position); unit.IssueSubCommand (moveCommand); } else { complete = true; } }
public static bool IsValidFile(string filePath) { if (!File.Exists(filePath)) { return(false); } using (var stream = File.OpenRead(filePath)) return(Resource.GetResourceType(stream) == ResourceType.ModelPack); }
private void StopHarvest() { //idle = true; harvesting = false; emptying = false; if (resourceDeposit && resourceDeposit.GetResourceType() == ResourceType.Food) { resourceDeposit.CanHarvest = true; } }
public void AddResource(Resource _resource) { bool foundResource = false; for (int i = 0; i < resourceList.Count; i++) { if (resourceList[i].GetResourceType() == _resource.GetResourceType()) { foundResource = true; resourceList[i].Add(_resource.GetAmount()); } } if (!foundResource) { resourceList.Add(new Resource(_resource.GetAmount(), _resource.GetResourceType())); } EventBroadcast.Instance.TriggerEvent(EventBroadcast.Event.RESOURCE_VALUES_UPDATED); }
//Empty in turret public void EmptyInventoryInTurret() { Resource resource = this.playerInventory.GetResource(); for (int i = 0; i < resource.GetAmount(); i++) { this.myTurret.AddResourceToInventory(resource.GetResourceType()); } this.playerInventory.ClearInventory(); GameObject.Destroy(resource.gameObject); this.playerSounds.PlayOneShot(this.grabSomething); }
//Empty on ground public void EmptyInventoryOnGround() { Resource resource = this.playerInventory.GetResource(); Vector2 whereToInstantiateResource = new Vector2(transform.position.x, transform.position.y); Resource resourceCreated = InstantiateResource(resource.GetResourceType(), whereToInstantiateResource); short lol = resource.GetAmount(); resourceCreated.initialise(resource.GetAmount()); this.playerInventory.ClearInventory(); GameObject.Destroy(resource.gameObject); this.playerSounds.PlayOneShot(this.grabSomething); }
private string ReplaceParametersWithFunctions(Resource resource, string res, string url) { var regex = new Regex(@"\<\<([a-z_-]+)\s?\|\s?\!(pluralize|singularize)\>\>", RegexOptions.IgnoreCase); var matchCollection = regex.Matches(res); foreach (Match match in matchCollection) { string replacementWord; switch (match.Groups[1].Value) { case "resourcePathName": replacementWord = url.Substring(1); break; case "resourcePath": replacementWord = url.Substring(1); break; case "methodName": replacementWord = url.Substring(1); break; default: var paramFound = match.Groups[1].Value; var type = resource.GetResourceType(); if (string.IsNullOrWhiteSpace(type)) { continue; } if (!resource.Type[type].ContainsKey(paramFound)) { continue; } replacementWord = resource.Type[type][paramFound]; break; } if (match.Groups[2].Value == "singularize") { res = res.Replace(match.Groups[0].Value, Singularize(replacementWord)); } else if (match.Groups[2].Value == "pluralize") { res = res.Replace(match.Groups[0].Value, Pluralize(replacementWord)); } } return(res); }
public override void MouseClick(GameObject hitObject, Vector3 hitPoint, Player controller) { base.MouseClick(hitObject, hitPoint, controller); bool doBase = true; //only handle input if owned by a human player if (player && player.human) { if (hitObject && hitObject.name != "Ground") { //idle = false; Resource resource = hitObject.transform.parent.GetComponent <Resource>(); Building building = hitObject.transform.parent.GetComponent <Building>(); if (resource && !resource.isEmpty()) { //make sure that we select harvester remains selected if (resource.GetResourceType() == ResourceType.Food && !resource.CanHarvest) { } else { if (player.SelectedObject) { player.SelectedObject.SetSelection(false, playingArea); } SetSelection(true, playingArea); player.SelectedObject = this; StartHarvest(resource); } } if (building) { if (building.UnderConstruction()) { SetBuilding(building); doBase = false; } } } else { StopHarvest(); } if (doBase) { base.MouseClick(hitObject, hitPoint, controller); } } }
protected Verb GetResourceTypeVerb(Method method, Resource resource) { var resourceTypes = raml.ResourceTypes.First(rt => rt.ContainsKey(resource.GetResourceType())); var resourceType = resourceTypes[resource.GetResourceType()]; Verb verb; switch (method.Verb) { case "get": verb = resourceType.Get; break; case "delete": verb = resourceType.Delete; break; case "post": verb = resourceType.Post; break; case "put": verb = resourceType.Put; break; case "patch": verb = resourceType.Patch; break; case "options": verb = resourceType.Options; break; default: throw new InvalidOperationException("Verb not found " + method.Verb); } return(verb); }
public void ScanForResources(float range) { Collider[] colliders = Physics.OverlapSphere(transform.position, range); for (int i = 0; i < colliders.Length; i++) { Resource resource = colliders[i].GetComponent <Resource>(); if (resource != null) { if (miningEfficiency.ContainsKey(resource.GetResourceType())) { resourcesInRange.Add(resource); } } } }
public void CastSpellAtAttackableTarget(Spells name) { if (target.IsTargetAttackable()) { spell = GetCastableWithName(name); if (!resource.CanCastSpell(spell)) { errorMessage.Show("Not enough " + resource.GetResourceType() + "!"); } StartCasting(); } else { errorMessage.Show("No target or target is friendly."); } }
public static ImmutableDictionary <string, IOutputCompletionSource> InitializeOutputs(Resource resource) { var name = resource.GetResourceName(); var type = resource.GetResourceType(); var query = from property in resource.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance) let attr1 = property.GetCustomAttribute <Pulumi.OutputAttribute>() #pragma warning disable 618 let attr2 = property.GetCustomAttribute <Pulumi.Serialization.OutputAttribute>() #pragma warning restore 618 where attr1 != null || attr2 != null select(property, attrName : attr1?.Name ?? attr2?.Name); var result = ImmutableDictionary.CreateBuilder <string, IOutputCompletionSource>(); foreach (var(prop, attrName) in query.ToList()) { var propType = prop.PropertyType; var propFullName = $"[Output] {resource.GetType().FullName}.{prop.Name}"; if (!propType.IsConstructedGenericType || propType.GetGenericTypeDefinition() != typeof(Output <>)) { throw new InvalidOperationException($"{propFullName} was not an Output<T>"); } var setMethod = prop.DeclaringType !.GetMethod("set_" + prop.Name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); if (setMethod == null) { throw new InvalidOperationException($"{propFullName} did not have a 'set' method"); } var outputTypeArg = propType.GenericTypeArguments.Single(); Converter.CheckTargetType(propFullName, outputTypeArg, new HashSet <Type>()); var ocsType = typeof(OutputCompletionSource <>).MakeGenericType(outputTypeArg); var ocsContructor = ocsType.GetConstructors().Single(); var completionSource = (IOutputCompletionSource)ocsContructor.Invoke(new[] { resource }); setMethod.Invoke(resource, new[] { completionSource.Output }); var outputName = attrName ?? prop.Name; result.Add(outputName, completionSource); } Log.Debug("Fields to assign: " + JsonSerializer.Serialize(result.Keys), resource); return(result.ToImmutable()); }
//Adds resources to the stockpile array. void AddResourceToStockpile(Resource resource) { stockpiledResources[(int)resource.GetResourceType()].IncreaseYield(resource.GetYield()); }
protected GeneratorParameter GetParameter(string key, Method method, Resource resource, string fullUrl) { var schema = GetJsonSchemaOrDefault(method.Body); if (schema != null) { var generatorParameter = GetGeneratorParameterWhenNamed(method, resource, schema, fullUrl); if (generatorParameter != null) { return(generatorParameter); } } if (resource.Type != null && resource.Type.Any() && raml.ResourceTypes.Any(rt => rt.ContainsKey(resource.GetResourceType()))) { var verb = GetResourceTypeVerb(method, resource); if (verb != null && verb.Body != null && !string.IsNullOrWhiteSpace(verb.Body.Schema)) { var generatorParameter = GetGeneratorParameterWhenNamed(method, resource, verb.Body.Schema, fullUrl); if (generatorParameter != null) { return(generatorParameter); } } } if (RequestHasKey(key)) { return(GetGeneratorParameterByKey(key)); } var requestKey = key + GeneratorServiceBase.RequestContentSuffix; if (RequestHasKey(requestKey)) { return(GetGeneratorParameterByKey(requestKey)); } if (linkKeysWithObjectNames.ContainsKey(key)) { var linkedKey = linkKeysWithObjectNames[key]; if (RequestHasKey(linkedKey)) { return(GetGeneratorParameterByKey(linkedKey)); } } if (linkKeysWithObjectNames.ContainsKey(requestKey)) { var linkedKey = linkKeysWithObjectNames[requestKey]; if (RequestHasKey(linkedKey)) { return(GetGeneratorParameterByKey(linkedKey)); } } return(new GeneratorParameter { Name = "content", Type = "string" }); }
private static void UpdateBarScale(Resource res) { Transform obj = res.GetUIObjectTransform(); if (obj) { const float defaultScale = 1; // this is full length float newScale = defaultScale * res.GetVal() / (float)m_resources[res.GetResourceType()].GetMaxValue(); float scaleDiff = (obj.localScale.x - newScale); float diff = 0; if (scaleDiff != 0) { diff = scaleDiff * res.GetUIObjectWidth() / 2; } obj.localScale = new Vector3(newScale, obj.localScale.y, obj.localScale.z); obj.Translate(new Vector3(-diff, 0f, 0f)); } }
public void RemoveResource(Resource resource) { RemoveResource(resource.GetResourceType(), resource.GetAmount()); }
/*** Private Methods ***/ private void StartHarvest(Resource resource) { resourceDeposit = resource; if (audioElement != null) audioElement.Play(startHarvestSound); StartMove (resource.transform.position, resource.gameObject); //we can only collect one resource at a time, other resources are lost if (harvestType == ResourceType.Unknown || harvestType != resource.GetResourceType ()) { harvestType = resource.GetResourceType(); currentLoad = 0.0f; } harvesting = true; emptying = false; }
private void StartHarvest(Resource resource) { resourceDeposit = resource; resourceStores = player.GetComponentsInChildren<Building>(); MoveToLocation(resource.transform.position); //we can only collect one resource at a time, other resources are lost if(harvestType != resource.GetResourceType()) { harvestType = resource.GetResourceType(); currentLoad = 0.0f; } harvesting = true; emptying = false; }
protected override bool CanImportCore(Stream stream, string filename = null) { return(Resource.GetResourceType(stream) == ResourceType.ModelPack); }
protected override bool CanImportCore( Stream stream, string filename = null ) { return Resource.GetResourceType( stream ) == ResourceType.Light; }
private void ActionFromHit(Collider2D hit) { Resource resource = hit.transform.GetComponentInParent <Resource>(); CellType cellType = resource.GetCellType(); ResourceType resourceType = resource.GetResourceType(); switch (cellType) { case CellType.RESOURCE_BRUT: if (this.player.isSomethingInMyInventory() == 0) { if (this.timerToBrakeResource == 100) { this.timerToBrakeResource = resource.GetTimerToBrakeResource(); } else if (this.timerToBrakeResource <= 0) { Vector3 positionToSpawnNewResource = hit.transform.parent.transform.position; Resource prefab = null; if (resourceType == ResourceType.IRON_ORE) { prefab = this.player.prefabIronPlate; } if (resourceType == ResourceType.COPPER_ORE) { prefab = this.player.prefabCopperPlate; } if (resourceType == ResourceType.MAGNUM_ORE) { prefab = this.player.prefabMagnumPlate; } GameObject.Instantiate <Resource>(prefab, positionToSpawnNewResource, new Quaternion()); GameObject.Destroy(hit.transform.parent.gameObject); this.player.ResetProgressBar(); this.timerToBrakeResource = 100; this.timerToPickUpItem = 0.6f; } this.timerToBrakeResource -= Time.deltaTime; this.player.PlusOnProgressBar(resource.GetTimerToBrakeResource()); this.player.PlayMiningSound(); } break; case CellType.RESOURCE_SMELT: if (this.player.isSomethingInMyInventory() < 3) { if (this.player.GetInventoryType() == resourceType || this.player.GetInventoryType() == ResourceType.EMPTY) { short amountICanGrab = (short)(3 - this.player.isSomethingInMyInventory()); short amountToGrab = resource.GetAmount(); short nbTourDeBoucle = 0; if (amountToGrab > amountICanGrab) { nbTourDeBoucle = amountICanGrab; } else { nbTourDeBoucle = amountToGrab; } for (short i = 0; i < nbTourDeBoucle; i++) { this.player.AddResourceToInventory(resourceType); resource.DescreaseAmount(); } if (resource.GetAmount() > 0) { resource.SwapSprite(); } else { GameObject.Destroy(hit.transform.parent.gameObject); } this.timerToPickUpItem = this.delayToPickItem; } else { //TODO swap resources } } break; } }
public Type GetDepositType() { return(_resource.GetResourceType()); }
public void AddResource(Resource resource) { AddResource(resource.GetResourceType(), resource.GetAmount()); }
protected GeneratorParameter GetParameter(string key, Method method, Resource resource, IDictionary <string, ApiObject> schemaRequestObjects) { var schema = GetJsonSchemaOrDefault(method.Body); if (schema != null) { var generatorParameter = GetGeneratorParameterWhenNamed(method, resource, schemaRequestObjects, schema); if (generatorParameter != null) { return(generatorParameter); } } if (resource.Type != null && resource.Type.Any() && raml.ResourceTypes.Any(rt => rt.ContainsKey(resource.GetResourceType()))) { var verb = GetResourceTypeVerb(method, resource); if (verb != null && verb.Body != null && !string.IsNullOrWhiteSpace(verb.Body.Schema)) { var generatorParameter = GetGeneratorParameterWhenNamed(method, resource, schemaRequestObjects, verb.Body.Schema); if (generatorParameter != null) { return(generatorParameter); } } } if (schemaRequestObjects.ContainsKey(key) && schemaRequestObjects[key].Properties.Any()) { return new GeneratorParameter { Name = schemaRequestObjects[key].Name.ToLower(), Type = schemaRequestObjects[key].Name, Description = schemaRequestObjects[key].Description } } ; var requestKey = key + GeneratorServiceBase.RequestContentSuffix; if (schemaRequestObjects.ContainsKey(requestKey) && schemaRequestObjects[requestKey].Properties.Any()) { return new GeneratorParameter { Name = schemaRequestObjects[requestKey].Name.ToLower(), Type = schemaRequestObjects[requestKey].Name, Description = schemaRequestObjects[requestKey].Description } } ; return(new GeneratorParameter { Name = "json", Type = "string" }); }
private void StartHarvest(Resource resource) { StartMove(resource.transform.position, resource.gameObject); harvestType = resource.GetResourceType(); harvesting = true; }
private void StartHarvest(Resource resource) { resourceDeposit = resource; WorldObject worldObject = resource.gameObject.GetComponent<WorldObject>(); addMovement(worldObject); //we can only collect one resource at a time, other resources are lost if(harvestType == ResourceType.Unknown || harvestType != resource.GetResourceType()) { harvestType = resource.GetResourceType(); SetResourceColor(); resourceStore = WorkManager.findClosestResourceStore(WorkManager.findResourceStores(harvestType,player), this.gameObject.GetComponent<Unit>()); currentLoad = 0.0f; } harvesting = true; recycling = false; emptying = false; }
protected override bool CanImportCore(Stream stream, string filename = null) { return(Resource.GetResourceType(stream) == ResourceType.TextureDictionary); }
protected override bool CanImportCore(Stream stream, string filename = null) { return(Resource.GetResourceType(stream) == ResourceType.ChunkType000100F9); }
/* Private Methods */ private void StartHarvest(Resource resource) { resourceDeposit = resource; //we can only collect one resource at a time, other resources are lost if (harvestType == ResourceType.Unknown || harvestType != resource.GetResourceType()) { harvestType = resource.GetResourceType(); currentLoad = 0.0f; } harvesting = true; emptying = false; }
// Private Methods private void StartHarvest(Resource resource) { resourceDeposit = resource; if(currentLoad >= capacity) { StartMove(resourceStore.transform.position, resourceStore.gameObject); harvesting = false; emptying = true; } else { StartMove(resource.transform.position, resource.gameObject); harvesting = true; emptying = false; } //we can only collect one resource at a time, other resources are lost if(harvestType == ResourceType.Unknown || harvestType != resource.GetResourceType()) { harvestType = resource.GetResourceType(); currentLoad = 0.0f; } }