// Start is called before the first frame update void Start() { sC = transform.parent.GetComponent <StatControler>(); bar = transform.Find("Bar"); barSprite = bar.Find("BarSprite").gameObject.GetComponent <SpriteRenderer>(); barSprite.color = maxHealth; }
public void Equip(StatControler statControler) { foreach (modInfo mod in modifiers) { statControler.AddModifier(new StatModifier(mod.value, mod.type, mod.statType, this)); } }
private void Update() { if (Input.GetButtonDown("Equipment")) { equipmentUI.SetActive(!equipmentUI.activeSelf); } statController = player.GetComponent <StatControler>(); }
// Start is called before the first frame update void Start() { heldItem = Instantiate(heldItem); curDirection = DIR.IDLE; player = GameObject.Find("Player").transform; statControler = GetComponent <StatControler>(); rb = GetComponent <Rigidbody2D>(); }
// do something on collision public override void onCollision(GameObject projectile, Collision2D collision) { Collider2D collider = collision.GetContact(0).collider; //Debug.Log(User.name + " hit " + collider.name); if (collider.gameObject == User) { return; } if (breakWalls) { Vector2 hitPos = collision.GetContact(0).point - collision.relativeVelocity.normalized * .1f; if (collision.GetContact(0).collider.name == "Walls") { FindObjectsOfType <Map.MapManager>()[0].DamageTile(hitPos.x, hitPos.y, damage); Destroy(projectile); } } StatControler sC; StatControler sCUser = User.GetComponent <StatControler>(); if ((sC = collision.GetContact(0).collider.gameObject.GetComponent <StatControler>()) != null) { int finalDamage = 0; finalDamage += damage; HealthStat health = sC.GetStatOfType(StatType.HealthStat) as HealthStat; ArmorStat armor = sC.GetStatOfType(StatType.ArmorStat) as ArmorStat; DamageStat damageBonus = sCUser.GetStatOfType(StatType.DamageStat) as DamageStat; if (armor != null) { finalDamage -= (int)armor.CalculateFinalValue(); } if (damageBonus != null) { finalDamage += (int)damageBonus.CalculateFinalValue(); } //Debug.Log(health); if (health != null) { //Debug.Log(finalDamage); health.addValue(-finalDamage); Destroy(projectile); } } }
void Start() { heldItem = Instantiate(heldItem); sprite = GetComponent <SpriteRenderer>(); rb = GetComponent <Rigidbody2D>(); statControler = GetComponent <StatControler>(); playerObj = GameObject.Find("Player_v2"); sprite.color = Color.Lerp(a, b, 0); StartCoroutine(SetHealth()); }
void Start() { // hack: works for now - ask isaac heldItem = Instantiate(heldItem); sprite = GetComponent <SpriteRenderer>(); statControler = GetComponent <StatControler>(); //rb = GetComponent<Rigidbody2D>(); playerObj = GameObject.FindGameObjectWithTag("Player"); if (health == null) { health = GetComponent <StatControler>().GetStatOfType(StatType.HealthStat) as HealthStat; } //StartCoroutine(EnemyFSM()); }
// Start is called before the first frame update void Start() { Debug.Log("Sound Manager Setup"); sC = player.GetComponent <StatControler>(); BGM.volume = 0.05f; FX.volume = 0.005f; StartCoroutine(BGM_Manager()); /**/ GameObject SlimeAS = new GameObject(); SlimeAS.transform.parent = transform; SlimeAS.AddComponent <AudioSource>(); SlimeFX = SlimeAS.GetComponent <AudioSource>(); SlimeFX.loop = true; SlimeFX.volume = 0.1f; SlimeFX.clip = SlimeAudio; }
// do something on collision public override void onCollision(GameObject attack, Collision2D collider) { //Debug.Log(User.name + " hit " + collider.gameObject.name); if (collider.gameObject == User) { return; } StatControler sC; StatControler sCUser = User.GetComponent <StatControler>(); if ((sC = collider.gameObject.GetComponent <StatControler>()) != null) { int finalDamage = 0; finalDamage += damage; HealthStat health = sC.GetStatOfType(StatType.HealthStat) as HealthStat; ArmorStat armor = sC.GetStatOfType(StatType.ArmorStat) as ArmorStat; DamageStat damageBonus = sCUser.GetStatOfType(StatType.DamageStat) as DamageStat; if (armor != null) { finalDamage -= (int)armor.CalculateFinalValue(); } if (damageBonus != null) { finalDamage += (int)damageBonus.CalculateFinalValue(); } //Debug.Log(health); if (health != null) { health.addValue(-finalDamage); //Debug.Log("Players health is = " + health.CurrentValue); } } }
// Start is called before the first frame update void Start() { player = GameObject.Find("Player_v2"); playerCollider = player.GetComponent <CapsuleCollider2D>(); playerSC = player.GetComponent <StatControler>(); }
private void Start() { statControler = GetComponentInParent <StatControler>(); }
public void Unequip(StatControler statControler) { statControler.RemoveAllModifiersFromSource(this); }
// Start is called before the first frame update void Start() { //Debug.Log("Starting"); sprite = GetComponent <SpriteRenderer>(); statControler = GetComponent <StatControler>(); }
// do something on collision public override void onCollision(GameObject projectile, Collision2D collision) { Collider2D collider = collision.GetContact(0).collider; //Debug.Log(User.name + " hit " + collider.name); if (collider.gameObject == User) { return; } if (breakWalls) { Vector2 hitPos = collision.GetContact(0).point - collision.relativeVelocity.normalized * .1f; if (collision.GetContact(0).collider.name == "Walls") { Instantiate(explosion, hitPos, new Quaternion()); for (float i = -explosionRaidius; i <= explosionRaidius; ++i) { for (float j = -explosionRaidius; j <= explosionRaidius; ++j) { var d = i * i + j * j; if (d <= sqrR) { Map.MapManager.instance.DamageTile(hitPos.x + i, hitPos.y + j, damage / d); } } } Destroy(projectile); } } StatControler sC; StatControler sCUser = User.GetComponent <StatControler>(); if ((sC = collision.GetContact(0).collider.gameObject.GetComponent <StatControler>()) != null) { int finalDamage = 0; finalDamage += damage; HealthStat health = sC.GetStatOfType(StatType.HealthStat) as HealthStat; ArmorStat armor = sC.GetStatOfType(StatType.ArmorStat) as ArmorStat; DamageStat damageBonus = sCUser.GetStatOfType(StatType.DamageStat) as DamageStat; if (armor != null) { finalDamage -= (int)armor.CalculateFinalValue(); } if (damageBonus != null) { finalDamage += (int)damageBonus.CalculateFinalValue(); } //Debug.Log(health); if (health != null) { //Debug.Log(finalDamage); health.addValue(-finalDamage); Destroy(projectile); } } }