Ejemplo n.º 1
0
 void Start()
 {
     cameraToLookAt = Camera.main;
     if (totem.getFaction() == Util.Factions.Ittla)
     {
         GetComponent <Image>().color = Util.gc.ittlaMaterial.color;
         lifeText.color = Color.white;
     }
     else if (totem.getFaction() == Util.Factions.Nerta)
     {
         GetComponent <Image>().color = Util.gc.nertaMaterial.color;
         lifeText.color = Color.white;
     }
 }
Ejemplo n.º 2
0
    void OnTriggerEnter(Collider other)
    {
        // Check the collision only once (only the Ittla totems manage the collisions,
        // just to not count them two times and fall into mistakes)
        if (faction == Util.Factions.Ittla)
        {
            Totem enemyTotem = other.GetComponent <Totem>();
            if (enemyTotem != null)
            {
                if (enemyTotem.getFaction() != faction)
                {
                    int enemyTotemLifeOnCollision = enemyTotem.life;
                    int lifeOnCollision           = life;


                    enemyTotem.life -= lifeOnCollision;
                    life            -= enemyTotemLifeOnCollision;

                    /*Debug.Log(faction + " life: " + life + " - " + this.gameObject );
                     * Debug.Log(enemyTotem.getFaction() + " life: " + enemyTotem.life + " - " + enemyTotem.gameObject);
                     * Debug.Log("---");*/


                    if (enemyTotem.life <= 0)
                    {
                        enemyTotem.life = 0;
                        Util.gc.nertaOnBoardTotems.Remove(enemyTotem.gameObject);
                        Destroy(enemyTotem.gameObject);
                    }
                    if (life <= 0)
                    {
                        life = 0;
                        Util.gc.ittlaOnBoardTotems.Remove(this.gameObject);
                        Destroy(this.gameObject);
                    }
                }
            }
        }
    }