Ejemplo n.º 1
0
    public static void CreatDamageText(string str, Transform position, int DMGtype)
    {
        DamageText exp = Instantiate(damageText);

        if (exp != null)
        {
            exp.transform.SetParent(canv.transform, false);
            exp.GetComponent <RectTransform>().position = Camera.main.WorldToScreenPoint(position.position);
            exp.SetText(str);
            switch (DMGtype)
            {
            case 1:
                exp.GetComponentInChildren <Animator>().SetTrigger(Random.Range(0, 10) > 5 ? "Cri1": "Cri2");
                break;

            case 2:
                exp.GetComponentInChildren <Animator>().SetTrigger(Random.Range(0, 10) > 5 ? "DMG1":"DMG2");
                break;

            case 3:
                exp.GetComponentInChildren <Animator>().SetTrigger(Random.Range(0, 10) > 5 ? "Dot1":"Dot2");
                break;
            }
        }
    }
Ejemplo n.º 2
0
    public void CreateDamageText(int damage, Transform pos, Color color)
    {
        //Debug.Log(pos.position);
        DamageText newDamageText = Instantiate(damagePrefabs);

        newDamageText.transform.SetParent(canvas.transform, false);
        newDamageText.GetComponentInChildren <Text>().color = color;

        Vector3 screenPos = currentCam.WorldToScreenPoint(pos.position);

        newDamageText.transform.position = screenPos;
        newDamageText.setDamageText(damage.ToString());

        newDamageText.gameObject.SetActive(true);
    }