public void GiveEnemy(int r) { GameObject enemy = Instantiate(enemies_prefabs[r], transform.position, Quaternion.identity) as GameObject; Base_Mob enemyScript = enemy.GetComponent <Base_Mob> (); PlayerTag enemyPlayerTag = enemy.GetComponent <PlayerTag> (); enemyPlayerTag.SetId(playerTag.Id); enemyPlayerTag.SetTeam(playerTag.Team); Color col = Color.white; Color col1 = Color.white; for (int i = 0; i < enemies_active.Length; i++) { if (enemies_active [i] == null) { enemies_active[i] = enemy; float angle = (360f / enemies_active.Length) * i; Vector3 sideVec = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle)) * 2f; float amount = .5f; if (playerTag.Id == 1) { col = Color.blue; col1.r = amount; col1.g = amount; } else if (playerTag.Id == 2) { col = Color.yellow; col1.r = amount; } else if (playerTag.Id == 3) { col = Color.red; col1.b = amount; col1.g = amount; } else if (playerTag.Id == 4) { col = Color.magenta; col1.g = amount; } enemyScript.Ini(gameObject, playerTag.Id, playerTag.Team, false); //enemyScript.Ini(i, sideVec, gameObject,col,this); break; } } enemy_count++; enemyScript.GetComponentInChildren <SpriteRenderer> ().color = col1; Physics2D.IgnoreCollision(GetComponent <CapsuleCollider2D>(), enemyScript.GetComponent <CircleCollider2D>()); Base_WeaponManager wepMan = GetComponent <Base_WeaponManager> (); //.weapons [0]; float damageRed = Mathf.Min(.5f, 1f - (enemy_count * .1f)); wepMan.DamageRed = damageRed; NumberSpawner.Instance.CreateNumber(transform.position, "-" + Mathf.Min(50f, enemy_count * 10f) + "% Damage", NUMBER_COL.DEBUFF, 0.1f, 60f, 1f); }
public void InstantiateObject() { GameObject objectToInstantiate = Instantiate(options [currentOption].prefab, transform.position, Quaternion.identity); if (options [currentOption].type == PlayerDeadOptionType.MOB) { Base_Mob mob = objectToInstantiate.GetComponent <Base_Mob> (); mob.Ini(null, playerTag.Id, playerTag.Team, true); } else if (options [currentOption].type == PlayerDeadOptionType.POWERUP) { PickupRespawn pickup = objectToInstantiate.GetComponent <PickupRespawn> (); pickup.duration = -1f; PickupGun gun = objectToInstantiate.GetComponent <PickupGun> (); if (gun != null) { return; } Powerup powerup = objectToInstantiate.GetComponent <Powerup> (); if (powerup != null) { powerup.SetValue(options[currentOption].baseValue); return; } AmmoPickup ammo = objectToInstantiate.GetComponent <AmmoPickup> (); if (ammo != null) { ammo.SetValue((int)options [currentOption].baseValue); return; } } }