12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class HomingCondomWeapon : Weapon
- {
- public PoolObject homingCondomPrefab;
- public int homingAmmo;
- private int _homingAmmoLeft;
- private Pool _homingCondomPool;
- public override void Arm()
- {
- base.Arm();
- _homingCondomPool = Pool.Get(homingCondomPrefab);
- _homingAmmoLeft = homingAmmo;
- NotificationCenter.Post(NotificationType.UpdateWeaponUpgradeAmmoLeft, _homingAmmoLeft);
- NotificationCenter.AddListener(OnVirusSpawned, NotificationType.VirusSpawned);
- }
- public override void Disarm()
- {
- base.Disarm();
- NotificationCenter.RemoveListener(OnVirusSpawned, NotificationType.VirusSpawned);
- }
- void OnVirusSpawned(Notification note)
- {
- Virus virus = (Virus)note.data;
- PoolObject homingCondom = _homingCondomPool.Spawn();
- homingCondom.GetComponent<HomingCondom>().target = virus.transform;
- NotificationCenter.Post(NotificationType.FireIndependently, homingCondom);
- --_homingAmmoLeft;
- NotificationCenter.Post(NotificationType.UpdateWeaponUpgradeAmmoLeft, _homingAmmoLeft);
- }
- public override bool IsEmpty
- {
- get
- {
- return _homingAmmoLeft <= 0;
- }
- }
- }
|