void SpawnCube(Ore oreType) { Color cubeColor; switch (oreType) { case Ore.Silver: cubeColor = Color.white; break; case Ore.Gold: cubeColor = Color.yellow; break; default: cubeColor = Color.red; break; } cubePos = new Vector3(xPos, yPos, 0); myCube = Instantiate(cubePreFab, cubePos, Quaternion.identity); myCube.GetComponent <Renderer>().material.color = cubeColor; //change color myCube.GetComponent <CubeController>().myOre = oreType; //store cube type in cubeCont xPos += 2; if (xPos > 6) { xPos = -5; yPos = Random.Range(-5, 6); } recentOre = oreType; }
private void SpawnOre() { //Spawn with some of the position and speed randomized GameObject instanceOre = Instantiate( ore, transform.position + (0.8f * new Vector3(Random.value, Random.value, Random.value)), Quaternion.identity ); //Put in Ore tree instanceOre.transform.parent = control.generation.ores.transform; //Rigidbody Rigidbody instanceOreRb = instanceOre.GetComponent <Rigidbody>(); instanceOreRb.velocity = rb.velocity; instanceOreRb.angularVelocity = rb.angularVelocity; instanceOreRb.inertiaTensor = rb.inertiaTensor; instanceOreRb.inertiaTensorRotation = rb.inertiaTensorRotation; instanceOreRb.AddForce(1000f * new Vector3( 0.5f + (0.5f * Random.value), 0.5f + (0.5f * Random.value), 0.5f + (0.5f * Random.value) )); instanceOreRb.AddTorque(5000f * new Vector3(Random.value, Random.value, Random.value)); //Script Ore instanceOreScript = instanceOre.GetComponent <Ore>(); instanceOreScript.control = control; instanceOreScript.type = type; instanceOreScript.parentVelocity = rb.velocity; }
public override void _Process(float delta) { base._Process(delta); RectGlobalPosition = GetGlobalMousePosition() + new Vector2(10, 10); var orePos = new Vector2() { x = Mathf.FloorToInt(GetGlobalMousePosition().x / Globals.TileSize), y = Mathf.FloorToInt(GetGlobalMousePosition().y / Globals.TileSize) }; int oreId = OreTiles.GetCellv(orePos); if (oreId != -1) { Ore ore = (Ore)oreId; Text = ore.ToString(); } else { Text = ""; } }
private void SearchOres() { var ore = Pet.Range.Resources.Values.Where(x => x.Position != null && !Pet.GetOwner().Information.Cargo.Full).OrderBy(x => x.Position.DistanceTo(Pet.Position)) .FirstOrDefault(); var owner = Pet.GetOwner(); var autoLooterRange = 2000; switch (Level) { case 2: autoLooterRange = 2500; break; case 3: autoLooterRange = 3000; break; } if (ore != null && owner.Position.DistanceTo(ore.Position) < autoLooterRange) { LockedOre = ore; Pet.Controller.PathFollower.Stop(); MovementController.Move(Pet, new Vector(LockedOre.Position.X, LockedOre.Position.Y - 100)); } else { Fly(); } }
public int TakeOre(Ore ore, int quantity = 1) { int index = ores.FindIndex(x => x.ore == ore); if (index != -1) { if (ores[index].quantity == quantity) { ores.RemoveAt(index); } else if (ores[index].quantity < quantity) { quantity = ores[index].quantity; ores.RemoveAt(index); } else { ores[index].quantity -= quantity; } } else { quantity = 0; } spaceLeft += quantity; UpdateBag(); return(quantity); }
// Update is called once per frame protected override void Update() { base.Update(); float percentLeft = (float)amountLeft / (float)capacity; if (percentLeft < 0) { percentLeft = 0; } int numBlocksToShow = (int)(percentLeft * numBlocks); Ore[] blocks = GetComponentsInChildren <Ore>(); if (numBlocksToShow >= 0 && numBlocksToShow < blocks.Length) { Ore[] sortedBlocks = new Ore[blocks.Length]; // Sort the list from highest to lowest foreach (Ore ore in blocks) { sortedBlocks[blocks.Length - int.Parse(ore.name)] = ore; } for (int i = numBlocksToShow; i < sortedBlocks.Length; i++) { sortedBlocks[i].renderer.enabled = false; } CalculateBounds(); } }
public void AddOre(Ore ore, int quantity = 1) { if (ores == null) { ores = new List <OreInBag>(); } if (spaceLeft <= 0) // BAG IS FULL!! TODO: add info { return; } else if (spaceLeft < quantity) { quantity = spaceLeft; } int index = ores.FindIndex(x => x.ore == ore); if (index != -1) { ores[index].quantity += quantity; } else { OreInBag newOre = new OreInBag(); newOre.ore = ore; newOre.quantity = quantity; ores.Add(newOre); } spaceLeft -= quantity; UpdateBag(); }
private void ItemSelected(IMyTerminalBlock autopilot, List <MyTerminalControlListBoxItem> selected) { if (m_addingOres) { if (selected.Count == 0) { return; } Ore ore; if (!TryGetOre(selected[0], out ore)) { throw new Exception("Selected item not found in all ores. Selected item: " + selected[0].Text.ToString()); } m_activeOres.Add(ore); m_addingOres = false; autopilot.RebuildControls(); return; } if (selected.Count == 0) { m_selected = null; } else { TryGetOre(selected[0], out m_selected); } }
/// <summary> /// Returns how many ores actualy sold. /// </summary> public int SellOres(Ore ore, int quantity, int price) { int sold = playerBag.TakeOre(ore, quantity); Player.Instance.stats.Cash += price * sold; return(sold); }
// Update is called once per frame void GenerateOre() { Ore iron = new Ore(); iron.id = 1000; iron.name = "Iron Ore"; iron.type = "Ore"; iron.buy = 10; iron.sell = 3; iron.count = 0; iron.description = "A large chunk of iron and rock."; iron.maxFind = 5; iron.minSkill = 0.0f; iron.maxSkill = 10.0f; iron.oreColor = Color.gray; iron.rarity = 10; iron.skillUsed = Craftable.SkillUsed.Mining; iron.stackable = true; Ore copper = new Ore(); copper.id = 1001; copper.name = "Copper Ore"; copper.type = "Ore"; copper.buy = 10; copper.sell = 3; copper.count = 0; copper.description = "A large chunk of copper and rock."; copper.maxFind = 5; copper.minSkill = 9.0f; copper.maxSkill = 20.0f; copper.oreColor = Color.red; copper.rarity = 20; copper.skillUsed = Craftable.SkillUsed.Mining; copper.stackable = true; Ore bronze = new Ore(); bronze.id = 1002; bronze.name = "Bronze Ore"; bronze.type = "Ore"; bronze.buy = 10; bronze.sell = 3; bronze.count = 0; bronze.description = "A large chunk of bronze and rock."; bronze.maxFind = 5; bronze.minSkill = 19.0f; bronze.maxSkill = 30.0f; bronze.oreColor = Color.yellow; bronze.rarity = 40; bronze.skillUsed = Craftable.SkillUsed.Mining; bronze.stackable = true; //Add all ore types to oreList oreList.Add(iron); oreList.Add(copper); oreList.Add(bronze); //Call AddToDatabase() to place them all in the main game item database AddToDatabase(); }
//Spawns a cube in a specified color public void SpawnCube(Ore oreType) { Color cubeColor = Color.red; if (oreType == Ore.Bronze) { cubeColor = Color.red; bronze++; } else if (oreType == Ore.Silver) { cubeColor = Color.white; silver++; } else if (oreType == Ore.Gold) { cubeColor = Color.yellow; gold++; } position = new Vector3(xPos, yPos, 0); myCube = Instantiate(cubePrefab, position, Quaternion.identity); myCube.GetComponent <Renderer>().material.color = cubeColor; myCube.GetComponent <CubeController>().myOre = oreType; xPos += 2; lastCube = oreType; }
private void OnTriggerEnter2D(Collider2D collision) { //if (collision.name != "Player") //{ // Debug.Log("Trigger entered by " + collision.name); //} Ore targetOre = collision.gameObject.GetComponent <Ore>(); if (targetOre != null) { //Debug.Log("This is an [Ore] object."); if (targetOre.GetOreType() == boxType) { audioSource.PlayOneShot(oreHit, 0.4f); HeldOre++; if (HeldOre > Capacity) { Overflow = Mathf.Clamp(Overflow + 1, 0, 12); HeldOre = Capacity; } Destroy(collision.gameObject); //Debug.Log("We should have destroyed the Ore object."); } } }
private void InstantiateDropText(Ore dropedOre, int amount = 1) { Text createdText = CreateTextGameobject(); createdText.text = amount.ToString("+#;-#;0") + " " + dropedOre.Name; createdText.color = dropedOre.DropTextColor; }
/// <summary> /// Called when [mouse enter]. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void OnMouseEnter(object sender, EventArgs e) { Control ctrl = sender as Control; if (!toolTipInfo.Active && ctrl != null) { string tooltip = ""; if (ctrl is PictureBox && ctrl.Tag is Ore) { toolTipInfo.ToolTipTitle = "Ore"; Ore ore = (Ore)ctrl.Tag; tooltip = ore.Name; try { double netYield = Convert.ToDouble(textBoxNetYield.Text) / 100; tooltip += string.Format(Environment.NewLine + "Efficiency: {0}", ore.GetEfficiency(netYield)); } catch (FormatException) {} } else if (ctrl is PictureBox && ctrl.Tag is Mineral) { toolTipInfo.ToolTipTitle = "Mineral"; Mineral m = ctrl.Tag as Mineral; tooltip = m.Name + Environment.NewLine + "price: " + m.Price.ToString("F3"); } if (tooltip.Length > 0) { toolTipInfo.SetToolTip(ctrl, tooltip); } toolTipInfo.Active = true; } }
protected override void Update () { base.Update(); float percentLeft = (float)amountLeft / (float)capacity; if(percentLeft < 0) { percentLeft = 0; } int numBlocksToShow = (int)(percentLeft * numBlocks); Ore[] blocks = GetComponentsInChildren< Ore >(); if(numBlocksToShow >= 0 && numBlocksToShow < blocks.Length) { Ore[] sortedBlocks = new Ore[blocks.Length]; //sort the list from highest to lowest foreach(Ore ore in blocks) { sortedBlocks[blocks.Length - int.Parse(ore.name)] = ore; } for(int i = numBlocksToShow; i < sortedBlocks.Length; i++) { sortedBlocks[i].GetComponent<Renderer>().enabled = false; } CalculateBounds(); } }
void SpawCube(Ore ore) { Color cubeColor; if (ore == Ore.Bronze) { cubeColor = Color.red; } else if (ore == Ore.Silver) { cubeColor = Color.white; } else { cubeColor = Color.yellow; } var mycube = Instantiate(cubePrep, new Vector3(Random.Range(-6, 9), Random.Range(-4, 4)), Quaternion.identity); mycube.GetComponent <Renderer> ().material.color = cubeColor; mycube.GetComponent <Click> ().myOre = ore; }
static void Main(string[] args) { tabOres[0] = new Ore("Fer", 7, 9, 4, 3); tabOres[1] = new Ore("Cuivre", 4, 8, 8, 2); tabOres[2] = new Ore("Plomb", 1, 3, 7, 2); tabOres[3] = new Ore("Zinc", 2, 5, 3, 6); int menu = 0; bool continuer = true; while (continuer == true) { AfficherMenu(); menu = Convert.ToInt32(Console.ReadLine()); switch (menu) { case 1: ConnaitrePireResistance(); Console.ReadKey(); break; case 2: AfficherMoyenneCote(); Console.ReadKey(); break; case 3: AfficherPointFusionPlusGrandQue8(); Console.ReadKey(); break; case 4: CreateAlloy(); Console.ReadKey(); break; case 5: QuitterMenu(); continuer = false; break; default: Console.WriteLine("Cette option n'est pas valide"); break; } } }
static void Question2(Ore ore, Tile[,] tiles) { int x = 0; int y = 0; Console.WriteLine(x + ", " + y); }
private void DrawOre(Graphics g, Ore ore) { if (!Properties.Settings.Default.DrawOres) { return; } switch (ore.Type) { case Ore.OreType.PROMETIUM: g.DrawRectangle(new Pen(Config.prometium), new Rectangle(Scale(ore.Position.X), Scale(ore.Position.Y), 1, 1)); break; case Ore.OreType.ENDURIUM: g.DrawRectangle(new Pen(Config.endurium), new Rectangle(Scale(ore.Position.X), Scale(ore.Position.Y), 1, 1)); break; case Ore.OreType.TERBIUM: g.DrawRectangle(new Pen(Config.terbium), new Rectangle(Scale(ore.Position.X), Scale(ore.Position.Y), 1, 1)); break; case Ore.OreType.PALLADIUM: g.DrawRectangle(new Pen(Config.palladium), new Rectangle(Scale(ore.Position.X), Scale(ore.Position.Y), 1, 1)); break; } }
void CreateCube(Ore ore) { Color cubeColor; if (ore == Ore.Bronze) { cubeColor = Color.red; } else if (ore == Ore.Silver) { cubeColor = Color.white; } else { cubeColor = Color.yellow; } cubePosition = new Vector3(xPos, yPos, 0); myCube = Instantiate(cubePrefab, cubePosition, Quaternion.identity); myCube.GetComponent <Renderer>().material.color = cubeColor; myCube.GetComponent <CubeController>().myOre = ore; // i got these positions from the video and that helps create // more cubes on my screen xPos += 2; if (xPos > 6) { xPos = -5; yPos += 2; } recentOre = ore; }
/// <summary> /// Fills the ore list. /// </summary> private void FillOreList() { foreach (KeyValuePair <string, Ore> pair in OreList.DictOre) { comboBoxOre.Items.Add(pair.Value); } //Select ore from config Ore ore = OreList.Get(Config <Settings> .Instance.SelectedOre); if (ore != null) { for (int n = 0; n < comboBoxOre.Items.Count; n++) { if (comboBoxOre.Items[n] == ore) { comboBoxOre.SelectedIndex = n; } } } else { comboBoxOre.SelectedIndex = 0; } }
public void UpdateItemSlots(Ore oreToUpdate = null) { if (oreToUpdate != null) { int oreIndex = Items.IndexOfKey(oreToUpdate); int amount = Items.ElementAt(oreIndex).Value; _equipmentSlots[oreIndex].UpdateOre(amount); } else { for (int i = 0; i < Items.Count; ++i) //full update for filled slots { Ore ore = Items.ElementAt(i).Key; int amount = Items.ElementAt(i).Value; _equipmentSlots[i].AssignOre(ore, amount); } if (SellButton.isActiveAndEnabled) //sell button position update { SellButton.UpdatePosition(_equipmentSlots); } for (int i = Items.Count; i < _equipmentSlots.Count; ++i) //update for empty slots { if (_equipmentSlots[i].IsEmpty()) { break; } _equipmentSlots[i].ClearSlot(); } } }
/// <summary> /// Open resource radial dial for an ore, store resource /// </summary> /// <param name="ore">Ore selected</param> public void OpenOreMenu(Ore ore) { _energyCrystal = null; _ore = ore; _resourceText.text = "Ore"; DoUpdateChecks(); gameObject.SetActive(true); }
public void SetOre(Ore ore) { this.ore = ore; this.icon.sprite = oresSettings.ores.Find(x => x.oreType == ore).icon; oreNameText.text = oresSettings.ores.Find(x => x.oreType == ore).ore; Price = oreStore.GetPrice(ore); Quantity = oreStore.GetQuantity(ore); }
/// <summary> /// Open resource radial dial for an energy crystal, store resource /// </summary> /// <param name="crystal">Energy crystal selected</param> public void OpenEnergyCrystalMenu(EnergyCrystal energyCrystal) { _energyCrystal = energyCrystal; _ore = null; _resourceText.text = "Energy Crystal"; DoUpdateChecks(); gameObject.SetActive(true); }
public void addOre(GameObject ore) { Ore oreType = ore.GetComponent <Ore>(); string resource = oreType.twoLetterID; int quantity = oreType.quantity; addOre(resource, quantity); }
public void SetUp(Ore ore, int fillerIndex) { _ore = ore; _fillerIndex = fillerIndex; oreName.text = _ore.name; _slider.maxValue = SingleExtractedOresCounter.ores[_ore.index]; _inputField.text = "0"; }
public void Initialize(Ore ore, int maxAmount) { _oreToSell = ore; _oreName = transform.GetChild(0).Find("Name").gameObject.GetComponent <Text>(); _oreName.text = ore.Name; _maxAmount = maxAmount; _amountSlider = transform.GetChild(0).Find("Slider").gameObject.GetComponent <Slider>(); _amountSlider.maxValue = _maxAmount; }
public void SellAll() { foreach (OreType type in Submarine.GetComponent <Sub>().Inventory) { money += Ore.GetValue(type); } Submarine.GetComponent <Sub>().Inventory.Clear(); inventoryDisplay.UpdateOreList(Submarine.GetComponent <Sub>().Inventory); }
public IActionResult MoonResults() { Moon moons = new Moon(); Ore ore = new Ore(); string[] initDelimit = (string[])TempData["Scan"]; string currentMoon = ""; var tempMoon = new List <Ore>(); if (initDelimit == null) { return(Redirect("Error")); } //Break moons and their respective ores down into categories for (int i = 0; i < initDelimit.Length; i++) { if (initDelimit[i].Length > 0) { if (initDelimit[i].Contains("Moon")) { if (currentMoon.Equals("")) { Console.WriteLine("check"); initDelimit[i] = initDelimit[i].TrimEnd(); currentMoon = initDelimit[i]; moons.moonInfo.Add(currentMoon, new Ore()); } else { currentMoon = initDelimit[i]; moons.moonInfo.Add(currentMoon, new Ore()); } } else if (Char.IsLetter(initDelimit[i][0])) { moons.moonInfo[currentMoon].oreInfo.Add(initDelimit[i], initDelimit[i + 1]); } } else { return(Redirect("Error")); } } //Debugging foreach (KeyValuePair <string, Ore> moon in moons.moonInfo) { Console.WriteLine(moon.Key + ":"); foreach (KeyValuePair <string, string> ores in moon.Value.oreInfo) { Console.WriteLine(ores.Key + ", " + ores.Value); } } return(View(moons)); }
public void Dig() { // tile breaking animation // particles tileType = TileType.Hole; ore = Ore.Ground; RefreshTile(); }
void AddToDatabase() { for(int i = 0; i < oreList.Count; i++) { Ore tempOre = new Ore(); tempOre.id = oreList[i].id; tempOre.name = oreList[i].name; tempOre.type = oreList[i].type; tempOre.buy = oreList[i].buy; tempOre.sell = oreList[i].sell; tempOre.count = oreList[i].count; tempOre.description = oreList[i].description; tempOre.maxFind = oreList[i].maxFind; tempOre.maxSkill = oreList[i].maxSkill; tempOre.minSkill = oreList[i].minSkill; tempOre.oreColor = oreList[i].oreColor; tempOre.rarity = oreList[i].rarity; tempOre.skillUsed = oreList[i].skillUsed; tempOre.stackable = oreList[i].stackable; itemDatabase.database.Add(tempOre); } }