public void criarCartas() { PackedScene cenaOriginal = ResourceLoader.Load <PackedScene>("res://scene/Carta.tscn"); CartaFactory cartaOriginal = new CartaFactory(); float y = 0; Vector3 posicao = this.Translation; foreach (COR cor in Enum.GetValues(typeof(COR))) { if (cor != COR.SEMCOR) { foreach (VALOR valor in Enum.GetValues(typeof(VALOR))) { if (valor != VALOR.SEM_VALOR) { Carta carta1 = new Carta(); carta1.Cor = cor; carta1.Valor = valor; CartaView carta = cartaOriginal.carregaCarta(carta1); carta.Translation = new Vector3(posicao.x, posicao.y + y, posicao.z); carta.Rotate(Vector3.Right, Mathf.Pi / 2); carta.Rotate(Vector3.Up, Mathf.Pi); y = y + altura; carta.Jogo = Jogo; baralhoCartas.Add(carta); Jogo.AddChild(carta); } } } } }
public void removeCarta(Carta carta) { CartaView cartaView = null; for (int i = 0; i < handCartas.Count; i++) { if (handCartas[i].Carta.Cor == carta.Cor && handCartas[i].Carta.Valor == carta.Valor) { cartaView = handCartas[i]; } } if (cartaView == null) { var rnd = new RandomNumberGenerator(); rnd.Randomize(); var i = rnd.RandiRange(0, handCartas.Count - 1); cartaView = handCartas[i]; cartaView.Carta = carta; } GD.Print(cartaView); handCartas.Remove(cartaView); organizar(); Jogo.animarCarta(cartaView); }
/// <summary> /// Tenta jogar uma carta /// </summary> /// <param name="carta"></param> public async void jogarCarta(CartaView carta) { PodeJogar = false; carta c = new carta(); c._cor = (int)carta.Carta.Cor; c._valor = (int)carta.Carta.Valor; Jogada jogada = new Jogada(); jogada.carta = c; jogada.jogadorId = jogadorPosicao; jogada.sala = NumeroSala; await Client.EmitAsync("jogada", response => { int x = response.GetValue <int>(); if (x == 1) { ordemJogada[jogadorPosicao].removeCarta(carta.Carta); aguardarAnimacaoCompra(); if (carta.Carta.Valor == VALOR.CORINGA || carta.Carta.Valor == VALOR.CORINGA_MAIS_QUATRO) { corSelecao.Visible = true; PodeJogar = false; } } else { PodeJogar = true; } }, jogada); }
public CartaView carregaCarta(Carta carta) { CartaView loadCarta = recurso.Instance() as CartaView; var novoShader = shaderFrente.Duplicate(true) as ShaderMaterial; loadCarta.init(normals, difuses, cores, novoShader); loadCarta.Carta = carta; return(loadCarta); }
public CartaView ultimaCartaView() { if (cartasDescartadas.Count == 0) { return(null); } int ultimoIndice = cartasDescartadas.Count - 1; CartaView carta = cartasDescartadas[ultimoIndice]; return(carta); }
public void addCarta(CartaView carta) { handCartas.Add(carta); var novasPosicoes = calculaPosicoes(); var rotacao = this.RotationDegrees; var tween = GetNode <Tween>("Tween"); for (int i = 0; i < handCartas.Count; i++) { tween.InterpolateProperty(handCartas[i], "translation", handCartas[i].Translation, novasPosicoes[i], 0.5f, Tween.TransitionType.Sine, Tween.EaseType.InOut); tween.InterpolateProperty(handCartas[i], "rotation_degrees", handCartas[i].RotationDegrees, rotacao, 0.5f, Tween.TransitionType.Sine, Tween.EaseType.InOut); } tween.Start(); }
public List <CartaView> comprarCartas(List <Carta> cartas) { List <CartaView> cards = new List <CartaView>(); for (int i = 0; i < cartas.Count; i++) { int ultima = baralhoCartas.Count - 1; CartaView ultimaCarta = baralhoCartas[ultima]; ultimaCarta.Carta = cartas[i]; cards.Add(ultimaCarta); baralhoCartas.Remove(ultimaCarta); } return(cards); }
private void _on_Area_input_event(object camera, object @event, Vector3 click_position, Vector3 click_normal, int shape_idx) { if (@event is InputEventMouse e) { if (e.ButtonMask == (int)ButtonList.Left) { if (baralhoCartas.Count == 0) { return; } int ultima = baralhoCartas.Count - 1; CartaView ultimaCarta = baralhoCartas[ultima]; Jogo.comprarCarta(ultimaCarta); baralhoCartas.Remove(ultimaCarta); } } }
public void addCarta(CartaView carta) { GD.Print("Carta Descartada"); var posIni = this.Translation; var r = new RandomNumberGenerator(); r.Randomize(); var rRot = r.RandfRange(-20, 20); var rot = new Vector3(-90, rRot, 0); posIni = new Vector3(posIni.x, posIni.y + (cartasDescartadas.Count * 0.02f), posIni.z); var tween = GetNode <Tween>("Tween"); tween.InterpolateProperty(carta, "translation", carta.Translation, posIni, 0.5f, Tween.TransitionType.Quart, Tween.EaseType.Out); tween.InterpolateProperty(carta, "rotation_degrees", carta.RotationDegrees, rot, 0.5f, Tween.TransitionType.Linear, Tween.EaseType.InOut); tween.Start(); cartasDescartadas.Add(carta); }
public void moverCartasBaralho() { int ultimoIndice = cartasDescartadas.Count - 1; CartaView ultimaCarta = cartasDescartadas[ultimoIndice]; cartasDescartadas.Remove(ultimaCarta); int tamanho = cartasDescartadas.Count; var tween = GetNode <Tween>("Tween"); var rot = new Vector3(90, 0, 180); float delay = 0; for (int i = tamanho - 1; i >= 0; i--) { CartaView tmp = cartasDescartadas[i]; cartasDescartadas.Remove(tmp); tween.InterpolateProperty(tmp, "translation", tmp.Translation, Baralho.Translation, 0.5f, Tween.TransitionType.Quart, Tween.EaseType.InOut, delay); tween.InterpolateProperty(tmp, "rotation_degrees", tmp.RotationDegrees, rot, 0.5f, Tween.TransitionType.Linear, Tween.EaseType.InOut, delay); delay += 0.08f; Baralho.addCarta(tmp); } moveCartasBaralho = true; tween.Start(); }
public void addCarta(CartaView carta) { carta.Carta = new project.src.models.Carta(); baralhoCartas.Add(carta); }
public void animarCarta(CartaView carta) { descarte.addCarta(carta); }
public void comprarCarta(CartaView carta) { mao.addCarta(carta); }