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 Awake() { playerTag = GetComponent <PlayerTag> (); movementScript = GetComponent <Base_Player_Movement> (); weaponScript = GetComponent <Base_WeaponManager> (); healthScript = GetComponent <Player_Health> (); playerAnimator = GetComponent <PlayerAnimator> (); playerEnemyHandler = GetComponent <PlayerEnemyHandler> (); }
public IEnumerator RespawnPlayer(GameObject player) { Camera.main.GetComponent <CameraController> ().TurnOnShake(); int playerId = player.GetComponent <PlayerTag> ().Id; respawnTicks [playerId] = 41; /*Time.timeScale = .1f; * for (int i = 0; i < 9; i++) { * yield return new WaitForSeconds (.1f); * Time.timeScale += .1f; * if (Time.timeScale > 1f) Time.timeScale=1f; * }*/ while (respawnTicks[playerId] > 0) { yield return(new WaitForSeconds(.5f)); respawnTicks[playerId] -= 5; } player.SetActive(true); Base_WeaponManager weaponManager = player.GetComponent <Base_WeaponManager> (); Player_Health healthScript = player.GetComponent <Player_Health> (); Base_Player_Movement movementScript = player.GetComponent <Base_Player_Movement> (); PlayerController playerController = player.GetComponent <PlayerController> (); weaponManager.RefreshWeapons(); float tempHealth = healthScript.Health_Max; tempHealth = Mathf.Ceil(tempHealth * 1.33f); healthScript.SetHealth(tempHealth, tempHealth, 0f); movementScript.ResetMovementValues(); playerController.SetInputActive(true); playerController.RefreshCanSwitch(); player.transform.position = spawnPoints [playerId].position; healthScript.StartCoroutine(healthScript.InvincibilityRoutine(60f)); healthScript.ResetHarsh(); //PowerupManager powMan = player.GetComponent<PowerupManager> (); //powMan.Reset (); TODO if (gameMode != GAMEMODE.PVE || gameMode != GAMEMODE.PVP_GUNS) { player.GetComponent <PlayerEnemyHandler> ().GiveEnemy(1); } }
protected virtual void Awake() { if (unlimitedAmmo) { ammo = 1; } else { ammo = maxAmmo; } wepMan = GetComponentInParent <Base_WeaponManager> (); if (wepMan == null) { wepMan = GetComponent <Base_WeaponManager> (); } }
void Update() { //RotateEnemies (); CheckDisband(); if (enemy_count == 0) { Base_WeaponManager wepMan = GetComponent <Base_WeaponManager>(); if (wepMan.DamageRed < 1f) { wepMan.DamageRed += .001f; // around 8 seconds from 50% reduction. if (wepMan.DamageRed > 1f) { wepMan.DamageRed = 1f; } if (wepMan.DamageRed == 1f) { NumberSpawner.Instance.CreateNumber(transform.position, Mathf.Round(wepMan.DamageRed) * 100f + "% damage", NUMBER_COL.DEBUFF, .075f, 60f, 1f); } } } lastAxis = Input.GetAxisRaw("rot_" + (playerTag.Id).ToString()); }