void PickUpWeapon(PickupRespawn pickup) { if (currentWeapon == primaryWeapon) { primaryWeapon = null; } else { secondaryWeapon = null; } Destroy(currentWeapon); currentWeapon = null; { GameObject temp = Instantiate(pickup.GetComponent <PickupGun> ().gun, transform); currentWeapon = temp.GetComponent <Base_Weapon> (); } if (primaryWeapon == null) { primaryWeapon = currentWeapon; } else { secondaryWeapon = currentWeapon; } currentWeapon.GetComponent <PlayerTag>().SetId(GetPlayerTag().Id); currentWeapon.GetComponent <PlayerTag>().SetTeam(GetPlayerTag().Team); UpdateAmmoUI(currentWeapon.Ammo, currentWeapon.MaxAmmo, !currentWeapon.HasUnlimitedAmmo); pickup.StartRespawnTimer(); }
void PickUpAmmo(PickupRespawn pickup) { int extraAmmo = pickup.GetComponent <AmmoPickup> ().Value; Base_Weapon ammoWeapon = currentWeapon; // if lemon -- refill secondary : if weapon is full, return, else fill. if (currentWeapon.HasUnlimitedAmmo) { ammoWeapon = (currentWeapon == primaryWeapon ? secondaryWeapon : primaryWeapon); } if (ammoWeapon.IsFull) { return; } ammoWeapon.AddAmmo(extraAmmo); if (playerUI != null) { playerUI.UpdateAmmoCounter(currentWeapon.Ammo, currentWeapon.MaxAmmo); } pickup.StartRespawnTimer(); }
void OnTriggerEnter2D(Collider2D other) { PickupRespawn pickup = other.GetComponent <PickupRespawn> (); if (pickup != null && pickup.active) { GameObject temp = Instantiate(brainMobPrefab, transform.position, Quaternion.identity) as GameObject; Mob_Skeel skeel = temp.GetComponent <Mob_Skeel> (); skeel.Ini(null, playerTag.Id, playerTag.Team, true); pickup.StartRespawnTimer(); } }
void OnTriggerEnter2D(Collider2D other) { if (GetComponent <PlayerController>().IsJuggernaut) { return; } if (other.tag == "EnemyPickup") { if (CheckForPanko()) { return; } if (enemy_count >= enemyMax) { return; } PickupRespawn pickupRespawn = other.GetComponent <PickupRespawn> (); if (!pickupRespawn.active) { return; } EnemyPickup pickup = other.GetComponent <EnemyPickup> (); pickupRespawn.StartRespawnTimer(); other.GetComponent <CircleCollider2D>().enabled = false; int r = pickup.enemy; if (pickup.random) { r = (int)Random.Range(0f, enemies_prefabs.Length); } if (GameManager.gameMode == GAMEMODE.PVP) { if (r == 0) { GameManager.score += 50f; } else if (r == 1) { GameManager.score += 25f; } else { GameManager.score += 100f; } } GiveEnemy(r); } }
void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent <ArmorPickup> () != null) { PickupRespawn pickup = other.GetComponent <PickupRespawn> (); if (!pickup.active) { return; } armor += other.GetComponent <ArmorPickup> ().Value; if (armor > 1f) { armor = 1f; } pickup.StartRespawnTimer(); playerUI.UpdateHealthUI(health, armor); } }
void OnTriggerEnter2D(Collider2D other) { if (GetComponent <PlayerController> ().IsJuggernaut) { return; } if (GetComponent <PlayerEnemyHandler> ().CheckForPanko()) { return; } PickupRespawn pickupRespawn = other.GetComponent <PickupRespawn> (); if (pickupRespawn == null) { return; } if (!pickupRespawn.active) { return; } Powerup otherPowerup = other.GetComponent <Powerup> (); if (otherPowerup == null) { return; } { Powerup currentPowerup = GetComponent <Powerup> (); if (currentPowerup != null) { if (currentPowerup.CanStack) { if (!otherPowerup.CanStack) { return; } } else { return; } } } Powerup thisPowerup = null; switch (otherPowerup.type) { case POWERUP_TYPE.DAMAGE: thisPowerup = gameObject.AddComponent <Powerup_Damage> (); break; case POWERUP_TYPE.SPEED: thisPowerup = gameObject.AddComponent <Powerup_Movement> (); break; case POWERUP_TYPE.HEALTH: thisPowerup = gameObject.AddComponent <Powerup_Health> (); break; } if (thisPowerup == null) { return; } thisPowerup.Copy(otherPowerup); StartCoroutine(UsePowerup(thisPowerup)); pickupRespawn.StartRespawnTimer(); }
void OnTriggerStay2D(Collider2D other) { if (type == 2) // PINKO PANKO { if (other.tag == "EnemyPickup" || other.tag == "Powerup") { PickupRespawn otherPickup = other.GetComponent <PickupRespawn> (); if (!otherPickup.active) { return; } otherPickup.StartRespawnTimer(); GameObject temp = Instantiate(brainProjectilePrefab, transform.position, Quaternion.identity); EnemyScript projectileScript = temp.GetComponent <EnemyScript> (); temp.GetComponentInChildren <SpriteRenderer> ().color = GetComponent <SpriteRenderer> ().color; // SETUP projectileScript.id = id; projectileScript.hp = 50f; projectileScript.hp_max = 50f; projectileScript.playerObject = null; // SET TO CHASE. projectileScript.team = team; Color col = Color.white; if (id == 1) { col = Color.blue; } else if (id == 2) { col = Color.yellow; } else if (id == 3) { col = Color.red; } else if (id == 4) { col = Color.magenta; } projectileScript.outlineSprite.color = col; GameObject[] temp2 = GameObject.FindGameObjectsWithTag("Player"); // Ignore player colilsion for (int i = 0; i < temp2.Length; i++) { MovementScript playerMov = temp2 [i].GetComponent <MovementScript> (); if (playerMov.player_num == id) { Physics2D.IgnoreCollision(temp2[i].GetComponent <CapsuleCollider2D>(), projectileScript.GetComponent <CircleCollider2D>()); } } } } else if (can_hit) // Everything Else { EnemyScript enemy = other.GetComponent <EnemyScript> (); if (enemy == null) { return; } if (team != 0 && enemy.team == team) { return; } if (enemy.id != id) { float damage; if (type == 0) { damage = 10f; enemy.hp -= 10f; } else { damage = 75f; enemy.hp -= 75f; // TANKS DO DAMAGE VS MOBS } enemy.CreateNumber(enemy.transform.position, damage.ToString(), new Color(1f, .9f, .9f), .1f, 120f, 2f); enemy.StartCoroutine(enemy.FlashRoutine()); enemy.particleSystems[1].Play(); enemy.audioManager.Play(0); } StartCoroutine(HitRoutine()); } }