示例#1
0
    public void FloatText(string style, string msg = "")
    {
        GameObject        text     = Instantiate(textFab, new Vector3(0, 0, 0), Quaternion.identity, canvas.transform);
        DmgTextController textCont = text.GetComponent <DmgTextController>();

        textCont.Init(this.transform.position, style, msg);
    }
示例#2
0
    public void ActivateButton()
    {
        InventoryItem item = activeList[selected];

        if (mode == "buying")
        {
            if (data.gold >= item.cost * 5)
            {
                data.AddToInventory(item.Copy());
                data.gold    -= item.cost * 5;
                goldText.text = data.gold.ToString();
                // Float cost text
                GameObject        text     = Instantiate(textFab, new Vector3(0, 0, 0), Quaternion.identity, gameObject.transform);
                DmgTextController textCont = text.GetComponent <DmgTextController>();
                textCont.Init(goldText.transform.position, "cost", "-" + (item.cost * 5).ToString());
            }
        }
        else if (mode == "selling")
        {
            data.gold     += item.cost;
            goldText.text  = data.gold.ToString();
            reselectNeeded = data.RemoveFromInventory(selected);
            // Float cost text
            GameObject        text     = Instantiate(textFab, new Vector3(0, 0, 0), Quaternion.identity, gameObject.transform);
            DmgTextController textCont = text.GetComponent <DmgTextController>();
            textCont.Init(goldText.transform.position, "gold", "+" + (item.cost).ToString());

            RefreshItems();
        }
    }
示例#3
0
 void Start()
 {
     DmgTextController.Initialize();
     player       = FindObjectOfType <Player>();
     healthBar    = GetComponent <Slider>();
     playerHealth = maxPlayerHealth;
     levelManager = FindObjectOfType <LevelManager>();
     isDead       = false;
 }
示例#4
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         DmgTextController.CreateFloatingText(damageToGive.ToString(), transform);
         HealthManager.HurtPlayer(damageToGive);
         Destroy(gameObject);
     }
 }
示例#5
0
 public virtual void giveDamage(int damageToGive)
 {
     if (name == "TowerShot B" || name == "TowerShot R") // Nay I say
     {
         enemyHealth -= damageToGive;                    // oh yeah this gives dmg to something that shouldn´t even have a health system!!! Great for perfomance....
     }
     else
     {
         enemyHealth -= damageToGive;
         DmgTextController.CreateFloatingText(damageToGive.ToString(), transform);
     }
 }
示例#6
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         Debug.Log("doing dmg");
         DmgTextController.CreateFloatingText(damageToGive.ToString(), transform);
         // HealthManager.HurtPlayer(damageToGive);
         HealthManager.dodmg = true;
         // GetComponent<Player>().GetComponent<HealthManager>().giveDamageAtAoe(damageToGive);
         // GetComponent<HealthManager>().giveDamageAtAoe(damageToGive);
     }
 }
示例#7
0
    public void Damage(int dmg, string style)
    {
        GameObject        dmgTextFab = Resources.Load("Prefabs/DamageText") as GameObject;
        GameObject        text       = Instantiate(dmgTextFab, new Vector3(0, 0, 0), Quaternion.identity, canvas.transform);
        DmgTextController textCont   = text.GetComponent <DmgTextController>();

        textCont.Init(this.transform.position, style, dmg.ToString());
        if (dmg > 0)
        {
            hp -= dmg;
            if (hp <= 0)
            {
                Die();
            }
        }
    }
示例#8
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         if (Random.Range(1, 101) == 100)
         {
             damageToGive = Random.Range(15, 20);
         }
         else if (Random.Range(1, 105) == 101)
         {
             damageToGive = 0;
         }
         else
         {
             damageToGive = Random.Range(1, 10);
         }
         DmgTextController.CreateFloatingText(damageToGive.ToString(), transform);
         HealthManager.HurtPlayer(damageToGive);
         GetComponent <HealthManager>().giveDamageAtAoe(damageToGive);
     }
 }
示例#9
0
    void Start()
    {
        if (name == "Champ")
        {
            t = Time.time;
        }
        baseDmg = 70;

        if (name == "TowerShot B" || name == "TowerShot R")
        {
        }
        else
        {
            healthBar = transform.FindChild("EnemyCanvas").FindChild("HealthBack").FindChild("HealthBar").GetComponent <Slider>();
        }
        clickMe      = GetComponent <ClickOnMe>();
        tim          = GameObject.Find("Timer_Spawner");
        anim         = GetComponent <Animator>();
        dodmg        = false;
        playerCenter = transform.FindChild("Center");
        DmgTextController.Initialize();
    }
示例#10
0
 void dmg(int damageToGive)
 {
     Debug.Log("continue dmg");
     enemyHealth -= damageToGive;
     DmgTextController.CreateFloatingText(damageToGive.ToString(), transform);
 }