/// <summary> /// Almacena el numero de escudos que ha adquirido actualmente el usuario en las preferencias /// </summary> public void SaveEscudos() { Debug.Log(">>> GUARDAR ESCUDOS"); // almacenar los escudos string strEscudos = ""; for (int i = 0; i < EscudosManager.instance.GetNumEscudos(); ++i) { Escudo escudo = EscudosManager.instance.GetEscudo(i); if (escudo != null && escudo.numUnidades > 0) { // añadir el separador antes del id de la equipacion if (strEscudos != "") { strEscudos += separadores[0]; } strEscudos += escudo.id + separadoresIgual[0] + escudo.numUnidades; } } EncryptedPlayerPrefs.SetString("escudos", strEscudos); PlayerPrefs.Save(); }
// Update is called once per frame void Update() { if (GameManager.instance.Energy() >= 0) { if (Input.GetKeyDown(KeyCode.E) && GameManager.instance.Energy() >= gasto) { GameManager.instance.TakeEnergy(gasto); granada.enemy = "PLAYER"; Granada boom = Instantiate(granada, grenadePoint.position, Quaternion.Euler(new Vector3(0, 0, 0))); Rigidbody2D rb = boom.GetComponent <Rigidbody2D>(); if (player.flipX) { rb.velocity = new Vector2(-velGranada, velGranada); } else { rb.velocity = new Vector2(velGranada, velGranada); } } if (Input.GetKeyDown(KeyCode.Q) && !activatedShield && GameManager.instance.Energy() >= gasto) { GameManager.instance.TakeEnergy(gasto); Escudo nokiaShield = Instantiate(escudo, gameObject.transform.position, Quaternion.Euler(new Vector3(0, 0, 0))); activatedShield = true; Invoke("ActivateShield", nokiaShield.shieldLength); } } }
public void ComprobarEscudosConsumidos() { if (escudoEquipado.numUnidades <= 0) { escudoEquipado = m_EscudoPorDefecto; } }
// ******************** ESCUDOS ***************** private void agregarNuevoEscudo() { int y = eligeDondePonerEscudo(); if (y > 17) { Escudo nuevoEscudo = new Escudo(game.Cañon.X, y); nuevoEscudo.Hp = nivelEscudos; escudos.Add(nuevoEscudo); Image img = new Image(); img.Source = new BitmapImage(new Uri(@"/Tarea5;component/Shield.png", UriKind.Relative)); Jueguito.Children.Add(img); Grid.SetColumn(img, nuevoEscudo.X); Grid.SetRow(img, nuevoEscudo.Y); Grid.SetColumnSpan(img, 1); Grid.SetRowSpan(img, 1); img.Stretch = Stretch.Fill; EscudosToImgs.Add(nuevoEscudo, img); } }
/// <summary> /// Muestra la informacion asociada a un escudo /// </summary> /// <param name="_escudo"></param> public void ShowAsEscudo(Escudo _escudo) { ObtenerReferencias(); if (_escudo == null) { // ocultar este control SetVisible(false); } else { // mostrar este control SetVisible(true); // actualizar textos m_txtCantidad.text = _escudo.numUnidades.ToString(); m_txtCantidadSombra.text = m_txtCantidad.text; m_txtPrecio.text = "§ " + _escudo.precioHard.ToString(); m_txtPrecioSombra.text = m_txtPrecio.text; m_txtBoost.text = _escudo.boost.ToString("f1"); m_txtBoost.gameObject.SetActive(true); // textura del escudo Texture texturaEscudo; if (EscudosManager.escudoEquipado.boost == _escudo.boost) { texturaEscudo = AvataresManager.instance.GetTexturaEscudoTiendaEquipado(_escudo.idTextura); } else { texturaEscudo = AvataresManager.instance.GetTexturaEscudoTienda(_escudo.idTextura); } m_btnCompra.GetComponent <GUITexture>().texture = texturaEscudo; m_btnCompra.m_current = texturaEscudo; if (_escudo.faseDesbloqueo < Interfaz.ultimaMisionDesbloqueada) { // boton m_btnCompra.action = (_name) => { Interfaz.ClickFX(); AccionComprarEscudo(_escudo); }; } else { // boton m_btnCompra.action = (_name) => { Interfaz.ClickFX(); // mostrar el dialogo de compra / equipar escudo ifcDialogBox.instance.ShowOneButtonDialog( ifcDialogBox.OneButtonType.POSITIVE, LocalizacionManager.instance.GetTexto(78).ToUpper(), string.Format(LocalizacionManager.instance.GetTexto(79), "<color=#ddf108> " + (int)(_escudo.faseDesbloqueo + 1) + "</color>"), LocalizacionManager.instance.GetTexto(45).ToUpper()); }; } } }
void destruirEscudo(Escudo escudo) { Jueguito.Children.Remove(EscudosToImgs[escudo]); EscudosToImgs.Remove(escudo); escudos.Remove(escudo); }
//########################################################################## //######################## CONSTRUCTORES ############################ //########################################################################## //Constructor public EscudoGUI() { InitializeComponent(); escudo = new Escudo(8, 8); dgvEscudo.RowCount = 8; dgvEscudo.ColumnCount = 8; escudo.iniciarEscudo(dgvEscudo); comprobarDanio(); prBEscudo.Value = escudo.getSanos(); }
// ------------------------------------------------------------------------------ // --- CONSTRUCTOR ------------------------------------------------------------ // ------------------------------------------------------------------------------ public EscudosManager() { m_listaEscudos = new List <Escudo>(); // crear el escudo por defecto m_EscudoPorDefecto = new Escudo("", "", 0, 1.0f, 0, 0, "", int.MaxValue, false); // F4KE: generar la lista de escudos m_listaEscudos.Add(new Escudo("IT_SHIELD_01", LocalizacionManager.instance.GetTexto(139), 1, 1.5f, 12, 0, LocalizacionManager.instance.GetTexto(142), 0, false)); m_listaEscudos.Add(new Escudo("IT_SHIELD_02", LocalizacionManager.instance.GetTexto(140), 2, 1.8f, 18, 20, LocalizacionManager.instance.GetTexto(143), 0)); m_listaEscudos.Add(new Escudo("IT_SHIELD_03", LocalizacionManager.instance.GetTexto(141), 3, 2.0f, 20, 45, LocalizacionManager.instance.GetTexto(144), 0)); }
/// <summary> /// se utiliza para retornar el nombre la clase con una variable de texto /// </summary> /// <param name="NombreDelaclase">Nombre de la clase a la que sequiere retornar</param> /// <returns></returns> public BaseItem RetornarClase(string NombreDelaclase) { BaseItem AuxIten = null; switch (NombreDelaclase) { case "pocima": AuxIten = new pocima(); break; case "manzana": AuxIten = new manzana(); break; case "Espada": AuxIten = new Espada(); break; case "Escudo": AuxIten = new Escudo(); break; case "BullBox": AuxIten = new BullBox(); break; case "Botas": AuxIten = new Botas(); break; case "MoCura": AuxIten = new MoCura(); break; case "MoSurf": AuxIten = new MoSurf(); break; case "MoAtaElec": AuxIten = new MoAtaqueElectrico(); break; default: Debug.Log("Este iten no existe o esta mal escrito =" + NombreDelaclase); Debug.Break(); break; } return(AuxIten); }
void FixedUpdate() { if (IsRecover) { if (Amanus < AmanusTotal) { Amanus++; } else { IsRecover = false; } } if (Application.loadedLevel == 0) { Destroy(gameObject); } if (Application.loadedLevelName == "GameOver") { if (!Escudo.activeInHierarchy) { Escudo.SetActive(true); } } if (EstadoDoJogador != GameStates.CharacterState.DontMove) { if (Jump()) { return; } if (!IsInvoking("CheckRecoverAmanusAuto")) { Invoke("CheckRecoverAmanusAuto", 10f); } if (EstadoDoJogador != GameStates.CharacterState.Defense) { Attack(); } if (!attack) { Movement(); rgd.velocity = new Vector3(moveX * Speed, rgd.velocity.y, moveZ * Speed); moveX = Input.GetAxis("Horizontal"); moveZ = Input.GetAxis("Vertical"); } } }
private void btn_escudo_Click(object sender, EventArgs e) { if (Playerativo.Dinheiro < 50) { MessageBox.Show("Sem dinheiro"); } else { Escudo escudo = new Escudo(); Playerativo.Inventario.Direita = escudo; Status.AdicionarStatusItens(Playerativo, escudo); Playerativo.Dinheiro -= 50; lbl_dinheiro.Text = "R$" + Playerativo.Dinheiro + ",00"; btn_escudo.Enabled = false; } }
static void Main(string[] args) { try { ColleccionKeyBlade col = new ColleccionKeyBlade(); Arma arms = new Arma(); arms.Name = "Fenrir"; arms.Large = 90; arms.PointDamage = 25; arms.PointMagic = 1; arms.PointDef = 14; arms.Description = "This Arm Nullified Magic but Have much Damage Base"; arms.Type = TypeKeyBlade.Sword; arms.Elem = Element.Light; arms.calcularDano(); Escudo esc = new Escudo(); esc.Name = "Lotus Shield"; esc.Large = 60; esc.PointDamage = 10; esc.PointMagic = 6; esc.PointDef = 20; esc.Description = "This Shield Have a lot defense and estable attack"; esc.Type = TypeKeyBlade.Shield; esc.Eleme = Element.Fire; esc.calcularDano(); col.Add(arms); col.Add(esc); Console.WriteLine(col.Imprimir()); Console.ReadKey(); } catch (ArgumentException ex) { Console.WriteLine("Error " + ex.Message); } catch (Exception ex) { Console.WriteLine("Error " + ex.Message); } }
public void QuitarVida(float cantidad) { Escudo escudo = GetComponent <Escudo>(); if (!(escudo != null && escudo.enabled) && !(health <= 0)) { health -= cantidad; barraDeVida.SetActive(true); _barraDeVida.sizeDelta = new Vector2((maxBarraDeVida) * (health / maxHealth), _barraDeVida.sizeDelta.y); if (health <= 0) { sonidoDeMorir.Play(); Slime slime = GetComponent <Slime>(); if (slime != null) { slime.InstanciarSlimes(); } LevelManager levelmanager = LevelManager.GetInstance(); if (levelmanager != null) { if (levelmanager.TipoHabitacion() == 'P') { levelmanager.MatarEnemigo(this.gameObject); GetComponent <Enemy>().EstaMuerto(); } else { levelmanager.QuitarEnemigoSala(); } } if (slime == null) { animator.SetBool("muere", true); Invoke("Destruye", 0.5f); } else { Destroy(this.gameObject); } } } }
private void btnEscudo_Click(object sender, RoutedEventArgs e) { Escudo esc = new Escudo(); esc.Name = txtEscudoNombre.Text; esc.Large = int.Parse(txtLargoEsc.Text); esc.PointDamage = int.Parse(txtEscDan.Text); esc.PointMagic = int.Parse(txtEscMag.Text); esc.PointDef = int.Parse(txtEscDef.Text); esc.Description = txtDesEsc.Text; esc.Type = (TypeKeyBlade)cbxTipoArmEsc.SelectedItem; esc.Eleme = (Element)cbxElementEsc.SelectedItem; esc.calcularDano(); col.Add(esc); DGEscudo.ItemsSource = col.ListaEscudo(); }
private void equiparEscudo(GameObject escudo) { //aqui ficara o cogido resposanvel por equipar os itens //ao personagem if (this.escudoAtual != null) //caso ja tenha uma arma equipada ela sera destruida, para que outra a substitua { Escudo escudoAserTrocada = armaAtual.GetComponent("Escudo") as Escudo; escudoAserTrocada.removerBuffs();//retira os pontos extras trazidos por armas Destroy(armaAtual); } Vector3 posicao = this.posicaoEscudo.transform.position;//posicao da arma(precisa ser ajustada) //Coloca o player como portador da arma armaAtual = Instantiate(escudo, posicao, this.posicaoEscudo.transform.rotation) as GameObject;//instancia a arma na mao do player Escudo escudoNovo = this.escudoAtual.GetComponent("Escudo") as Escudo; escudoNovo.portador = player; this.escudoAtual.transform.parent = this.posicaoEscudo.transform;//transforma a arma em "filha" do player(assim ela se movera junto com ele) this.escudoAtual.transform.localPosition = new Vector3(0, 0, 0); this.escudoAtual.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); }
/// <summary> /// Muestra la informacion asociada a un escudo /// </summary> /// <param name="_escudo"></param> /// <param name="_onCloseCallback"></param> public void ShowEscudoDesbloqueado(Escudo _escudo, btnButton.guiAction _onCloseCallback = null) { // obtener las referencias a los elementos de esta interfaz GetReferencias(); // textura del boton m_imgEscudo.texture = AvataresManager.instance.GetTexturasEscudosDesbloqueados(_escudo.idTextura); ShowImagen(m_imgEscudo); // textos m_txtTitulo.text = LocalizacionManager.instance.GetTexto(254).ToUpper(); m_txtTituloSombra.text = m_txtTitulo.text; m_txtTexto.text = string.Format(LocalizacionManager.instance.GetTexto(255), "<color=#ddf108>" + LocalizacionManager.instance.GetTexto(257) + "</color>"); m_txtEscudoBoost.text = _escudo.boost.ToString("f1"); // boton cancelar => ocultarlo m_btnCancelar.gameObject.SetActive(false); // mostrar este dialogo transform.gameObject.SetActive(true); MostrarDialogoConSuperTweener(_onCloseCallback); }
//Verifica se o item é repetido(com o mesmo nome e status) e caso seja adiciona ao inventario //como um incremento na quantidade atual de itens private bool addItemRepetido(GameObject itemAtual, GameObject itemAdicionado) { bool resultado = false; if (itemAtual.name == itemAdicionado.name) { if (itemAtual.tag == "arma") { Arma armaAtual = itemAtual.GetComponent("Arma") as Arma; Arma armaAserAdd = itemAdicionado.GetComponent("Arma") as Arma; if (armaAtual.status.ehIgual(armaAserAdd.status)) { armaAtual.setQuantidade(armaAtual.getQuantidade() + 1); resultado = true; } } else if (itemAtual.tag == "escudo") { Escudo escudoAtual = itemAtual.GetComponent("Escudo") as Escudo; Escudo escudoAserAdd = itemAdicionado.GetComponent("Escudo") as Escudo; if (escudoAtual.status.ehIgual(escudoAserAdd.status)) { escudoAtual.setQuantidade(escudoAserAdd.getQuantidade() + 1); resultado = true; } } else if (itemAtual.tag == "pocao") { Pocao pocaoAtual = itemAtual.GetComponent("Pocao") as Pocao; Pocao pocaoAserAdd = itemAdicionado.GetComponent("Pocao") as Pocao; if (pocaoAtual.status.ehIgual(pocaoAserAdd.status)) { pocaoAtual.setQuantidade(pocaoAtual.getQuantidade() + 1); resultado = true; } } } return(resultado); }
/// <summary> /// se utiliza para retornar el nombre la clase con una variable de texto /// </summary> /// <param name="NombreDelaclase">Nombre de la clase a la que sequiere retornar</param> /// <returns></returns> public static BaseItem EncontrarItem(string NombreDelaclase) { BaseItem AuxIten = null; switch (NombreDelaclase) { case "pocima": AuxIten = new pocima(); break; case "manzana": AuxIten = new manzana(); break; case "Espada": AuxIten = new Espada(); break; case "Escudo": AuxIten = new Escudo(); break; case "BullBox": AuxIten = new BullBox(); break; case "Botas": AuxIten = new Botas(); break; default: Debug.Log("Este iten no existe o esta mal escrito =" + NombreDelaclase); Debug.Break(); break; } return(AuxIten); }
public void NewElement(string elementalAtack) { MonoBehaviour element_state = GetComponent(elementalAtack.Split('_')[1]) as MonoBehaviour; Escudo escudo = GetComponent <Escudo>(); if (escudo != null && escudo.enabled) { GetComponentInChildren <Charco>().NoPuedeMojarse(); escudo.AtaqueEscudo(elementalAtack.Split('_')[0]); } else if (currentState == null) { currentState = element_state; element_state.enabled = true; Invoke("StateTimeOut", stateTime); } else if (currentState == element_state) { CancelInvoke("StateTimeOut"); Invoke("StateTimeOut", stateTime); } else if (currentState != element_state) { CancelInvoke("StateTimeOut"); currentState.enabled = false; string element = elementalAtack.Split('_')[0]; Charco pies; if (element == "Fuego") { if (currentState == GetComponent <Mojado>()) { pies = GetComponentInChildren <Charco>(); if (pies != null) { pies.NoPuedeMojarse(); } GetComponent <ElementalReactions>().VapolizadoDebil(); } else { GetComponent <ElementalReactions>().Sobrecargado(); } } else if (element == "Agua") { if (currentState == GetComponent <Quemado>()) { GetComponent <ElementalReactions>().VapolizadoFuerte(); } else { GetComponent <Paralizar>().Paraliza(); GetComponent <ElementalReactions>().Electrocargado(); } } else { GetComponent <Paralizar>().Paraliza(); if (currentState == GetComponent <Quemado>()) { GetComponent <ElementalReactions>().Sobrecargado(); } else { pies = GetComponentInChildren <Charco>(); if (pies != null) { pies.NoPuedeMojarse(); } GetComponent <ElementalReactions>().Electrocargado(); } } currentState = null; } }
// ------------------------------------------------------------------------------ // --- METODOS ---------------------------------------------------------------- // ------------------------------------------------------------------------------ /// <summary> /// Carga la informacion almacenada en la preferencias del juego (si no se ha cargado ya antes) /// </summary> /// <param name="_forzarCarga">Fuerza la carga de las preferencias aunque ya se haya realizado antes</param> public void LoadAllData(bool _forzarCarga = false) { if (_forzarCarga || !m_cargaDatosRealizada) { Debug.LogWarning(">>> Recupero informacion de las preferencias"); // comprobar si existen las claves asociadas a los logros (es caso de que no crearlas) if (!EncryptedPlayerPrefs.HasKey("logrosLanzador")) { CreateListaLogrosPlayerPrefs(LogrosManager.logrosLanzador, "logrosLanzador"); PlayerPrefs.Save(); } if (!EncryptedPlayerPrefs.HasKey("logrosPortero")) { CreateListaLogrosPlayerPrefs(LogrosManager.logrosPortero, "logrosPortero"); PlayerPrefs.Save(); } if (!EncryptedPlayerPrefs.HasKey("logrosDuelo")) { CreateListaLogrosPlayerPrefs(LogrosManager.logrosDuelo, "logrosDuelo"); PlayerPrefs.Save(); } // obtener el dinero del juego y actualizar el dinero en la barra superior Interfaz.SetMonedaSoft_SinPersistencia(EncryptedPlayerPrefs.HasKey("softCurrency") ? EncryptedPlayerPrefs.GetInt("softCurrency") : 0); Interfaz.SetMonedaHard_SinPersistencia(EncryptedPlayerPrefs.GetInt("hardCurrency", 0)); cntBarraSuperior.instance.ActualizarDinero(); // obtener las mejores puntuaciones //Player.record_keeper = (PlayerPrefs.HasKey("goalkeeperRecord")) ? PlayerPrefs.GetInt("goalkeeperRecord") : 0; //Player.record_thrower = (PlayerPrefs.HasKey("shooterRecord")) ? PlayerPrefs.GetInt("shooterRecord") : 0; Interfaz.m_uname = EncryptedPlayerPrefs.GetString("alias", ""); // obtener el tiempo de juego Interfaz.m_nextTryTime = (EncryptedPlayerPrefs.HasKey("nextTryTime")) ? EncryptedPlayerPrefs.GetInt("nextTryTime") : 0; // obtener el avance como portero Interfaz.m_asKeeper.record = EncryptedPlayerPrefs.GetInt("goalkeeperRecord", 0); Interfaz.m_asKeeper.targets = EncryptedPlayerPrefs.GetInt("goalkeeperTargets", 0); Interfaz.m_asKeeper.goals = EncryptedPlayerPrefs.GetInt("goalkeeperGoals", 0); Interfaz.m_asKeeper.goalsStopped = EncryptedPlayerPrefs.GetInt("goalkeeperGoalsStopped", 0); Interfaz.m_asKeeper.throwOut = EncryptedPlayerPrefs.GetInt("goalkeeperThrowOut", 0); Interfaz.m_asKeeper.totalPoints = EncryptedPlayerPrefs.GetInt("goalkeeperTotalPoints", 0); Interfaz.m_asKeeper.deflected = EncryptedPlayerPrefs.GetInt("goalkeeperDeflected", 0); Interfaz.m_asKeeper.perfects = EncryptedPlayerPrefs.GetInt("goalkeeperPerfects", 0); // obtener el avance como lanzador Interfaz.m_asThrower.record = EncryptedPlayerPrefs.GetInt("shooterRecord", 0); Interfaz.m_asThrower.targets = EncryptedPlayerPrefs.GetInt("shooterTargets", 0); Interfaz.m_asThrower.goals = EncryptedPlayerPrefs.GetInt("shooterGoals", 0); Interfaz.m_asThrower.goalsStopped = EncryptedPlayerPrefs.GetInt("shooterGoalsStopped", 0); Interfaz.m_asThrower.throwOut = EncryptedPlayerPrefs.GetInt("shooterThrowOut", 0); Interfaz.m_asThrower.totalPoints = EncryptedPlayerPrefs.GetInt("shooterTotalPoints", 0); Interfaz.m_asThrower.deflected = EncryptedPlayerPrefs.GetInt("shooterDeflected", 0); Interfaz.m_asThrower.perfects = EncryptedPlayerPrefs.GetInt("shooterPerfects", 0); // obtener el avance en duelos Interfaz.m_duelsPlayed = EncryptedPlayerPrefs.GetInt("duelsPlayed", 0); Interfaz.m_duelsWon = EncryptedPlayerPrefs.GetInt("duelsWon", 0); Interfaz.m_perfectDuels = EncryptedPlayerPrefs.GetInt("perfectDuels", 0); // obtener la ultima mision desbloqueada Interfaz.ultimaMisionDesbloqueada = EncryptedPlayerPrefs.GetInt("ultimaMisionDesbloqueada", 0); // actualizar el estado de desbloqueo de los escudos en funcion de la ultima fase desbloqueada EscudosManager.instance.ActualizarEstadoDesbloqueoEscudos(Interfaz.ultimaMisionDesbloqueada); // obtener los lanzadores comprados if (PlayerPrefs.HasKey("shootersComprados")) { string strShootersComprados = EncryptedPlayerPrefs.GetString("shootersComprados"); if (strShootersComprados != null) { string[] shootersComprados = strShootersComprados.Split(separadores); if (shootersComprados != null) { for (int i = 0; i < shootersComprados.Length; ++i) { Jugador jugador = InfoJugadores.instance.GetJugador(shootersComprados[i]); if (jugador != null) { jugador.estado = Jugador.Estado.ADQUIRIDO; } } } } } // obtener los porteros comprados if (PlayerPrefs.HasKey("goalkeepersComprados")) { string strGoalkeepersComprados = EncryptedPlayerPrefs.GetString("goalkeepersComprados"); if (strGoalkeepersComprados != null) { string[] goalkeepersComprados = strGoalkeepersComprados.Split(separadores); if (goalkeepersComprados != null) { for (int i = 0; i < goalkeepersComprados.Length; ++i) { Jugador jugador = InfoJugadores.instance.GetJugador(goalkeepersComprados[i]); if (jugador != null) { jugador.estado = Jugador.Estado.ADQUIRIDO; Debug.LogWarning(">>> El jugador " + jugador.nombre + " pasa a estar ADQUIRIDO"); } } } } } // obtener equipaciones de lanzador compradas if (PlayerPrefs.HasKey("shooterEquipaciones")) { string strEquipacionesLanzador = EncryptedPlayerPrefs.GetString("shooterEquipaciones"); if (strEquipacionesLanzador != null) { string[] equipacionesLanzador = strEquipacionesLanzador.Split(separadores); if (equipacionesLanzador != null) { for (int i = 0; i < equipacionesLanzador.Length; ++i) { Equipacion equipacion = EquipacionManager.instance.GetEquipacion(equipacionesLanzador[i]); if (equipacion != null) { equipacion.estado = Equipacion.Estado.ADQUIRIDA; } } } } } // obtener equipaciones de portero compradas if (PlayerPrefs.HasKey("goalkeeperEquipaciones")) { string strEquipacionesPortero = EncryptedPlayerPrefs.GetString("goalkeeperEquipaciones"); if (strEquipacionesPortero != null) { string[] equipacionesPortero = strEquipacionesPortero.Split(separadores); if (equipacionesPortero != null) { for (int i = 0; i < equipacionesPortero.Length; ++i) { Equipacion equipacion = EquipacionManager.instance.GetEquipacion(equipacionesPortero[i]); if (equipacion != null) { equipacion.estado = Equipacion.Estado.ADQUIRIDA; } } } } } // obtener los powerups de lanzador comprados if (PlayerPrefs.HasKey("pwrUpsLanzador")) { string strPowerUpsLanzador = EncryptedPlayerPrefs.GetString("pwrUpsLanzador"); if (strPowerUpsLanzador != null) { string[] powerUps = strPowerUpsLanzador.Split(separadores); if (powerUps != null) { for (int i = 0; i < powerUps.Length; ++i) { string[] infoPowerUp = powerUps[i].Split(separadoresIgual); if (infoPowerUp != null && infoPowerUp.Length == 2) { PowerupService.ownInventory.SetCantidadPowerUp(infoPowerUp[0], int.Parse(infoPowerUp[1])); } } } } } // obtener los powerups de portero comprados if (PlayerPrefs.HasKey("pwrUpsPortero")) { string strPowerUpsPortero = EncryptedPlayerPrefs.GetString("pwrUpsPortero"); if (strPowerUpsPortero != null) { string[] powerUps = strPowerUpsPortero.Split(separadores); if (powerUps != null) { for (int i = 0; i < powerUps.Length; ++i) { string[] infoPowerUp = powerUps[i].Split(separadoresIgual); if (infoPowerUp != null && infoPowerUp.Length == 2) { PowerupService.ownInventory.SetCantidadPowerUp(infoPowerUp[0], int.Parse(infoPowerUp[1])); } } } } } // obtener los escudos comprados if (PlayerPrefs.HasKey("escudos")) { string strEscudos = EncryptedPlayerPrefs.GetString("escudos"); if (strEscudos != null) { string[] escudos = strEscudos.Split(separadores); if (escudos != null) { for (int i = 0; i < escudos.Length; ++i) { string[] infoEscudo = escudos[i].Split(separadoresIgual); if (infoEscudo != null && infoEscudo.Length == 2) { Escudo escudo = EscudosManager.instance.GetEscudo(infoEscudo[0]); if (escudo != null) { escudo.numUnidades = int.Parse(infoEscudo[1]); } } } } } } // fuerza a que si los jugadores y equipaciones seleccionadas actualmente no estan ADQUIRIDOS, sean substidos por unos que si ifcVestuario.instance.ComprobarJugadoresYEquipacionesAdquiridos(true); // cargar el avance del jugador CargarObjetivosMision(); // actualizar el estado de los jugadores InfoJugadores.instance.RefreshJugadoresDesbloqueados(Interfaz.ultimaMisionDesbloqueada); EquipacionManager.instance.RefreshEquipacionesDesbloqueadas(Interfaz.ultimaMisionDesbloqueada); // indicar que la carga de datos ya se ha realizado una vez m_cargaDatosRealizada = true; } // comprobar si existen logros que aun no han sido registrados int recompensaPendiente = 0; List <string> idsLogros = new List <string>(); if (PersistenciaManager.instance.CheckHayLogrosSinRecompensar(ref recompensaPendiente, ref idsLogros)) { // mostrar en la barra de opciones una "exclamacion" if (cntBarraSuperior.instance != null) { cntBarraSuperior.instance.MostrarQueHayNuevosLogros(); } // actualizar el dinero Interfaz.MonedasHard += recompensaPendiente; // actualizar el progreso de los logros para que esta alerta no se dispare mas SaveLogros(); // crear los dialogos para mostrar cada uno de los logros desbloqueados for (int i = 0; i < idsLogros.Count; ++i) { DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.LOGRO_DESBLOQUEADO, idsLogros[i])); } } }
// Use this for initialization void Start() { Escudo.S = this; this.nivel = 1; }
void AccionComprarEscudo(Escudo _escudo) { // comprobar como debe funcionar el boton "equipar/desequipar" btnButton.guiAction onEquiparCallback; bool equipar = _escudo.boost != EscudosManager.escudoEquipado.boost; if (equipar) { // el boton funciona como equipar onEquiparCallback = (_name) => { GeneralSounds_menu.instance.playOneShot(GeneralSounds_menu.instance.equiparEscudoClip); EscudosManager.escudoEquipado = _escudo; ifcVestuario.instance.RefreshMultiplicadorPuntuacion(); ifcVestuario.instance.RefreshInfo(); // <= refrescar el estado de los escudos }; } else { // el boton funciona como desequipar onEquiparCallback = (_name) => { GeneralSounds_menu.instance.playOneShot(GeneralSounds_menu.instance.desequiparEscudoClip); EscudosManager.escudoEquipado = EscudosManager.instance.escudoPorDefecto; // <= al desequipar asigno el escudo por defecto ifcVestuario.instance.RefreshMultiplicadorPuntuacion(); ifcVestuario.instance.RefreshInfo(); // <= refrescar el estado de los escudos }; } if (_escudo.numUnidades == 0) { // mostrar el dialogo de compra / equipar escudo ifcDialogBox.instance.ShowOneButtonDialog( ifcDialogBox.OneButtonType.BITOONS, string.Format(LocalizacionManager.instance.GetTexto(80).ToUpper(), _escudo.nombre.ToUpper()), _escudo._descripcion + " " + string.Format(LocalizacionManager.instance.GetTexto(81), "<color=#ddf108> " + _escudo.numUnidades + "</color>", _escudo.nombre, (_escudo.numUnidades == 1) ? LocalizacionManager.instance.GetTexto(136) : LocalizacionManager.instance.GetTexto(145)), _escudo.precioHard.ToString(), // callback para la compra de escudo (_name) => { // para que el usuario no se pase comprando if (_escudo.numUnidades >= 99) { ifcDialogBox.instance.ShowOneButtonDialog( ifcDialogBox.OneButtonType.POSITIVE, LocalizacionManager.instance.GetTexto(84).ToUpper(), string.Format(LocalizacionManager.instance.GetTexto(85), "<color=#ddf108> " + _escudo.nombre + "</color>"), LocalizacionManager.instance.GetTexto(45).ToUpper()); return; } // comprobar que el usuario tenga suficiente dinero para la compra if (Interfaz.MonedasHard < _escudo.precioHard) { ifcDialogBox.instance.ShowOneButtonDialog( ifcDialogBox.OneButtonType.POSITIVE, LocalizacionManager.instance.GetTexto(84).ToUpper(), string.Format(LocalizacionManager.instance.GetTexto(86), "<color=#ddf108> " + LocalizacionManager.instance.GetTexto(47) + "</color>"), LocalizacionManager.instance.GetTexto(45).ToUpper()); return; } // pagar el escudo y actualizar el dinero mostrado Interfaz.MonedasHard -= _escudo.precioHard; cntBarraSuperior.instance.ActualizarDinero(); GeneralSounds_menu.instance.comprar(); // incrementar la cantidad de escudos y repintar la tienda ++_escudo.numUnidades; if (ifcVestuario.instance != null) { ifcVestuario.instance.RefreshInfo(); } // persistir la cantidad de escudos PersistenciaManager.instance.SaveEscudos(); ShowAsEscudo(_escudo); // volver a la compra de escudos AccionComprarEscudo(_escudo); }, true, null, true); } else { // mostrar el dialogo de compra / equipar escudo ifcDialogBox.instance.ShowTwoButtonDialog( (equipar) ? ifcDialogBox.TwoButtonType.BITOONS_EQUIPAR : ifcDialogBox.TwoButtonType.BITOONS_DESEQUIPAR, string.Format(LocalizacionManager.instance.GetTexto(80).ToUpper(), _escudo.nombre.ToUpper()), string.Format(LocalizacionManager.instance.GetTexto(81), "<color=#ddf108> " + _escudo.numUnidades + "</color>", _escudo.nombre, (_escudo.numUnidades == 1) ? LocalizacionManager.instance.GetTexto(137) : LocalizacionManager.instance.GetTexto(145)), _escudo.precioHard.ToString(), (equipar ? LocalizacionManager.instance.GetTexto(82) : LocalizacionManager.instance.GetTexto(83)).ToUpper(), // callback para la compra de escudo (_name) => { // para que el usuario no se pase comprando if (_escudo.numUnidades >= 99) { ifcDialogBox.instance.ShowOneButtonDialog( ifcDialogBox.OneButtonType.POSITIVE, LocalizacionManager.instance.GetTexto(84).ToUpper(), string.Format(LocalizacionManager.instance.GetTexto(85), "<color=#ddf108> " + _escudo.nombre + "</color>"), LocalizacionManager.instance.GetTexto(45).ToUpper()); return; } // comprobar que el usuario tenga suficiente dinero para la compra if (Interfaz.MonedasHard < _escudo.precioHard) { ifcDialogBox.instance.ShowOneButtonDialog( ifcDialogBox.OneButtonType.POSITIVE, LocalizacionManager.instance.GetTexto(84).ToUpper(), string.Format(LocalizacionManager.instance.GetTexto(86), "<color=#ddf108> " + LocalizacionManager.instance.GetTexto(47) + "</color>"), LocalizacionManager.instance.GetTexto(45).ToUpper()); return; } // pagar el escudo y actualizar el dinero mostrado Interfaz.MonedasHard -= _escudo.precioHard; cntBarraSuperior.instance.ActualizarDinero(); GeneralSounds_menu.instance.comprar(); // incrementar la cantidad de escudos y repintar la tienda ++_escudo.numUnidades; if (ifcVestuario.instance != null) { ifcVestuario.instance.RefreshInfo(); } // persistir la cantidad de escudos PersistenciaManager.instance.SaveEscudos(); ShowAsEscudo(_escudo); // volver a la compra de escudos AccionComprarEscudo(_escudo); }, // callback para equipar / desequipar el escudo onEquiparCallback, true, null, true); } }
static void Main(string[] args) { //Creacion de Enanos //Creo a Enano Tommy y le asigno dos elementos diferentes IPersonaje enano1 = new Enano("Tommy"); IElemento elemento1 = new Hacha("Hacha Milagrosa"); enano1.AgregarElemento(elemento1); //Creo a Enano Lucas y le asigno dos elementos diferentes IPersonaje enano2 = new Enano("Lucas"); IElemento elemento2 = new Hacha("Hacha Loca"); enano2.AgregarElemento(elemento2); IElemento elemento3 = new Escudo("Escudo Largo"); enano2.AgregarElemento(elemento3); PrintPersonaje print = new PrintPersonaje(); print.ConsolePrint(enano1); print.ConsolePrint(enano2); //Ataque entre Enanos -> Tommy Ataca a Lucas enano1.RecibirAtaque(enano2); print.ConsolePrint(enano1); //Ataque entre Enanos -> Lucas Ataca a Tommy enano2.RecibirAtaque(enano1); print.ConsolePrint(enano2); //Curo Enanos: Tommy vuelve a tener 100 de vida enano1.Curar(); print.ConsolePrint(enano1); //los Enanos se crean Elfo dooby = new Elfo("Dooby"); Elfo belatrix = new Elfo("Belatrix"); IElemento dagaBelatrix = new Espada("Daga Belatrix"); IElemento calcetin = new Armadura("Calcetín"); dooby.AgregarElemento(calcetin); belatrix.AgregarElemento(dagaBelatrix); //Belatrix ataca a dobby dooby.Vida = dooby.Vida - belatrix.CalcularAtaqueTotal(); Console.WriteLine(dooby.Nombre + "\t" + "Vivo: " + dooby.TieneVida()); //Creo Dementores Dementor dementor1 = new Dementor("SeñorOscuro"); IElemento elementoDementor1 = new Daga("Bostezo Fatal"); dementor1.AgregarElemento(elementoDementor1); IElemento elementoDementor2 = new Capa("Alas de murcielago"); dementor1.AgregarElemento(elementoDementor2); Dementor dementor2 = new Dementor("Ron"); IElemento elementoDementor3 = new Capa("Traje invisible"); dementor2.AgregarElemento(elementoDementor3); IElemento elementoDementor4 = new Daga("Gorro Asesino"); dementor2.AgregarElemento(elementoDementor4); //Ataque entre Dementores dementor1.RecibirAtaque(dementor2); print.ConsolePrint(dementor1); //Curo Dementor dementor1.Curar(); print.ConsolePrint(dementor1); //Prueba instanciar magos Mago antioch = new Mago("Antioch Peverell"); Varita sauco = new Varita("Varita de Sauco"); antioch.AgregarElemento(sauco); Mago cadmus = new Mago("Cadmus Peverell"); Sombrero seleccionador = new Sombrero("Sombrero seleccionador"); cadmus.AgregarElemento(seleccionador); }
public void TryShotResult(ShotResult shotResult) { bool playingGoalkeeper = GameplayService.IsGoalkeeper(); if (playingGoalkeeper) { Habilidades.EndRound(shotResult.Result == Result.Goal); } if (!GameplayService.networked) { if (!playingGoalkeeper) { if (shotResult.Result == Result.Goal || shotResult.Result == Result.Target) { if (shotResult.Perfect && attempts < maxAttempts) { GeneralSounds.instance.vidaExtra(); kickEffects.instance.ExtraLife(shotResult.Point); this.attempts++; if (Habilidades.IsActiveSkill(Habilidades.Skills.VIP) && (attempts < maxAttempts)) { this.attempts++; kickEffects.instance.ExtraLife(shotResult.Point + (Vector3.up * -1f)); } } /*if (this.attempts >= maxAttempts && shotResult.Perfect) * { * if (perfects > 1 || Habilidades.IsActiveSkill(Habilidades.Skills.VIP)) * { * if (this.attempts != 3) * { * GeneralSounds.instance.vidaExtra(); * kickEffects.instance.ExtraLife(shotResult.Point); * this.attempts = 3; * } * } * } * if(this.attempts < maxAttempts) this.attempts = maxAttempts;*/ } else { ShotFailed(); } } else { if (shotResult.Result == Result.Goal) { ShotFailed(); } else { if (shotResult.Perfect && attempts < maxAttempts) { GeneralSounds.instance.vidaExtra(); kickEffects.instance.ExtraLife(shotResult.Point); this.attempts++; if (Habilidades.IsActiveSkill(Habilidades.Skills.VIP) && (attempts < maxAttempts)) { this.attempts++; kickEffects.instance.ExtraLife(shotResult.Point + (Vector3.up * -0.5f)); } } //else if (this.attempts < maxAttempts && shotResult.Result != Result.OutOfBounds) this.attempts = maxAttempts; } } SumarDineroPorPrimas(); } else if (GameplayService.networked) { bool isPlayer1 = GameplayService.initialGameMode != GameMode.Shooter; if (playingGoalkeeper) { cntPastillaMultiplayer.marcadorRemoto.Lanzamientos++; } else { cntPastillaMultiplayer.marcadorLocal.Lanzamientos++; } if (newState) { Debug.Log("APPLYING"); cntPastillaMultiplayer.marcadorLocal.SetEstado(GetSimpleState(serverState, isPlayer1)); cntPastillaMultiplayer.marcadorRemoto.SetEstado(GetSimpleState(serverState, !isPlayer1)); newState = false; } else { Debug.Log("CALCULATING"); MatchState tempstate = serverState; if ((isPlayer1 == playingGoalkeeper)) { tempstate.rounds++; } if (playingGoalkeeper) { MatchStateSimple state = cntPastillaMultiplayer.marcadorRemoto.AddResult(shotResult.Result == Result.Goal); if (isPlayer1) { tempstate.marker_2 = state.marker; tempstate.score_2 = state.score; } else { tempstate.marker_1 = state.marker; tempstate.score_1 = state.score; } } else { MatchStateSimple stateF = cntPastillaMultiplayer.marcadorLocal.AddResult(shotResult.Result == Result.Goal); if (isPlayer1) { tempstate.marker_1 = stateF.marker; tempstate.score_1 = stateF.score; } else { tempstate.marker_2 = stateF.marker; tempstate.score_2 = stateF.score; } } serverState = tempstate; if (!playingGoalkeeper) { Debug.Log("SENDING"); MsgSendState msg = Shark.instance.mensaje <MsgSendState>(); msg.state = tempstate; msg.defense = MsgDefend.ToDefenseInfoNet(Vector3.zero, shotResult.DefenseResult); msg.send(); } newState = false; } if (isPlayer1 == playingGoalkeeper) //fin de ronda { if (serverState.rounds > 4 && serverState.score_1 != serverState.score_2) //fin de partida { gameOver = true; bool winner = isPlayer1 ? (serverState.score_1 > serverState.score_2) : (serverState.score_2 > serverState.score_1); bool perfect = isPlayer1 ? (serverState.score_2 == 0) : (serverState.score_1 == 0); perfect = perfect && (isPlayer1 ? (serverState.score_1 >= 5) : (serverState.score_2 >= 5)); if (winner) { Interfaz.MonedasSoft += recompensaMultijugadorWin; } else { Interfaz.MonedasSoft += recompensaMultijugadorFail; } PersistenciaManager.instance.GuardarPartidaMultiPlayer(winner, perfect); } } } int points = shotResult.ScorePoints + shotResult.EffectBonusPoints; // actualizar la informacion de cada ronda RoundInfoManager.instance.AcumularRonda(shotResult.Result, points, shotResult.Perfect);//, GameplayService.IsGoalkeeper() ? (shotResult.DefenseResult == GKResult.Perfect) : (shotResult.Perfect)); // acumular la recompensa // DINERO! MONEDAS! int monedas = Mathf.FloorToInt((float)points * DifficultyService.GetRatioRecompensa()); Interfaz.recompensaAcumulada += monedas; Interfaz.MonedasSoft += monedas; if (gameOver && !GameplayService.networked) { //ifcGameOver.instance.resultTime = FieldControl.instance.seconds; Mission mission = MissionManager.instance.GetMission(); if (attempts > 0) { // persistir la mision que se acaba de superar PersistenciaManager.instance.ActualizarUltimoNivelDesbloqueado(mission.indexMision + 1); // comprobar si la en mision que se acaba de superar desbloquea algun jugador Jugador jugadorDesbloqueado = InfoJugadores.instance.GetJugadorDesbloqueableEnFase(mission.indexMision); if (jugadorDesbloqueado != null) { // registrar el dialogo para mostrar el aviso de que se ha obtenido un nuevo jugador y actualizar su estado jugadorDesbloqueado.estado = Jugador.Estado.DISPONIBLE; DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.JUGADOR_DESBLOQUEADO, jugadorDesbloqueado)); } // comprobar si en la mision que se acaba de superar se desbloquea alguna equipacion Equipacion equipacionDesbloqueada = EquipacionManager.instance.GetEquipacionDesbloqueableEnFase(mission.indexMision); if (equipacionDesbloqueada != null) { // registrar el dialogo para mostrar el aviso de que se ha obtenido una nueva equipacion y actualizar su estado equipacionDesbloqueada.estado = Equipacion.Estado.DISPONIBLE; DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.EQUIPACION_DESBLOQUEADA, equipacionDesbloqueada)); } // comprobar si en la mision que se acaba de superar se ha desbloqueado algun escudo Debug.Log(">>> Compruebo escudo => fase "); Escudo escudoDesbloqueado = EscudosManager.instance.GetEscudoDesbloqueableEnFase(mission.indexMision); if (escudoDesbloqueado != null) { // registrar el dialogo para mostrar el aviso de que se ha obtenido un nuevo escudo y desbloquearlo escudoDesbloqueado.bloqueado = false; DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.ESCUDO_DESBLOQUEADO, escudoDesbloqueado)); } } } if (firstShot) { firstShot = false; } UpdateEvent(); }
private void Start() { jugador = nave.GetComponent <Player>(); escudo = nave.GetComponentInChildren <Escudo>(); arma = nave.GetComponent <Arma>(); }
void Start() { //Empieza con el escudo predeterminado de fuego scriptEscudo = GetComponent <Escudo>(); escudoFisicoFuego.SetActive(true); }