Esempio n. 1
0
 public void PlayCard(GameObject g)
 {
     Debug.Log("CHAMOU METODO CURAR CARTA");
     if (parent.selected == true)
     {
         if (cardcontroller == null)
         {
             cardcontroller = (CardController)parent.GetComponent("CardController");
         }
         Debug.Log("CARTA CURA CARTA");
         if (podeUsar == true)
         {
             Debug.Log("ESTA CURANDO");
             podeUsar = false;
             parent.PlayCard();
             parent.Deselect();
             target = g;
             Debug.Log(target);
             CardController status       = (CardController)target.GetComponent("CardController");
             CardController statusparent = (CardController)parent.GetComponent("CardController");
             status.defesa = status.defesa + 4;
             EventManager.Instance.OnTargetSelect -= PlayCard;
             if (player1 != null)
             {
                 GameObject carta = player1.campo[parent.position];
                 player1.campo.RemoveAt(parent.position);
                 Destroy(carta);
                 player1.OrganizeCards();
                 Debug.Log("RETIRANDO BARRICADA DO CAMPO");
             }
             if (player2 != null)
             {
                 GameObject carta = player2.campo[parent.position];
                 player2.campo.RemoveAt(parent.position);
                 Destroy(carta);
                 player2.OrganizeCards();
                 Debug.Log("RETIRANDO BARRICADA DO CAMPO 2");
             }
         }
     }
 }
