public ManagerBuilder WithInnovationLevel(int level, Ressource ressourceFrom, Ressource ressourceTo) { _innovation = level; _innovateFrom = ressourceFrom; _innovateTo = ressourceTo; return this; }
public Manager(string name, int bonus, bool dividends, int promotion, int optimisation, int innovation, Ressource innovationFrom, Ressource innovationTo) { Name = name; Bonus = bonus; Dividends = dividends; Promotion = promotion; Optimisation = optimisation; Innovation = innovation; InnovationFrom = innovationFrom; InnovationTo = innovationTo; }
public GameEventBuilder RessourceBonus(Ressource ressource, int i) { _actions.Add(new GameEventAction(goodwill => { //TODO }) { Name = $"RessourceBonus{ressource}Bonus{i}" }); return this; }
public GameEventBuilder PriceChange(Ressource ressource, int priceChange) { _actions.Add(new GameEventAction(goodwill => { var newPrice = goodwill.RessourcePrices[ressource] + priceChange; newPrice = (newPrice > goodwill.Config.MaxRessourcePrice) ? goodwill.Config.MaxRessourcePrice : newPrice; newPrice = (newPrice < goodwill.Config.MinRessourcePrice) ? goodwill.Config.MinRessourcePrice : newPrice; goodwill.RessourcePrices[ressource] = newPrice; }) { Name = $"Ressource{ressource}Price{priceChange}" }); return this; }
public static void DataBind(this ComboBox pComboBox, Type pEnum, Ressource pRessource, bool pSort) { pComboBox.DisplayMember = "Display"; pComboBox.ValueMember = "Value"; var list = (from item in Enum.GetNames(pEnum) select new { Display = MultiLanguageStrings.GetString(pRessource, item + ".Text") ?? item, Value = item }); if (pSort) list = list.OrderBy(item => item.Value); pComboBox.DataSource = list.ToList(); }
public void addResource(int number, Ressource.resType type) { this._stopped = false; if (this._gold == 0 && this._wood == 0) { switch (type) { case Ressource.resType.Gold: this._gold += number; break; case Ressource.resType.Wood: this._wood += number; break; default: break; } } this.nextPoint(); }
public Player() { party = new Party (this); ressource = new Ressource (); }
// Update is called once per frame void Update() { //Clear selection if right click if (Input.GetKeyDown(KeyCode.Mouse1) && !PauseMenu.IsGamePaused) { ClearSelection(); } //If left click if (Input.GetKeyDown(KeyCode.Mouse0) && !PauseMenu.IsGamePaused) { //Cancel click if mouse is hovering build panel if (buildManager.gameObject.activeSelf && buildManager.CheckHovering(Input.mousePosition)) { return; } //Hit init RaycastHit hit; Ray ray = camera.ScreenPointToRay(Input.mousePosition); //Camera ray casting if (Physics.Raycast(ray, out hit)) { //Disable the building panel buildManager.Hide(); //If tree was hit if (hit.transform.gameObject.tag == GameManager.Instance.treeTag) { //Get tree Tree tree = hit.transform.gameObject.GetComponentInParent <Tree>(); if (tree != null) { //Select tree selectedSource = tree.transform; UpdateSelectionEffect(selectedSource.position, radiusFactor * tree.Radius * new Vector3(1, 0, 1)); //If we are not trying to place root OR we are placing but from rootHandle if (!isPlacing || (isPlacing == true && placingFromTree == false)) { //Then we are placing from a tree isPlacing = true; placingFromTree = true; } } else { Debug.LogError("Hit object has no Tree component"); } } //If root handle was hit else if (hit.transform.gameObject.tag == GameManager.Instance.rootHandleTag) { //Get rootHandle RootHandle rootHandle = hit.transform.gameObject.GetComponentInParent <RootHandle>(); if (rootHandle != null) { //Update selected source and lastHandle selectedSource = rootHandle.transform; lastHandle = rootHandle; //Get connected tree Tree tree = lastHandle.sourceRoot.connectedTree; //Update selection sprite UpdateSelectionEffect(tree.transform.position, radiusFactor * tree.Radius * new Vector3(1, 0, 1)); //Enable build manager buildManager.Show(selectedSource.position, Input.mousePosition); //If we are not trying to place root then we are placing from a rootHandle if (!isPlacing) { isPlacing = true; placingFromTree = false; } } else { Debug.LogError("Hit object has no RootHandle component"); } } //If ground was hit else if (hit.transform.gameObject.tag == GameManager.Instance.groundTag || hit.transform.gameObject.tag == GameManager.Instance.sandGroundTag || hit.transform.gameObject.tag == GameManager.Instance.saltGroundTag || hit.transform.gameObject.tag == GameManager.Instance.ressourceTag || hit.transform.gameObject.tag == GameManager.Instance.rampTag) { //If we are trying to place root if (isPlacing) { bool pointInRange = false; //And if placing from tree if (placingFromTree) { //Get tree Tree tree = selectedSource.GetComponent <Tree>(); bool placementAuthorized = IsOnSameLevel(tree.transform.position, hit.point) || hit.transform.gameObject.tag == GameManager.Instance.ressourceTag || hit.transform.gameObject.tag == GameManager.Instance.rampTag; //Check if hit point is in tree range if (tree != null && tree.InRange(hit.point) && placementAuthorized) { //Place root and update connected tree Root root = Instantiate(rootPrefab, Vector3.zero, Quaternion.identity).GetComponent <Root>(); root.connectedTree = tree; pointInRange = true; if (hit.transform.gameObject.tag == GameManager.Instance.ressourceTag) { root.TraceRoot(selectedSource.position + rootOffset, hit.transform.position); Ressource ressource = hit.transform.GetComponent <Ressource>(); if (ressource != null) { GameManager.Instance.CollectRessource(ressource); } ClearSelection(); return; } else if (hit.transform.gameObject.tag == GameManager.Instance.rampTag) { Ramp ramp = hit.transform.GetComponent <Ramp>(); if (ramp != null) { Vector3 firstPos = ramp.GetPrimaryPoint(selectedSource.position); Vector3 secondPos = ramp.GetSecondaryPoint(selectedSource.position); root.TraceRoot(selectedSource.position + rootOffset, firstPos + rootOffset); root.ProlongateRoot(secondPos + rootOffset); CreateRootHandle(secondPos, root, false); } } else { root.TraceRoot(selectedSource.position + rootOffset, hit.point + rootOffset); CreateRootHandle(hit.point, root, false); } } } //If placing from root else if (lastHandle != null) { //Get root connected tree Tree tree = lastHandle.sourceRoot.connectedTree; bool placementAuthorized = IsOnSameLevel(lastHandle.transform.position, hit.point) || hit.transform.gameObject.tag == GameManager.Instance.ressourceTag || hit.transform.gameObject.tag == GameManager.Instance.rampTag; //If hit point in tree range if (tree.InRange(hit.point) && placementAuthorized) { pointInRange = true; if (hit.transform.gameObject.tag == GameManager.Instance.ressourceTag) { lastHandle.sourceRoot.ProlongateRoot(hit.transform.position); Ressource ressource = hit.transform.GetComponent <Ressource>(); if (ressource != null) { GameManager.Instance.CollectRessource(ressource); } Destroy(lastHandle.gameObject); ClearSelection(); return; } else if (hit.transform.gameObject.tag == GameManager.Instance.rampTag) { Ramp ramp = hit.transform.GetComponent <Ramp>(); if (ramp != null) { Vector3 firstPos = ramp.GetPrimaryPoint(lastHandle.transform.position); Vector3 secondPos = ramp.GetSecondaryPoint(lastHandle.transform.position); lastHandle.sourceRoot.ProlongateRoot(firstPos + rootOffset); lastHandle.sourceRoot.ProlongateRoot(secondPos + rootOffset); CreateRootHandle(secondPos, lastHandle.sourceRoot, true); } } else { //Then prolongate root and create handle lastHandle.sourceRoot.ProlongateRoot(hit.point + rootOffset); CreateRootHandle(hit.point, lastHandle.sourceRoot, true); } } AudioManager.instance.Play("GrowRoots"); } //If point in range if (pointInRange) { //Then we are placing from rootHandle placingFromTree = false; isPlacing = true; //Enable build panel buildManager.Show(selectedSource.position, Input.mousePosition); } } } } } }
public Building(int id, string name, int idCase, int width, int length, int pv, int idDistrict, int idPlayer, Ressource cost, bool destructable) { this.id = id; this.name = name; this.idCase = idCase; this.width = width; this.length = length; this.destructable = destructable; this.pv = pv; this.cost = cost; this.idDistrict = idDistrict; this.idPlayer = idPlayer; }
protected override void Update() { switch (state) { case WorkerState.Idle: if (Time.time > nextIdleMovementTime) { nextIdleMovementTime = Time.time + idleMovementInterval; Vector3 wanderPoint = UnityEngine.Random.insideUnitSphere * 4; wanderPoint.y = entity.transform.position.y; wanderPoint += entity.transform.forward * 4 + entity.transform.position; Vector3 basePosition = BuildingSystem.Instance.playersBaseLocation.position; //if he would stray off to far, bring him back to base if (Vector3.Distance(basePosition, wanderPoint) > maxDistanceToBaseForWander) { wanderPoint += (basePosition - wanderPoint) / 4; } movement.MoveTo(wanderPoint); } break; case WorkerState.Construction: switch (constructionState) { case ConstructionState.Idle: //if idle /first get nearest Building which needs construction, if there is no we just chill beside the base if (Time.time > nextScanTime) { nextScanTime = Time.time + scanInterval; if (BuildingSystem.Instance.AreThereBuildingsToConstruct()) { standingBesideBaseAndWaiting = false; BuildingInConstruction nearestBuildingToConstruct = null; float nearestDistance = Mathf.Infinity; foreach (BuildingInConstruction building in BuildingSystem.Instance.GetBuildingsWaitingForConstruction()) { float currentDistance = (building.transform.position - entity.transform.position).sqrMagnitude; if (currentDistance < nearestDistance) { nearestDistance = currentDistance; nearestBuildingToConstruct = building; } } assignedBuildingToBuild = nearestBuildingToConstruct; //we move to a position from where we can build, not to a position inside the building Vector3 targetPosition = nearestBuildingToConstruct.transform.position + (entity.transform.position - nearestBuildingToConstruct.transform.position).normalized * nearestBuildingToConstruct.width / 2; movement.MoveTo(targetPosition); constructionState = ConstructionState.MovingToBuilding; } else if (!standingBesideBaseAndWaiting) { Vector3 positonToMoveTo = UnityEngine.Random.insideUnitSphere * 8; positonToMoveTo += BuildingSystem.Instance.playersBaseLocation.position; standingBesideBaseAndWaiting = true; movement.MoveTo(positonToMoveTo); } } break; case ConstructionState.MovingToBuilding: if (Time.time > nextScanTime) { nextScanTime = Time.time + scanInterval; if (assignedBuildingToBuild != null) { if (Vector3.Distance(entity.transform.position, assignedBuildingToBuild.transform.position) < assignedBuildingToBuild.width + constructionRange) { movement.Stop(); constructionState = ConstructionState.Constructing; constructionTool.StartAnimation(); nextConstructionTime = Time.time + constructionInterval; } } else { constructionState = ConstructionState.Idle; } } break; case ConstructionState.Constructing: if (Time.time > nextConstructionTime) { //check if it istn completed yet if (assignedBuildingToBuild != null) { nextConstructionTime = Time.time + constructionInterval; assignedBuildingToBuild.Construct(constructionPoints); } else { constructionState = ConstructionState.Idle; constructionTool.StopAnimation(); } } break; } break; case WorkerState.Harvesting: switch (harvestingState) { case HarvestingState.Idle: //check if there are some ressources in the area - should it check with physics check or get the nearest from the ressourcesmanager? if (Time.time > nextScanTime) { nextScanTime = Time.time + scanInterval; HashSet <Ressource> ressources = RessourcesManager.Instance.GetRessources(assignedHarvesterType); if (ressources.Count > 0) { standingBesideHarvesterAndWaiting = false; Ressource nearestRessource = null; float nearestDistance = Mathf.Infinity; foreach (Ressource ressource in ressources) { float currentDistance = (ressource.transform.position - assignedHarvester.transform.position).sqrMagnitude; if (currentDistance < nearestDistance) { nearestDistance = currentDistance; nearestRessource = ressource; } } currentSelectedRessource = nearestRessource; Vector3 targetPosition = currentSelectedRessource.transform.position + (entity.transform.position - currentSelectedRessource.transform.position).normalized * currentSelectedRessource.width / 2; movement.MoveTo(targetPosition); harvestingState = HarvestingState.MovingToRessource; } else if (!standingBesideHarvesterAndWaiting) { Vector3 positonToMoveTo = UnityEngine.Random.insideUnitSphere * 5; positonToMoveTo += assignedHarvester.transform.position; standingBesideHarvesterAndWaiting = true; movement.MoveTo(positonToMoveTo); } } break; case HarvestingState.MovingToRessource: if (Time.time > nextScanTime) { nextScanTime = Time.time + scanInterval; if (currentSelectedRessource != null) { if (Vector3.Distance(entity.transform.position, currentSelectedRessource.transform.position) < currentSelectedRessource.width) { movement.Stop(); harvestingState = HarvestingState.GatheringRessource; //activate the tool if (assignedHarvesterType == RessourceType.fer) { ferHarvestingTool.StartAnimation(); } else if (assignedHarvesterType == RessourceType.mer) { merHarvestingTool.StartAnimation(); } nextRessourceGatheringTime = Time.time + ressourceGatherInterval; } } else { harvestingState = HarvestingState.Idle; ferHarvestingTool.StopAnimation(); merHarvestingTool.StopAnimation(); } } break; case HarvestingState.GatheringRessource: if (Time.time > nextRessourceGatheringTime) { //check if it istn completed yet if (currentSelectedRessource != null) { nextRessourceGatheringTime = Time.time + ressourceGatherInterval; //gather but check how much will fit if (ressourceInventory.currentRessourceTransportLoad + ressourceGatheringPower > ressourceInventory.ressourceTransportLoad) { ressourceInventory.AddRessource(currentSelectedRessource.type, currentSelectedRessource.TakeRessource(ressourceInventory.ressourceTransportLoad - ressourceInventory.currentRessourceTransportLoad)); } else { ressourceInventory.AddRessource(currentSelectedRessource.type, currentSelectedRessource.TakeRessource(ressourceGatheringPower)); } //if the sack is full, go back if (ressourceInventory.currentRessourceTransportLoad == ressourceInventory.ressourceTransportLoad) { Vector3 targetPosition = assignedHarvester.transform.position + (entity.transform.position - assignedHarvester.transform.position).normalized * assignedHarvester.width / 2; movement.MoveTo(targetPosition); // movement.MoveTo(assignedHarvester.transform.position); harvestingState = HarvestingState.TransportingRessourceToHarvester; ferHarvestingTool.StopAnimation(); merHarvestingTool.StopAnimation(); } } else { ferHarvestingTool.StopAnimation(); merHarvestingTool.StopAnimation(); if (ressourceInventory.currentRessourceTransportLoad > 0) { Vector3 targetPosition = assignedHarvester.transform.position + (entity.transform.position - assignedHarvester.transform.position).normalized * assignedHarvester.width / 2; movement.MoveTo(targetPosition); //movement.MoveTo(assignedHarvester.transform.position); harvestingState = HarvestingState.TransportingRessourceToHarvester; } else { harvestingState = HarvestingState.Idle; } } } break; case HarvestingState.TransportingRessourceToHarvester: if (Time.time > nextScanTime) { nextScanTime = Time.time + scanInterval; if (Vector3.Distance(entity.transform.position, assignedHarvester.transform.position) < assignedHarvester.width) { movement.Stop(); assignedHarvester.DepotRessource(ressourceInventory.currentRessourceTransportLoad); ressourceInventory.Clear(); if (currentSelectedRessource != null) { harvestingState = HarvestingState.MovingToRessource; movement.MoveTo(currentSelectedRessource.transform.position); } else { harvestingState = HarvestingState.Idle; } } } break; } break; case WorkerState.Depositing: if (Time.time > nextScanTime) { nextScanTime = Time.time + scanInterval; if (despositionBuilding != null) { if (Vector3.Distance(entity.transform.position, despositionBuilding.transform.position) < despositionBuilding.width) { despositionBuilding.GetComponent <IDepositioneable <B_Worker> >().DepositionWorker(this); } } else { AssignToIdle(); } } break; } }
public bool Import(JSONObject source) { // Recuperation du tableau de items ItemsList = new List <Item>(); JSONArray array = source["items"].Array; foreach (JSONValue value in array) { ItemElement invItem = new ItemElement(); foreach (KeyValuePair <string, JSONValue> itemEntry in value.Obj) { if (itemEntry.Key == "type") { switch (itemEntry.Value.Str) { case "Ressource": invItem.type = "Ressource"; break; case "Equipment": invItem.type = "Equipment"; break; default: invItem.type = "None"; break; } } Item item; switch (invItem.type) { case "Ressource": item = new Ressource(); item.Type = "Ressource"; invItem.type = "Ressource"; break; default: item = new Equipment(); item.Type = "Equipment"; invItem.type = "Equipment"; break; } if (itemEntry.Key == "item") { foreach (KeyValuePair <string, JSONValue> currentItem in itemEntry.Value.Obj) { if (currentItem.Key == "id") { item.Id = currentItem.Value.Str; } if (currentItem.Key == "itemName") { item.ItemName = currentItem.Value.Str; } if (currentItem.Key == "description") { item.Description = currentItem.Value.Str; } if (currentItem.Key == "inventorySprite") { item.InventorySprite = dictSprites[currentItem.Value.Str]; } if (currentItem.Key == "ingameVisual") { item.IngameVisual = Resources.Load(currentItem.Value.Str) as GameObject; } if (item.Type == "Equipment") { if (currentItem.Key == "slot") { if (!Enum.IsDefined(typeof(EquipmentSlot), currentItem.Value.Str)) { return(false); } ((Equipment)item).Constraint = (EquipmentSlot)Enum.Parse(typeof(EquipmentSlot), currentItem.Value.Str, true); } if (currentItem.Key == "stat") { if (!Enum.IsDefined(typeof(Stat), currentItem.Value.Str)) { return(false); } ((Equipment)item).Stat = (Stat)Enum.Parse(typeof(Stat), currentItem.Value.Str, true); } if (currentItem.Key == "bonusStat") { ((Equipment)item).BonusToStat = (short)currentItem.Value.Number; } } if (item.Type == "Ressource") { if (currentItem.Key == "use") { if (!Enum.IsDefined(typeof(ResourceFunctions), currentItem.Value.Str)) { return(false); } ((Ressource)item).ResourceUseIndex = (ResourceFunctions)Enum.Parse(typeof(ResourceFunctions), currentItem.Value.Str, true); } if (currentItem.Key == "value") { ((Ressource)item).Value = (int)currentItem.Value.Number; } } } } invItem.item = item; } ItemsList.Add(invItem.item); } return(true); }
public ActionResult Put(int id, [FromBody] Ressource Ressource) { Ressource.Id = id; _Ressources.Update(Ressource); return(Ok()); }
void Start() { ressource = (Ressource)FindObjectOfType(typeof(Ressource)) as Ressource; }
void add(string[] words) { int type = int.Parse(words[1], System.Globalization.CultureInfo.InvariantCulture); float nbx = float.Parse(words[2], System.Globalization.CultureInfo.InvariantCulture) + 1; float nbz = float.Parse(words[3], System.Globalization.CultureInfo.InvariantCulture) + 1; int j = 0; if (type == 0) { j = elem.Count; } while (j < elem.Count && (Mathf.Round(elem[j].transform.position.x) != nbx || Mathf.Round(elem[j].transform.position.z) != nbz || elem[j].GetComponent <Ressource>().type != type)) { j += 1; } if (j == elem.Count) { elem.Add(Instantiate(prefabs[type], new Vector3(nbx, 1.6f, nbz), Quaternion.identity) as GameObject); elem[elem.Count - 1].transform.parent = transform; if (type == 0) { elem[elem.Count - 1].name = words[4]; } else { elem[elem.Count - 1].name = words[4] + id; id += 1; } if (type == 0) { elem[elem.Count - 1].transform.localScale = new Vector3(0.2f, 0.2f, 0.2f); Move mv = elem[elem.Count - 1].AddComponent <Move>(); mv.dam = dam; Rigidbody body = elem[elem.Count - 1].AddComponent <Rigidbody>(); BoxCollider box = elem[elem.Count - 1].AddComponent <BoxCollider>(); body.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ; Vector3 vect = box.size; vect.y = 5; box.size = vect; /* elem[elem.Count - 1].AddComponent<Animation>(); * Animation anim = elem[elem.Count - 1].GetComponent<Animation>(); * AnimationClip clip = (AnimationClip)Resources.Load("Walk"); * anim.AddClip(clip, "Walk");*/ } else if (type == 1) { elem[elem.Count - 1].transform.localScale = new Vector3(0.05f, 0.05f, 0.05f); elem[elem.Count - 1].transform.position += new Vector3(0, -1, 0); } else if (type == 2) { elem[elem.Count - 1].transform.localScale = new Vector3(0.05f, 0.05f, 0.05f); elem[elem.Count - 1].transform.position += new Vector3(-0.2f, -1, 0); } else if (type == 3) { elem[elem.Count - 1].transform.localScale = new Vector3(0.05f, 0.05f, 0.05f); elem[elem.Count - 1].transform.position += new Vector3(0.2f, -1, 0); elem[elem.Count - 1].transform.Rotate(Vector3.right * 90); } else if (type == 4) { elem[elem.Count - 1].transform.localScale = new Vector3(0.01f, 0.01f, 0.01f); elem[elem.Count - 1].transform.position += new Vector3(-0.1f, -1, -0.2f); } else if (type == 5) { elem[elem.Count - 1].transform.localScale = new Vector3(0.01f, 0.01f, 0.01f); elem[elem.Count - 1].transform.position += new Vector3(0.1f, -1, -0.2f); } else if (type == 6) { elem[elem.Count - 1].transform.localScale = new Vector3(0.01f, 0.01f, 0.01f); elem[elem.Count - 1].transform.position += new Vector3(0.1f, -1, 0.2f); } else if (type == 7) { elem[elem.Count - 1].transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); elem[elem.Count - 1].transform.position += new Vector3(-0.1f, -1, 0.2f); } Ressource res = elem[elem.Count - 1].AddComponent <Ressource>(); res.type = type; /* if (type > 1) * { * j = 0; * while (j < dam.tiles.Count && (Mathf.Round() != Mathf.Round(dam.tiles[j].transform.position.x) || Mathf.Round(nbz) != Mathf.Round(dam.tiles[j].transform.position.z))) || { || Console.Write((Mathf.Round(dam.tiles[j].transform.position.x)).ToString() + " "); || Console.Write((Mathf.Round(dam.tiles[j].transform.position.z)).ToString()); || Console.WriteLine(); || j += 1; || } || j = (int)(nbz * size.x + nbx + 0.5f); || GameObject.Find("Main Camera").GetComponent<Cam>().dispText = (dam.tiles.Count).ToString(); || dam.tiles[j].GetComponent<Tile>().res[type - 2] += 1; || }*/ } else { elem[j].GetComponent <Ressource>().nb += 1; } }
public static void IniRessourceList() { for(int i = 0; i < RessourceList.Length; i++) { RessourceList[i] = new Ressource(); RessourceList[i].Name = ((RessourceName)i).ToString(); if(RessourceList[i].Name == "Coin") { RessourceList[i].CurValue = 5; RessourceList[i].MaxValue = 1000; } else if(RessourceList[i].Name == "Rock") { RessourceList[i].CurValue = 50; RessourceList[i].MaxValue = 1000; } else if(RessourceList[i].Name == "Wood") { RessourceList[i].CurValue = 100; RessourceList[i].MaxValue = 1000; } /*else if(RessourceList[i].Name == "Gold") { RessourceList[i].CurValue = 0; RessourceList[i].MaxValue = 1000; }*/ } }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { IdentityResult result; // Switch on Selected Account type switch (model.AccountType) { // Volunteer Account type selected: case MapDomain.Entities.UserType.Client: { // create new volunteer and map form values to the instance User v = new Client { UserType = "Client", UserName = model.Email, Email = model.Email }; result = await UserManager.CreateAsync(v, model.Password); // Add volunteer role to the new User if (result.Succeeded) { // UserManager.AddToRole(v.Id, EAccountType.Patient.ToString()); await SignInManager.SignInAsync(v, isPersistent : false, rememberBrowser : false); // Email confirmation here return(RedirectToAction("Index", "Home")); } AddErrors(result); } break; // Ngo Account type selected: case MapDomain.Entities.UserType.Resource: { // create new Ngo and map form values to the instance User res = new Ressource { UserType = "Resource", UserName = model.Email, Email = model.Email }; result = await UserManager.CreateAsync(res, model.Password); // Add Ngo role to the new User if (result.Succeeded) { // UserManager.AddToRole(ngo.Id, EAccountType.Doctor.ToString()); await SignInManager.SignInAsync(res, isPersistent : false, rememberBrowser : false); return(RedirectToAction("Index", "Home")); } // AddErrors(result); } break; /* * case MapDomain.Entities.UserType.Candidate: * { * // create new Ngo and map form values to the instance * User cd = new Candidate { UserName = model.Email, Email = model.Email }; * result = await UserManager.CreateAsync(cd, model.Password); * * // Add Ngo role to the new User * if (result.Succeeded) * { * // UserManager.AddToRole(ngo.Id, EAccountType.Doctor.ToString()); * await SignInManager.SignInAsync(cd, isPersistent: false, rememberBrowser: false); * * return RedirectToAction("Index", "Home"); * } * // AddErrors(result); * } * break;*/ } } // If we got this far, something failed, redisplay form return(View(model)); }
public string Save(string Name, Int64 ID, string jsonData, string Type = "") { string s = Ressource.Save(Name, ID, Type, jsonData); return(s); }
public bool SaveRessource(Ressource ressource) { return(resRep.SaveRessource(ressource)); }
private void GenererInventaireSlot(Tribu tribu) { NettoyerInventaire(); float[] gains = tribu.stockRessources.RessourcesEnStock.gains; //Génère slots de ressource for (int i = 0; i < gains.Length; i++) { Ressource ressource = ListeRessources.Defaut.listeDesRessources[i]; if (gains[i] >= 1 && !platoActuel.ressourcesEchangees.Contains(ressource.nom)) { GameObject nvSlot = Instantiate(slotRessourceBase, fond); listeSlots.Add(nvSlot); nvSlot.SetActive(true); foreach (Image image in nvSlot.GetComponentsInChildren <Image>()) { if (image.name == "Icone") { image.sprite = ListeIcones.Defaut.TrouverIconeRessource(ressource); } } nvSlot.GetComponentInChildren <TextMeshProUGUI>().text = "" + gains[i]; nvSlot.GetComponentInChildren <InfoBulle>().texteInfoBulle = ressource.texteInfobulle; Button nvBouton = nvSlot.GetComponentInChildren <Button>(); nvBouton.onClick.AddListener(() => platoActuel.AjouterSlotEchange(ressource)); nvBouton.onClick.AddListener(() => Destroy(nvSlot)); nvBouton.onClick.AddListener(CacherInventaire); } } List <Consommable> consommables = tribu.stockRessources.consommables; Dictionary <Consommable, int> inventaireConso = new Dictionary <Consommable, int>(); //Génère slots de consommables for (int i = 0; i < consommables.Count; i++) { if (inventaireConso.ContainsKey(consommables[i])) { inventaireConso[consommables[i]]++; } else { inventaireConso.Add(consommables[i], 1); } } foreach (Consommable consommable in inventaireConso.Keys) { if (!platoActuel.ressourcesEchangees.Contains(consommable.nom)) { GameObject nvSlot = Instantiate(slotRessourceBase, fond); listeSlots.Add(nvSlot); nvSlot.SetActive(true); foreach (Image image in nvSlot.GetComponentsInChildren <Image>()) { if (image.name == "Icone") { image.sprite = consommable.icone; } } nvSlot.GetComponentInChildren <TextMeshProUGUI>().text = "" + inventaireConso[consommable]; nvSlot.GetComponentInChildren <InfoBulle>().texteInfoBulle = consommable.TexteInfobulle; Button nvBouton = nvSlot.GetComponentInChildren <Button>(); nvBouton.onClick.AddListener(() => platoActuel.AjouterSlotEchange(consommable)); nvBouton.onClick.AddListener(() => Destroy(nvSlot)); nvBouton.onClick.AddListener(CacherInventaire); } } }
// Use this for initialization void Start() { ressource = (Ressource)FindObjectOfType(typeof(Ressource)) as Ressource; lifeBar = transform.FindChild("LifeBar").gameObject; }
protected void SetRessource <T>(Ressource <T> Source, T Value) { (Source ?? (Source = new Ressource <T>()) ).DefaultValue = Value; }
public Hospital(int id, string name, int idCase, int width, int length, int pv, int idDistrict, int idPlayer, Ressource cost, bool destructable) : base(id, name, idCase, width, length, pv, idDistrict, idPlayer, cost, destructable) { }
public ActionResult Post([FromBody] Ressource Ressource) { var createdRessource = _Ressources.Create(Ressource); return(Ok(createdRessource)); }
public void updateValue(bool isAmo) { Ressource res = db.Ressource.Include("Tarification_Ressource").Where(x => x.Initial == initials).FirstOrDefault(); // Recuperation de la personne correspondant aux initials Tarification tar = new Tarification(); // creation d'un nouvel objet Tarification if (res != null) // Si l'objet n'est pas null { List <long> typeId = res.Tarification_Ressource.Select(x => x.FK_Tarification).ToList(); // Récupération des id's correspondant à la personne pointé par les initals if (!res.isFullAMO()) // si la personne n'est pas Full Amo { tar = db.Tarification.Where(x => typeId.Contains(x.ID) && x.IsAmo == isAmo).FirstOrDefault(); // je récupère la tarification de la personne correspondant au bool Amo pris en param } //SI la personne n'as que des tarifs amo else { if (isAmo) { //Si la tache est typé amo alors on prend la valeur tarifaire la plus cher List <Tarification> lesTarifications = db.Tarification.Where(x => typeId.Contains(x.ID)).ToList(); // récuperation des differentes tarification correspondant a l'id de la personne if (lesTarifications.Count > 1) // si il y en a plus d'une { if (res.Niveau == 3) // si le niveau de cette personne est bac+3 { tar = lesTarifications.Select(s => s).OrderByDescending(s => s.Tar3).FirstOrDefault(); // je prend la tarification la plus chère correspondant au niveau bac+ 3 } else { tar = lesTarifications.Select(s => s).OrderByDescending(s => s.Tar5).FirstOrDefault(); // je prend la tarification la plus chère correspondant au niveau bac+ 5 } } else { tar = lesTarifications.FirstOrDefault(); } } else // Sinon si la tache n'est pas typé amo { List <Tarification> tars = db.Tarification.Where(x => typeId.Contains(x.ID)).ToList(); // je recupère les tartification correspondant à la personne if (tars.Count > 1) // si il y a plus d'ue tarification { if (res.Niveau == 3) // si niveaux personne => b + 3 { tar = tars.Select(s => s).OrderBy(s => s.Tar3).FirstOrDefault(); // première tarification ordonnée a partir de tarification de niveaux 3 } else // sinon si niveaux personne => b + 5 { tar = tars.Select(s => s).OrderBy(s => s.Tar5).FirstOrDefault(); // première tarification ordonnée a partir de tarification de niveaux 5 } } else // sinon { tar = tars.FirstOrDefault(); // je prend la seul qui est dispo } } } decimal dailyValue = this.value != null?Math.Round(Convert.ToDecimal(this.value / 7), 2) : 0; // conversion en jour decimal dailyValueWE = this.valueWE != null?Math.Round(Convert.ToDecimal(this.valueWE / 7), 2) : 0; // conversion en jour decimal dailyValueF = this.valueF != null?Math.Round(Convert.ToDecimal(this.valueF / 7), 2) : 0; // conversion en jour dailyValue = getDecimalPart(dailyValue); //Arrondie au supérieur dailyValueWE = getDecimalPart(dailyValueWE); //Arrondie au supérieur dailyValueF = getDecimalPart(dailyValueF); //Arrondie au supérieur this.value = Math.Round(dailyValue * (res.Niveau == 3 ? (decimal)tar.Tar3 : (decimal)tar.Tar5), 2); // je prend la valeur en fonction de son niveau if (this.valueWE != null) { this.valueWE = Math.Round(dailyValueWE * (res.Niveau == 3 ? (decimal)tar.Tar3 : (decimal)tar.Tar5), 2) * 1.5m; // si la personne a travailler le weekend j'applique le tarif weekend } else { this.valueWE = 0; // Tarif weekend = 0 } if (this.valueF != null) { this.valueF = Math.Round(dailyValueF * (res.Niveau == 3 ? (decimal)tar.Tar3 : (decimal)tar.Tar5), 2) * 2m; // si la personne a travailler un jour férié j'applique le tarif férié } else { this.valueF = 0; // Tarif férié = 0 } this.sum = Convert.ToDecimal(this.value + this.valueWE + this.valueF); //j'applique la somme de tout les tarifs pour la personne } }
public float RecupuererGainRessource(Ressource ressource) { return(RecupuererGainRessource(ressource.nom)); }
public static string GetString(Ressource pRessourceName, string pName) { ResourceManager rm = (ResourceManager) _ressourceManagers[pRessourceName]; if (rm == null) { rm = new ResourceManager("OpenCBS.MultiLanguageRessources.resx." + pRessourceName, typeof(MultiLanguageStrings).Assembly); _ressourceManagers.Add(pRessourceName, rm); } return rm.GetString(pName); }
protected T GetRessource <T>(Ressource <T> Source) { return(LocaleHelper.GetRessource <T>(Source)); }