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); }
void IniCapturePoint() { cpScore = new int[4]; StartCoroutine(SetNewCapturePoint()); for (int i = 0; i < 4; i++) { if (players [i] == null) { continue; } PlayerTag playerTag = players [i].GetComponent <PlayerTag> (); if (playerTag.Team == 0) { playerTag.SetTeam(i + 1); //Random.Range (1, 5); TODO ??? playerTag.SetId(i + 1); } } }
public virtual void Ini(GameObject parent, int id, int team, bool _released) { playerTag = GetComponent <PlayerTag> (); movementScript = GetComponent <Base_Movement> (); healthScript = GetComponent <Base_Health> (); targetter = GetComponentInChildren <Targetter> (); if (playerTag == null) { playerTag = GetComponent <PlayerTag> (); } playerTag.SetId(id); playerTag.SetTeam(team); if (_released) { Release(); } else { parentObject = parent; } }