public async Task <ActionResult <RessourceType> > Create(RessourceTypeViewModel ressourceTypeIn) { if (!ModelState.IsValid) { return(BadRequest(new ValidationProblemDetails(ModelState))); } var ressourceType = new RessourceType { Description = ressourceTypeIn.Description, Name = ressourceTypeIn.Name, Type = ressourceTypeIn.Type }; try { await _ressourceTypeService.Create(ressourceType); } catch (RessourceTypeRepositoryException ex) { ModelState.AddModelError(ex.Field, ex.Message); return(BadRequest(new ValidationProblemDetails(ModelState))); } catch (Exception ex) { return(StatusCode(500, "Internal server error")); } return(CreatedAtRoute("GetRessourceType", new { id = ressourceType.Id.ToString() }, ressourceType)); }
public void AddRessource(RessourceType type, int value) { if (type != currentType) { currentType = type; currentRessourceTransportLoad = value; } else { currentRessourceTransportLoad += value; } if (currentType == RessourceType.fer) { ferLook.SetActive(true); merLook.SetActive(false); } else if (currentType == RessourceType.mer) { merLook.SetActive(true); ferLook.SetActive(false); } UpdateVisuals(); }
bool ressourceConsumer_OnRessourceConsumed(RessourceType type) { if (type == RessourceType.Green) { int probaConsumeGreen = 4; if (Random.Range(0, probaConsumeGreen) != 0) { return false; } return true; } else if (type == RessourceType.Blue) { int probaConsumeBlue = 3; if (Random.Range(0, probaConsumeBlue) != 0) { return false; } if (growthLevel == maxLevel) return false; currentRessources++; return true; } return false; }
private Ressource(RessourceType type, float size, float respawnTime) { this.type = type; this.size = size; this.respawnTime = respawnTime; isMoveable = false; }
public void GatherRessources(RessourceType ressource) { if (ressource == RessourceType.Parrot) { FoodStorage.IncreaseFoodBy(1); } }
public void ChangeInputRecipe(RessourceType inputRessource) { this.Progress = 0; this.Inventory.Storage.Clear(); this.Inventory.AddRessource(inputRessource); this.Inventory.AddRessource(TradeOutput); this.TradeInput = inputRessource; this.Inventory.RessourceLimits.Clear(); this.Inventory.RessourceLimits.Add(TradeInput, this.RessourceLimit - 1); if (this.Inventory.RessourceLimits.ContainsKey(TradeOutput)) { this.Inventory.RessourceLimits[TradeOutput] = this.RessourceLimit; } else { this.Inventory.RessourceLimits.Add(TradeOutput, 1); } this.Inventory.UpdateIncoming(new List <RessourceType> { inputRessource }); }
public void AddRessourceToDB(RessourceType pRessource, int pMass) { int oldValue=0; if(ressourceStorage.TryGetValue(pRessource, out oldValue)) ressourceStorage.Remove(pRessource); ressourceStorage.Add(pRessource, pMass+oldValue); }
// Buster proof private void ModifyRessource(RessourceType type, float delta) { // If delta value make your value bust, it assign max value type.valueReference.Value = (type.valueReference.Value + delta > type.maxValueReference.Value) ? type.maxValueReference.Value : type.valueReference.Value + delta; type.ressourceChangedEvent.Raise(); }
public void AddRessource(RessourceType ressourceType) { if (this.Storage.ContainsKey(ressourceType)) { return; } this.Storage.Add(ressourceType, 0); }
public int GetRessourceAmount(RessourceType ressourceType) { if (Storage.ContainsKey(ressourceType)) { return(Storage[ressourceType]); } return(0); }
public void GenerateRessources() { RessourceType generationType = currentLevel.ressourceGenTransaction.ressourceType; float generationQt = currentLevel.ressourceGenTransaction.delta; RessourceTransaction rt = currentSeason.Value.seasonModifiers.Find(sm => sm.ressourceType == generationType); ModifyRessource(generationType, generationQt + (rt != null ? rt.delta : 0)); }
public Ressource(RessourceType type, uint quantity) : base(ArrayOfPrefabResources[(int)type].Name, quantity, ArrayOfPrefabResources[(int)type].Weight, ArrayOfPrefabResources[(int)type].Type, (InventoryManager.ItemsUniqueID)type + 10) { typeRessources = type; }
public bool RemoveRessource(RessourceType ressourceType, int amount) { if (GetRessourceAmount(ressourceType) >= amount) { Storage[ressourceType] -= amount; return(true); } return(false); }
public static void BroadcastChangeRessourceLimit(HexCoordinates coordinates, RessourceType type, int newValue) { using (Packet packet = new Packet((int)ServerPackets.broadcastChangeRessourceLimit)) { packet.Write(coordinates); packet.Write((byte)type); packet.Write(newValue); SendTCPDataToAll(packet); } }
public static void BroadcastUpdateMarket(HexCoordinates coords, RessourceType type, bool isInput) { using (Packet packet = new Packet((int)ServerPackets.broadcastUpdateMarketRessource)) { packet.Write(coords); packet.Write((byte)type); packet.Write(isInput); SendTCPDataToAll(packet); } }
public void AddRessourceToDB(RessourceType pRessource, int pMass) { int oldValue = 0; if (ressourceStorage.TryGetValue(pRessource, out oldValue)) { ressourceStorage.Remove(pRessource); } ressourceStorage.Add(pRessource, pMass + oldValue); }
public void SetRessource(RessourceType type) { if (type == RessourceType.Wood) { image.texture = wood; } else { image.texture = food; } }
public void GatherRessources(RessourceType ressource) { if (ressource == RessourceType.Fish) { FoodStorage.IncreaseFoodBy(1); } else if (ressource == RessourceType.Wood) { Wood.IncreaseWoodBy(1); } }
ManagersRessource GetRessource(RessourceType type) { foreach (ManagersRessource ressource in ressources) { if (ressource.type == type) { return(ressource); } } return(null); }
public float GetRessourceAmount(RessourceType type) { foreach (RessourceSet item in ressources) { if (item.type == type) { return(item.amount); } } return(0f); }
public IEnumerator RessourceGiver(float pTime,NPC pTarget,RessourceType pRessource) { while(presentWorkers.Contains(pTarget) && listedWorkers.Contains(pTarget)){ if(pTarget.AddCargo (10, pRessource)){ ressourceStock = ressourceStock - 10; } else{ break; } yield return new WaitForSeconds(pTime); } }
public void AddRessource(RessourceType type, int value) { ManagersRessource ressource = GetRessource(type); ressource.value += value; if (ressource.value > ressource.capacity) { ressource.value = ressource.capacity; } UpdateUIRessources(); }
Pig GetPigComponentByType(RessourceType pigType) { foreach (Pig pig in m_pigs) { if (pig.m_Ressource == pigType) { return(pig); } } return(null); }
public void AssignToHarvesting(EC_HarvestingBuilding harvester) { if (state == WorkerState.Idle) { PlayerManager.Instance.RemoveIdleWorker(this); } this.assignedHarvester = harvester; assignedHarvesterType = harvester.type; state = WorkerState.Harvesting; harvestingState = HarvestingState.Idle; nextScanTime = Time.time; ChangeAcessories(); }
public void AddRessource(RessourceType type, float amount) { foreach (RessourceSet item in ressources) { if (item.type == type) { item.amount += amount; if (item.amount > item.capacity) { item.amount = item.capacity; } } } }
public Market( HexCell Cell, byte Tribe, byte Level, byte Health, TroopInventory TroopInventory, BuildingInventory Inventory, int Progress, RessourceType TradeInput, RessourceType TradeOutput ) : base(Cell, Tribe, Level, Health, TroopInventory, Inventory, Progress) { this.TradeInput = TradeInput; this.TradeOutput = TradeOutput; }
public bool IsThereEnoughOf(RessourceType type, float amount) { foreach (RessourceSet item in ressources) { if (item.type == type) { if (item.amount >= amount) { return(true); } } } return(false); }
public override int AddRessource(RessourceType ressourceType, int count) { int availableSpace = 0; if (Storage.ContainsKey(ressourceType)) { availableSpace = AvailableSpace(ressourceType); if (availableSpace > 0) { Storage[ressourceType] += Mathf.Min(availableSpace, count); } } return(Mathf.Min(availableSpace, count)); }
public IEnumerator RessourceGiver(float pTime, NPC pTarget, RessourceType pRessource) { while (presentWorkers.Contains(pTarget) && listedWorkers.Contains(pTarget)) { if (pTarget.AddCargo(10, pRessource)) { ressourceStock = ressourceStock - 10; } else { break; } yield return(new WaitForSeconds(pTime)); } }
public void EndOfSource(RessourceType collectRessource) { if (collectRessource == RessourceType.Fish) { resFish = false; } if (collectRessource == RessourceType.Parrot) { resParrot = false; } if (collectRessource == RessourceType.Wood) { resWood = false; } }
public RessourceType GetMainRessource() { RessourceType mainRessource = RessourceType.WOOD; int mainRessourceAmount = 0; foreach (RessourceType ressourceType in this.Storage.Keys) { if (Storage[ressourceType] > mainRessourceAmount) { mainRessourceAmount = Storage[ressourceType]; mainRessource = ressourceType; } } return(mainRessource); }
public void RemoveRessource(RessourceType type, float amount) { foreach (RessourceSet item in ressources) { if (item.type == type) { item.amount -= amount; if (item.amount <= 0) { if (item.vital) { entity.Destroy(); } } } } }
public async Task <RessourceType> Update(RessourceType ressourceTypeIn) { try { await _ressourceTypeRepository.Update(ressourceTypeIn); } catch (MongoWriteException mwx) { if (mwx.WriteError.Category == ServerErrorCategory.DuplicateKey) { var pattern = @"\{(?:[^{*}])*\}"; Match result = Regex.Match(mwx.Message, pattern); // get the dublicated feild from the string error msg JObject duplicatedField = JsonConvert.DeserializeObject <JObject>(result.Value); // parse it to get the field throw new RessourceTypeRepositoryException(string.Format(_errorHandler.GetMessage(ErrorMessagesEnum.DuplicateKey), nameof(RessourceType), duplicatedField.First.Path), duplicatedField.First.Path); } } return(ressourceTypeIn); }
int getAtlasY( RessourceType type ) { switch (type) { case RessourceType.None: return 0; case RessourceType.Blue: return 1; case RessourceType.Green: return 2; //case RessourceType.Yellow: // return 3; case RessourceType.Purple: return 4; case RessourceType.Heart: return 5; } return 7; }
public bool AddCargo(int newToAdd, RessourceType ressource) { if((cargoStatus + newToAdd) <= capacity && (cargoStatus + newToAdd) >= 0){ if(RessourceType.WOOD == ressource){ woodCargo += newToAdd; cargoStatus += newToAdd; return true; } if(RessourceType.STONE == ressource){ stoneCargo += newToAdd; cargoStatus += newToAdd; return true; } if(RessourceType.FOOD == ressource){ foodCargo += newToAdd; cargoStatus += newToAdd; return true; } } return false; }
bool ressourceConsumer_OnRessourceCreated(RessourceType type) { heartToGive--; if(heartToGive == 0) growthLevel--; return true; }
bool ressourceConsumer_OnRessourceConsumed(RessourceType type) { heartConsumed++; return true; }
public virtual void OnChangeCell(Cell cell, int x, int y) { //var dirs = new CellFlowDirection[] { CellFlowDirection.Right, CellFlowDirection.Up, CellFlowDirection.Left, CellFlowDirection.Down }; if (type == RessourceType.None) { foreach (var neighbourCell in worldGrid.getNeighbourCell(x, y)) { if (neighbourCell.type.ressourceType != RessourceType.None) { type = neighbourCell.type.ressourceType; break; } else if (neighbourCell.ressourceConsumer != null && neighbourCell.ressourceConsumer.createTypes != RessourceType.None) { type = neighbourCell.ressourceConsumer.Create(); break; } } } else if (type == RessourceType.Green) { int mudTypeIndex = worldGrid.getCellTypeIndexByName("Mud"); UnityEngine.Debug.Log("mudTypeIndex:" + mudTypeIndex); foreach (var neighbourCell in worldGrid.getNeighbourCell(x, y)) { UnityEngine.Debug.Log("neighbourCell.typeIndex:" + neighbourCell.typeIndex); UnityEngine.Debug.Log("neighbourCell.hasGrass:" + neighbourCell.hasGrass); if (neighbourCell.typeIndex == mudTypeIndex && !neighbourCell.hasGrass) ChangeMudToGrass(neighbourCell, x, y); } } if (type != RessourceType.None) { foreach (var neighbourCell in worldGrid.getNeighbourCell(x, y)) { if (neighbourCell.ressourceConsumer != null) { if (neighbourCell.ressourceConsumer.consumTypes != RessourceType.None && EnumHelper.Has(neighbourCell.ressourceConsumer.consumTypes, type)) { bool consumed = neighbourCell.ressourceConsumer.Consume(type); if (consumed) { type = RessourceType.None; break; } } } } } }
public bool Consume(RessourceType type) { if (OnRessourceConsumed != null) return OnRessourceConsumed(type); return true; }
public int GetValueOf(RessourceType pRessource) { int cargoInDB = 0; ressourceStorage.TryGetValue(pRessource, out cargoInDB); return cargoInDB; }
private void ChangeMudToGrass(Cell cell, int x, int y) { Debug.Log("ChangeMudToGrass"); //Spawn grass sprite cell.hasGrass = true; type = RessourceType.None; new Tree(worldGrid, cell, new Vector2(x, y+1)); }