/*public static void Buy(MiningMachine machine) * { * bool buy = false; * switch (machine.currCost) * { * case Currency.Hashes: * if (me.MinedHashes > machine.cost) * { * me.MinedHashes -= machine.cost + machine.cost / 2 * machine.qnt; * buy = true; * } * break; * * case Currency.BTC: * if (me.Bitcoins > machine.cost) * { * me.Bitcoins -= machine.cost + machine.cost / 2 * machine.qnt; * buy = true; * } * break; * * case Currency.Dollars: * if (me.Dollars > machine.cost) * { * me.Dollars -= machine.cost + machine.cost / 2 * machine.qnt; * buy = true; * } * break; * } * if (buy) * { * me.HashRate += machine.hashRate+machine.hashRate/3*machine.qnt; * machine.qnt++; * } * }*/ public static void Buy(Transistors t) { if (me.Bitcoins >= t.unitCost) { //int index = me.transGroups.IndexOf(t); me.Bitcoins -= t.unitCost; //int u = t.unitsAdquired; ++t.unitsAdquired; //Debug.Log("CurIndex: "+curIndex+"; Count: "+me.transGroups.Count); t.unitCost = FloatToBInt(t.baseCost, Mathf.Pow(1.15f, t.unitsAdquired)); if (!t.unlocked) { if (me.transGroups.IndexOf(t) < me.transGroups.Count - 2) { me.unblockedTrans.Add(me.transGroups[me.transGroups.IndexOf(t) + 1]); } t.unlocked = true; //++curIndex; } //t.updateConst(); //Debug.Log(t.myConst); } }
void OnGUI() { //Bloque de la derecha GUI.DrawTexture(new Rect(0, 0, BackgroundWidth, Screen.height), background); //Falling coins goes here GUI.DrawTexture(new Rect(LeftBlockWidth / 2 - stoneWidth / 2, Screen.height / 2 - stoneHeight / 2, stoneWidth, stoneHeight), stoneTex); animBtc.Draw(LeftBlockWidth / 2 - 32, Screen.height / 2 - 16); //Pieces of rocks goes here Color c = GUI.color; foreach (TextureFade t in texFade) { t.alpha -= Time.deltaTime / fadeTime; c.a = t.alpha; GUI.color = c; GUI.DrawTexture(t.pos, t.tex); } c.a = 1; GUI.color = c; //Debug... //if(GUI.Button(new Rect(5, 5, 100, 20), "Debug bought items!")) // foreach(Transistors t in transGroups) // Debug.Log("Transistor de "+ t.getSize() + ": x"+t.unitsAdquired); GUI.Box(new Rect(-5, 30 * (screenPerc - .2f), LeftBlockWidth + 10, 50), ""); GUI.Label(new Rect(0, 32.5f * (screenPerc - .2f), LeftBlockWidth, 50), "Hashes minadas: " + GetPrefix(l_MinedHashes), new GUIStyle("label") { fontSize = 20, fontStyle = FontStyle.Bold, alignment = TextAnchor.UpperCenter, padding = new RectOffset(-50, 0, 3, 3) }); //GUI.Label(new Rect(285 * (screenPerc + .07f), 22 * (screenPerc - .4f), 300, 50), GetPrefix(l_MinedHashes), new GUIStyle("label") { fontSize = 20, fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleLeft }); GUI.Label(new Rect(0, 35 * (screenPerc - .2f), LeftBlockWidth, 40), "por segundo: " + GetPrefix(HashRate + AccHashRate) + "/s", new GUIStyle("label") { fontSize = 12, alignment = TextAnchor.LowerCenter }); GUI.Box(new Rect(10, Screen.height - 30, 200, 25), GetPrefix(Bitcoins, UnitType.Inter, "{0} {1}BTCs")); //Left separator GUI.DrawTexture(new Rect(LeftBlockWidth, -2, separator1.width, separator1.height), separator1); //Right sepatator GUI.DrawTexture(new Rect(Screen.width - RightBlockWidth - separator1.width, -2, separator1.width, separator1.height), separator1); //Next feature: resize texture on click & mouse hand texture around the rock //Areas //Bloque central GUI.BeginGroup(new Rect(LeftBlockWidth + separator1.width, 0, CentralBlockWidth, Screen.height)); GUI.DrawTexture(new Rect(0, 0, BackgroundWidth, Screen.height), background); if (GUI.Button(new Rect(0, 0, 150 * screenPerc, 45), "Estadísticas")) { curMenu = Menu.Stats; } if (GUI.Button(new Rect(0, 55, 150 * screenPerc, 45), "Ajustes")) { curMenu = Menu.Settings; } if (GUI.Button(new Rect(BackgroundWidth - 150 * screenPerc - 34, 0, 150 * screenPerc, 45), "Info")) { curMenu = Menu.Menu; } GUI.BeginGroup(new Rect(0, 100 + separator2.height, BackgroundWidth, Screen.height - 100)); GUI.Box(new Rect(-1, -1, BackgroundWidth - 30, Screen.height - 100 - separator2.height + 5), ""); if (curMenu == Menu.Menu) { GUI.Label(new Rect(5, 5, BackgroundWidth - 44, Screen.height - 100 - separator2.height), "<size=" + Mathf.Round(20 * screenPerc + .1f) + "><b>¡Bienvenido a Bitcoin Mining Game!</b></size>\n\nEste juego trata de basarse en realidad, el minado de Bitcoins es algo que está hace no mucho estaba en auge, pero que poco a poco está decayendo debido a la relación coste/beneficios que es demasiado deficiente y seguirá siendo mayor a lo largo del tiempo.\nEl propósito de este juego es enseñar a todos los publicos como de compleja resuelta esta función. Aunque ahora mismo no tenga mucho contenido, en el futuro el juego intentará ser un fiel retrato a la realidad vigente, hasta entonces debéis aguardar. ;)\n\nHaz click sobre la roca de la derecha para conseguir tus primeras Hashes que te harán ganar unas cuantas microBitcoins las cuales te servirán para comprar tus primeros diez mil transistores que te otorgarán una capacidad de minado de 10 Hashes/segundo.\nPoco a poco ve consiguiendo más Bitcoins para ir pudiendo comprar transistores con un proceso de fabricación más eficiente.\n\nArriba tienes dos menús: Estadísticas y Ajustes.\n- Estadísticas: Te mostrará información detallada del proceso de minado.\n- Ajustes: Podrás cambiar la configuración del juego.\n\n<b>Nota:</b> Juega este juego en pantalla completa para disfrutar de una mejor experiencia.\n\nEl equipo de Lerp2Dev espera que tu experiencia jugando sea de tu agrado, en especial Ikillnukes. ;)\nUn saludo.", new GUIStyle("label") { richText = true, fontSize = Mathf.RoundToInt(13 * (screenPerc + .2f)) }); //\n\n<b>Nota:</b> Ni el coste de los transistores, ni el Hashrate del mismo es lineal, es decir, cada 5 items de transistor comprados el Hashrate y el coste cambian torno a una función exponencial. } else if (curMenu == Menu.Stats) //En el futuro poner un scroll... { GUI.Label(new Rect(5, 5, BackgroundWidth - 44, 25), "Estadísticas", new GUIStyle("label") { alignment = TextAnchor.MiddleCenter, fontSize = 24, fontStyle = FontStyle.Bold }); GUI.Label(new Rect(5, 30, BackgroundWidth - 44, 25), "General", new GUIStyle("label") { fontSize = 20 }); GUI.DrawTexture(new Rect(5, 55, BackgroundWidth - 44, 2), sep); GUI.Label(new Rect(5, 65, BackgroundWidth - 44, 20), "<b>Hashes minadas:</b> " + GetPrefix(l_MinedHashes), new GUIStyle("label") { richText = true }); GUI.Label(new Rect(5, 85, BackgroundWidth - 44, 20), "<b>Hashes/s:</b> " + GetPrefix(HashRate + AccHashRate) + "/s", new GUIStyle("label") { richText = true }); GUI.Label(new Rect(5, 105, BackgroundWidth - 44, 20), "<b>Hash minadas a clicks:</b> " + (clickedHashes) + " Hashes", new GUIStyle("label") { richText = true }); GUI.Label(new Rect(5, 125, BackgroundWidth - 44, 20), "<b>BTCs disponibles:</b> " + GetPrefix(Bitcoins, UnitType.Inter, "{0} {1}BTCs"), new GUIStyle("label") { richText = true }); GUI.Label(new Rect(5, 145, BackgroundWidth - 44, 20), "<b>BTCs totales:</b> " + GetPrefix(allBTCs, UnitType.Inter, "{0} {1}BTCs"), new GUIStyle("label") { richText = true }); GUI.Label(new Rect(5, 165, BackgroundWidth - 44, 20), "<b>BTCs gastadas:</b> " + (allBTCs - Bitcoins) + " BTCs", new GUIStyle("label") { richText = true }); GUI.Label(new Rect(5, 185, BackgroundWidth - 44, 20), "<b>BTCs/s:</b> " + GetPrefix(BTCRate, UnitType.Inter, "{0} {1}BTCs/s"), new GUIStyle("label") { richText = true }); GUI.Label(new Rect(5, 205, BackgroundWidth - 44, 20), "<b>BTCs/Hash (prob):</b> " + (l_MinedHashes > 0 ? (((float)BigInteger.ToUInt64(allBTCs) / (float)BigInteger.ToUInt64(l_MinedHashes)) * 100).ToString("F5") + " %" : "0 %"), new GUIStyle("label") { richText = true }); GUI.Label(new Rect(5, 245, BackgroundWidth - 44, 40), "<b>Tiempo jugado desde esta sesión:</b> " + GetTimeFormat(Time.timeSinceLevelLoad), new GUIStyle("label") { richText = true, wordWrap = screenPerc < 1 }); //GetPrefix(Bitcoins/MinedHashes, UnitType.Inter, "{0} {1}BTCs/Hash") } else if (curMenu == Menu.Settings) { GUI.Label(new Rect(5, 5, BackgroundWidth - 44, 25), "Ajustes", new GUIStyle("label") { alignment = TextAnchor.MiddleCenter, fontSize = 24, fontStyle = FontStyle.Bold }); GUI.Label(new Rect(5, 30, BackgroundWidth - 44, 25), "General", new GUIStyle("label") { fontSize = 20 }); GUI.DrawTexture(new Rect(5, 55, BackgroundWidth - 44, 2), sep); GUI.Label(new Rect(5, 60, BackgroundWidth - 44, 20), "Nivel de calidad [" + QualitySettings.names[s_quality] + "]:"); s_quality = (int)GUI.HorizontalSlider(sr_quality, s_quality, 0, QualitySettings.names.Length - 1); s_runInBack = GUI.Toggle(sr_runInBack, s_runInBack, " Seguir ejecutando en segundo plano"); if (GUI.Button(new Rect((BackgroundWidth - 44) / 2 - 75, 125, 150, 45), "Guardar cambios")) { QualitySettings.SetQualityLevel(s_quality, false); Application.runInBackground = s_runInBack; } } GUI.EndGroup(); GUI.EndGroup(); //Bloque central (separador) GUI.BeginGroup(new Rect(LeftBlockWidth + separator1.width - 1, 0, CentralBlockWidth + 2, Screen.height)); GUI.DrawTexture(new Rect(0, 100, separator2.width + 2, separator2.height), separator2); GUI.EndGroup(); //Bloque de la izquierda GUI.BeginGroup(new Rect(Screen.width - RightBlockWidth, 0, RightBlockWidth, Screen.height)); GUI.DrawTexture(new Rect(0, 0, BackgroundWidth, Screen.height), background); GUI.Label(new Rect(0, 0, RightBlockWidth, 20), "Tienda", new GUIStyle("label") { alignment = TextAnchor.UpperCenter }); GUI.Box(new Rect(0, 20, RightBlockWidth, 30), "Work in progress...", new GUIStyle("box") { alignment = TextAnchor.MiddleCenter }); Transistors.Draw(new Rect(0, 50 + separator3.height, RightBlockWidth - 10, itemTransHeight), unblockedTrans); GUI.EndGroup(); //Bloque de la izquierda (separador) GUI.BeginGroup(new Rect(Screen.width - RightBlockWidth - 1, 0, RightBlockWidth + 1, Screen.height)); GUI.DrawTexture(new Rect(0, 50, separator3.width + 1, separator3.height), separator3); GUI.EndGroup(); if (h_Elems != null && h_Elems.Count > 0) { foreach (HoveringElement h in h_Elems) { if (h.position.Contains(fixedMousePos) && curMenu == h.condition) { GUI.Box(new Rect(h.box.xMin + fixedMousePos.x, h.box.yMin + fixedMousePos.y, h.box.width, h.box.height), h.caption, new GUIStyle("box") { wordWrap = true }); } } } }