Esempio n. 2
0
    void Update()
    {
        //Dinamite
//		if (this.properties.card_name == "Dinamite")
//		{
//			if (this.podeAtacar == true && this.player1 != null && player1.suaVez == true)
//			{
//				player2 = (Player2Controller)player2.GetComponent("9868");
//				this.podeAtacar = false;
//				Debug.Log ("Sera q funciona");
//				for (int i = 0; i < player2.campo.Count; i++) {
//					CardController cb = GetBehav (player2.campo [i]);
//					Debug.Log ("FUNCIONOUU!!!");
//					cb.defesa -=2;
//				}
//				//				player2 = null;
//			}
//		}

        //Retira seleçao quando turno eh do outro jogador
        if (this.player1 != null && player1.suaVez == false)
        {
            if (selected == true)
            {
                selected = false;
                player1.OrganizeCards();
                Debug.Log("Retirar select");
            }
            if (this.borda.enabled == true)
            {
                this.borda.enabled = false;
            }
        }
        if (this.player2 != null && player2.suaVez == false)
        {
            if (selected == true)
            {
                selected = false;
                player2.OrganizeCards();
                Debug.Log("Retirar select");
            }
            if (this.borda.enabled == true)
            {
                this.borda.enabled = false;
            }
        }

        //Detonando Dinamite
//		if (this.properties.card_name == "Dinamite" && this.podeAtacar == true)
//		{
//			EventManager.Instance.OnTargetSelectEventCall(gameObject);
//		}

        //Sempre que uma carta de apoio estiver no campo sem estar selecionada, destrui-la
        if ((this.cardPosition == POSITION.INPLAY && this.selected == false && this.properties.card_tipo.ToString() == "Tipo: Apoio" && this.properties.card_name == "Colete") || (this.cardPosition == POSITION.INPLAY && this.selected == false && this.properties.card_tipo.ToString() == "Tipo: Apoio" && this.properties.card_name == "Barricada"))
        {
            if (this.player1 != null && player1.suaVez == true)
            {
                GameObject carta = player1.campo[position];
                player1.campo.RemoveAt(position);
                Destroy(carta);
                player1.OrganizeCards();
            }
            if (this.player2 != null && player2.suaVez == true)
            {
                GameObject carta = player2.campo[position];
                player2.campo.RemoveAt(position);
                Destroy(carta);
                player2.OrganizeCards();
            }
        }

        //update da textura de ataque e defesa
        if (txtataque.text != ataque.ToString())
        {
            txtataque.text = ataque.ToString();
        }
        if (txtdefesa.text != defesa.ToString())
        {
            txtdefesa.text = defesa.ToString();
        }

        if (cardPosition == POSITION.INPLAY && this.podeAtacar == false && player1 != null && player1.suaVez == false)
        {
            this.podeAtacar = true;
        }

        if (cardPosition == POSITION.INPLAY && this.podeAtacar == false && player2 != null && player2.suaVez == false)
        {
            this.podeAtacar = true;
        }

        // Atribuindo o script  variavel
        if (player1status == null && player1 != null && this.cardPosition == POSITION.HAND)
        {
            player1status = (Player1Status)player1.GetComponent("Player1Status");
        }
        if (player2status == null && player2 != null && this.cardPosition == POSITION.HAND)
        {
            player2status = (Player2Status)player2.GetComponent("Player2Status");
        }


        // ativando e desativando bordas em Campo de batalha
        if ((cardPosition == POSITION.INPLAY && this.borda.enabled == false && player1status != null && this.podeAtacar == true && player1.suaVez == true) || (cardPosition == POSITION.INPLAY && this.borda.enabled == false && player2status != null && this.podeAtacar == true && player2.suaVez == true))
        {
            this.borda.enabled        = true;
            this.borda.material.color = Color.white;
        }
        if ((cardPosition == POSITION.INPLAY && this.borda.enabled == true && player1status != null && this.podeAtacar == false && player1.suaVez == true) || (cardPosition == POSITION.INPLAY && this.borda.enabled == true && player2status != null && this.podeAtacar == false && player2.suaVez == true))
        {
            this.borda.enabled = false;
        }

        // Ativando e desativando bordas
        if (cardPosition == POSITION.HAND && this.borda.enabled == false && player1status != null && this.properties.comando <= player1status.mana)
        {
            if (player1.suaVez == true)
            {
                Debug.Log("Ativando borda");
                this.borda.enabled        = true;
                this.borda.material.color = Color.green;
            }
        }

        if (cardPosition == POSITION.HAND && this.borda.enabled == false && player2status != null && this.properties.comando <= player2status.mana)
        {
            if (player2.suaVez == true)
            {
                Debug.Log("Ativando borda");
                this.borda.enabled        = true;
                this.borda.material.color = Color.green;
            }
        }

        //Desativando borda quando nao tiver mana suficiente
        if (cardPosition == POSITION.HAND && this.borda.enabled == true && player1status != null && this.properties.comando > player1status.mana)
        {
            Debug.Log("Desativando novamente a borda");
            this.borda.enabled = false;
        }

        if (cardPosition == POSITION.HAND && this.borda.enabled == true && player2status != null && this.properties.comando > player2status.mana)
        {
            Debug.Log("Desativando novamente a borda");
            this.borda.enabled = false;
        }

        //Desativando borda quando nao for sua vez
        if (cardPosition == POSITION.HAND && this.borda.enabled == true && player1status != null)
        {
            if (player1.suaVez == false)
            {
                Debug.Log("Desativando borda");
                this.borda.enabled = false;
            }
        }

        if (cardPosition == POSITION.HAND && this.borda.enabled == true && player2status != null)
        {
            if (player2.suaVez == false)
            {
                Debug.Log("Desativando borda");
                this.borda.enabled = false;
            }
        }

        //carta grande na mao sempre name frente
        if (scaledUp == true && transform.localPosition.z != -8.5f && cardPosition == POSITION.HAND)
        {
            SetLayer(-8.5f);
        }

        if (transform.localScale.x != 1f && transform.localScale.y != 1f && cardPosition == POSITION.INPLAY)
        {
            transform.localScale = new Vector3(1f, 1f, 1f);
            StartCoroutine(Wait());
        }
        if (scaledUp == true && transform.localPosition.z != 2f && cardPosition == POSITION.INPLAY)
        {
            SetLayer(2f);
            scaledUp = false;
        }
        if (transform.localScale.x > 2f && transform.localScale.y > 2f && cardPosition == POSITION.HAND && scaledUp == true)
        {
            transform.localScale = new Vector3(2f, 2f, 2f);
            transform.Translate(new Vector3(0f, 0f, .2f));
        }

        // retirar bug da carta continuar grande mesmo sem o mouse estar em cima
        if (y == default_y && scaledUp == true && player1.suaVez == true)
        {
            SetLayer((float)position);
            y = default_y;
            transform.localScale = new Vector3(transform.localScale.x / 2f, transform.localScale.y / 2f, transform.localScale.z / 2f);
            transform.Translate(new Vector3(0f, 0f, .2f));
            scaledUp = false;
        }
        // retirar bug da carta continuar grande mesmo sem o mouse estar em cima
        if (y == default_y2 && scaledUp == true && player2.suaVez == true)
        {
            SetLayer((float)position);
            y = default_y2;
            transform.localScale = new Vector3(transform.localScale.x / 2f, transform.localScale.y / 2f, transform.localScale.z / 2f);
            transform.Translate(new Vector3(0f, 0f, .2f));
            scaledUp = false;
        }

        //Retirar seleçao da carta no campo quando outra carta da mao for colocada no campo
        if (this.selected == true && this.y3 == -2f)
        {
            selected = false;
        }

        if (this.selected == true && this.y3 == 2f)
        {
            selected = false;
        }

        if (cardPosition == POSITION.HAND)
        {
            transform.position = Vector3.Lerp(transform.position, new Vector3(x, y, this.transform.position.z), 0.1f);
        }
        else if (cardPosition == POSITION.DECK)
        {
            transform.position = Vector3.Lerp(transform.position, new Vector3(x2, y2, this.transform.position.z), 0.1f);
        }
        else if (cardPosition == POSITION.INPLAY)
        {
            transform.position = Vector3.Lerp(transform.position, new Vector3(x3, y3, this.transform.position.z), 0.1f);
        }
    }