/// <summary> /// Take out clip, then put new one /// </summary> /// <param name="clip">New clip to put</param> /// <returns>Old clip which was taken out</returns> public GunClip Reload(GunClip clip) { GunClip res = TakeOutClip(); PutClip(clip); return(res); }
/// <summary> /// Take clip out from gun /// </summary> /// <returns>Old clip</returns> public GunClip TakeOutClip() { var res = gunClip; OnClipTakeOut?.Invoke(this, res); gunClip = null; return(res); }
/// <summary> /// Put compatible clip to gun /// </summary> /// <param name="clip">New clip to put</param> /// <returns>Was it put successfully?</returns> public bool PutClip(GunClip clip) { var res = false; if (CompatibleClips.Contains(clip.ToString())) { this.gunClip = clip; clip.OnBulletNumChange += Clip_OnBulletNumChange; res = true; } OnClipPutIn?.Invoke(this, res); return(res); }
/// <summary> /// Update how many bullets left in clip /// </summary> private void Clip_OnBulletNumChange(GunClip clip, int bulletNum) { OnBulletNumChange?.Invoke(this, bulletNum); }