Ejemplo n.º 1
0
	public void takedamage(Card from, bool attack = true) {
        //positions of one taking damage and one giving damage
        Vector3 pos = originposition;
        if (!attack) { pos = onfieldpos; }

		//create particle
		GameObject particle = (GameObject)Object.Instantiate(Main.textures.bleedparticles);
        particle.transform.position = pos; particle.transform.Translate(0, 20, 0); particle = null;

		//create damage text
		GameObject damagefadetext = (GameObject)Object.Instantiate(Main.uimanager.damagetext);
        damagefadetext.transform.position = pos; damagefadetext.transform.Translate(0, 20, 0);
		damagefadetext.renderer.enabled = true;
        damagefadetext.GetComponent<TextMesh>().text = from.details.damage.ToString();
        damagefadetext.GetComponent<TextFade>().fadeenabled = true;

        //deal damage to crystals
        int damage = from.details.damage;
        if (details.health - damage < 0) { damage = Mathf.Abs(details.health - damage); }else { damage = 0; }
        if (!opponent) { Main.uimanager.playerhealth -= damage;
        }else { Main.uimanager.opphealth -= damage; }
        Main.uimanager.updateui();

		//take away health
        details.health -= from.details.damage;
        healthtext.text = details.health.ToString();
        damagetext.text = details.damage.ToString();
        manatext.text = details.manacost.ToString();

		if (details.health <= 0) {
			destroy();
		}

        //return the attack from the card
        if (attack) {
            from.takedamage(this, false);
        }
	}