Ejemplo n.º 1
0
    public void GiveBuffs(ClashBattleUnit attributes, string tag)
    {
        var team = GameObject.FindGameObjectsWithTag(tag);

        foreach (var teammate in team)
        {
            var teammateAttribute = teammate.GetComponent <ClashBattleUnit>();
            //teammate != attributes.gameObject so it doesn't get a buff from itself
            if (teammate != attributes.gameObject && teammateAttribute.currentHealth > 0)
            {
                switch (attributes.species.name)
                {
                case "Big Tree":                        //hp buff
                    teammateAttribute.currentHealth += 100;
                    break;

                case "Baobab":                  //damage buff
                    teammateAttribute.damage += 8;
                    break;

                case "Trees and Shrubs":                        //movement speed buff
                    if (teammateAttribute.agent != null)
                    {
                        teammateAttribute.agent.speed += 5.0f;
                    }
                    break;

                default:
                    break;
                }
            }
        }
    }
Ejemplo n.º 2
0
    void Start()
    {
        camera = Camera.main.transform;
        unit = GetComponentInParent<ClashBattleUnit>();
        slider = GetComponentInChildren<Slider>();

        var colors = new ColorBlock();
        switch (unit.species.type) {
            case ClashSpecies.SpeciesType.CARNIVORE:
                colors.normalColor = Color.red;
                break;
            case ClashSpecies.SpeciesType.HERBIVORE:
                colors.normalColor = Color.blue;
                break;
            case ClashSpecies.SpeciesType.OMNIVORE:
                colors.normalColor = Color.yellow;
                break;
            case ClashSpecies.SpeciesType.PLANT:
                colors.normalColor = Color.green;
                break;
            default: break;
        }
        colors.colorMultiplier = 1.0f;
        slider.colors = colors;
    }
    public void GiveBuffs(ClashBattleUnit attributes, string tag)
    {
        var team = GameObject.FindGameObjectsWithTag (tag);

        foreach (var teammate in team) {
            var teammateAttribute = teammate.GetComponent<ClashBattleUnit>();
            //teammate != attributes.gameObject so it doesn't get a buff from itself
            if(teammate != attributes.gameObject && teammateAttribute.currentHealth > 0) {
                switch (attributes.species.name) {
                case "Big Tree":	//hp buff
                    teammateAttribute.currentHealth += 100;
                    break;
                case "Baobab":	//damage buff
                    teammateAttribute.damage += 8;
                    break;
                case "Trees and Shrubs":	//movement speed buff
                    if(teammateAttribute.agent != null)
                        teammateAttribute.agent.speed += 5.0f;
                    break;
                default:
                    break;
                }
            }
        }
    }
    void Start()
    {
        camera = Camera.main.transform;
        unit   = GetComponentInParent <ClashBattleUnit>();
        slider = GetComponentInChildren <Slider>();

        var colors = new ColorBlock();

        switch (unit.species.type)
        {
        case ClashSpecies.SpeciesType.CARNIVORE:
            colors.normalColor = Color.red;
            break;

        case ClashSpecies.SpeciesType.HERBIVORE:
            colors.normalColor = Color.blue;
            break;

        case ClashSpecies.SpeciesType.OMNIVORE:
            colors.normalColor = Color.yellow;
            break;

        case ClashSpecies.SpeciesType.PLANT:
            colors.normalColor = Color.green;
            break;

        default: break;
        }
        colors.colorMultiplier = 1.0f;
        slider.colors          = colors;
    }
    void TakeDamage(int damage, ClashBattleUnit source = null)
    {
        if (timeSinceSpawn < 1.0)
        {
            return;                               // Be invincible for the first second after being spawned
        }
//		Debug.Log (tag + " " + species.name + " taking " + damage + " damage from " + source.tag + " " + source.species.name);
        currentHealth = Mathf.Max(0, currentHealth - damage);
        if (currentHealth == 0)
        {
            Die();
        }
    }
Ejemplo n.º 6
0
 void Die()
 {
     //Disable all functions here
     if (anim != null) {
         anim.SetTrigger("Dead");
     }
     target=null;
     if(agent != null)
         agent.enabled = false;
     if (species.type == ClashSpecies.SpeciesType.PLANT) {
         RemoveBuffs(species, this.gameObject.tag);
         if(this.gameObject.tag == "Ally")
             controller.UpdateBuffPanel(species, false);
     }
 }
 void Update()
 {
     timer          += Time.deltaTime;
     timeSinceSpawn += Time.deltaTime;
     if (!target)
     {
         Idle();
     }
     else if ((target.currentHealth > 0) && (timer >= timeBetweenAttacks) && (currentHealth >= 0.0f))
     {
         Attack();
     }
     else if (target.currentHealth <= 0)
     {
         target = null;
     }
 }
 void Die()
 {
     //Disable all functions here
     if (anim != null)
     {
         anim.SetTrigger("Dead");
     }
     target = null;
     if (agent != null)
     {
         agent.enabled = false;
     }
     if (species.type == ClashSpecies.SpeciesType.PLANT)
     {
         RemoveBuffs(species, this.gameObject.tag);
         if (this.gameObject.tag == "Ally")
         {
             controller.UpdateBuffPanel(species, false);
         }
     }
 }
Ejemplo n.º 9
0
 void Update()
 {
     timer += Time.deltaTime;
     timeSinceSpawn += Time.deltaTime;
     if (!target) {
         Idle();
     } else if ((target.currentHealth > 0) && (timer >= timeBetweenAttacks) && (currentHealth >= 0.0f)) {
         Attack();
     } else if (target.currentHealth <= 0) {
         target = null;
     }
 }
Ejemplo n.º 10
0
 void TakeDamage(int damage, ClashBattleUnit source = null)
 {
     if (timeSinceSpawn < 1.0) return; // Be invincible for the first second after being spawned
     //		Debug.Log (tag + " " + species.name + " taking " + damage + " damage from " + source.tag + " " + source.species.name);
     currentHealth = Mathf.Max(0, currentHealth - damage);
     if (currentHealth == 0) {
         Die();
     }
 }