public void ChangeWeapon(int i) { switch (i) { case 1: { Debug.LogWarning("Medium!"); currentWeapon = CurrentWeapon.medium; } break; case 2: { Debug.LogWarning("Heavy!"); currentWeapon = CurrentWeapon.heavy; } break; case 3: { Debug.LogWarning("Rockets!"); currentWeapon = CurrentWeapon.rockets; } break; case 4: { Debug.LogWarning("light!"); currentWeapon = CurrentWeapon.light; } break; case 5: { Debug.LogWarning("light!"); currentWeapon = CurrentWeapon.light; } break; } }
protected void Shoot() { if (HasWeapons) { CurrentWeapon.Shoot(_body.Position + Vector2.Normalize(_locationToFace - _body.Position) * (EntitySize / 1.5f), _locationToFace - _body.Position); } }
IEnumerator WeaponFire() { CurrentWeapon.UseWeapon(this, _animation, _launcher); yield return(new WaitForSeconds(CurrentWeapon.FireRate * _agent.Stats.FireRate)); _weaponFire = null; }
/// <summary> /// Toggle the firing selector /// </summary> void toggleFiringSelector() { if (InputToggleFiring.GetButtonPressed) { CurrentWeapon.ToggleFireSelector(); } }
//hand off the reloading/shooting stuff to the currently equipped weapon protected void Reload() { if (HasWeapons) { CurrentWeapon.Reload(); } }
// Use this for initialization void Start() { pickupRadius = 1; player = FindObjectOfType <MvmtBody> (); playerWeapon = FindObjectOfType <CurrentWeapon> (); thisStats = GetComponent <ThisWeapon> (); }
/// <summary> /// 设置武器喷漆颜色 /// </summary> /// <param name="color"></param> public void SetWeaponInkColor(Color color, int id = 0) { WeaponColor = color; if (CurrentWeapon == null) { ////test.....test// //GameManager.Instance.CurWeapon = 1000; //ConfiguringCurrentProPerities(1000); ////else.... int WeaponId = id; if (0 == id) { WeaponId = GameManager.Instance.CurWeapon; } ConfiguringCurrentProPerities(WeaponId); ChangeWeaponMeshRender(CurrentWeapon.WeaponProperty.WeaponName); //Debug.Log("GameManager.Instance.CurWeapon:::"+ GameManager.Instance.CurWeapon + // ",,urrentWeapon.WeaponProperty.WeaponName::" + CurrentWeapon.WeaponProperty.WeaponName + // ",,CurrentWeapon.WeaponProperty.BulletId::" + CurrentWeapon.WeaponProperty.BulletId); } else { CurrentWeapon.SetWeaponColor(color); } }
void Update() { if (!Loader.HasLoaded) { return; } //this.UpdateWeaponTransform (); if (CurrentWeapon != null) { CurrentWeapon.EnableOrDisableGunFlash(); CurrentWeapon.UpdateGunFlashRotation(); } // reload weapon ammo clip if (CurrentWeapon != null) { if (CurrentWeapon.AmmoClipSize > 0 && CurrentWeapon.AmmoInClip <= 0) { int amountToRefill = Mathf.Min(CurrentWeapon.AmmoClipSize, CurrentWeapon.AmmoOutsideOfClip); CurrentWeapon.AmmoInClip = amountToRefill; CurrentWeapon.AmmoOutsideOfClip -= amountToRefill; } } }
public void Fire() { if (!IsAnimating && CurrentWeapon != null) { CurrentWeapon.Fire(); } }
/// <summary> /// Draws player and weapons /// </summary> /// <param name="sb"></param> public override void Draw(SpriteBatch sb) { // If the player is not a spectator and isn't dead if (CurrentTeam != ServerClientInterface.Team.Spectator && State != ServerClientInterface.PlayerState.Dead) { if (CurrentTeam == ServerClientInterface.Team.CounterTerrorist) { sb.Draw(Assets.CTTexture, position, new Rectangle(0, 0, 32, 32), Color.White, 1.57f + rotation, new Vector2(16, 16), 1f, SpriteEffects.None, 0); } else { sb.Draw(Assets.TTexture, position, new Rectangle(0, 0, 32, 32), Color.White, 1.57f + rotation, new Vector2(16, 16), 1f, SpriteEffects.None, 0); } // Draw their name sb.DrawString(Assets.DefaultFont, UserName, new Vector2(position.X, position.Y - 50), CurrentTeam == ServerClientInterface.Team.CounterTerrorist ? Color.Blue : Color.Red); // Draws the weapon CurrentWeapon.Draw(sb); debrisEmitter.Draw(sb, Assets.DebrisParticle); } }
/// <summary> /// Causes the character to stop shooting /// </summary> public virtual void ShootStop() { // if the Shoot action is enabled in the permissions, we continue, if not we do nothing if (CurrentWeapon == null) { return; } if (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponIdle) { return; } if ((CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponReload) || (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponReloadStart) || (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponReloadStop)) { return; } if ((CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBeforeUse) && (!CurrentWeapon.DelayBeforeUseReleaseInterruption)) { return; } if ((CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBetweenUses) && (!CurrentWeapon.TimeBetweenUsesReleaseInterruption)) { return; } CurrentWeapon.TurnWeaponOff(); }
/// <summary> /// Reloads the weapon /// </summary> protected virtual void Reload() { if (CurrentWeapon != null) { CurrentWeapon.InitiateReloadWeapon(); } }
public override void Update(GameTime gameTime) { LastPosition = NewPosition; LastBottomVertex = BottomVertex; LastUpVertex = UpVertex; var elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds; ProcessKeyboard(elapsedTime); this.Camera.Update(gameTime); //Les saco el componente Y para que no se mueva verticalmente FrontDirection = Vector3.Normalize(Camera.FrontDirection * new Vector3(1, 0, 1)); RightDirection = Vector3.Normalize(Camera.RightDirection * new Vector3(1, 0, 1)); UpDirection = Vector3.Normalize(Camera.UpDirection); CalculateView(); Camera.Position = NewPosition + CameraCorrection; if (explosion_happening) { explosionEffect(Camera, gameTime, RightDirection); } //UpdatePlayerVectors(); BottomVertex = NewPosition - HitboxSize; UpVertex = NewPosition + HitboxSize; CurrentWeapon.Update(gameTime, Camera.FrontDirection, Camera.Position); }
private IEnumerator Reloading() { CurrentWeapon.ReloadWeapon(this, _animation); yield return(new WaitForSeconds(CurrentWeapon.ReloadSpeed * _agent.Stats.ReloadSpeed)); _weaponReload = null; }
/* * 손에 든 무기를 교체한다 */ void WeaponChange() { if (cw == CurrentWeapon.hand) { if (GetSword) { cw = CurrentWeapon.sword; } else if (GetHammer) { cw = CurrentWeapon.hammer; } } else if (cw == CurrentWeapon.sword) { if (GetHammer) { cw = CurrentWeapon.hammer; } else { cw = CurrentWeapon.hand; } } else if (cw == CurrentWeapon.hammer) { cw = CurrentWeapon.hand; } if (cw == CurrentWeapon.hand) { Inventory[0].SetActive(true); Inventory[1].SetActive(false); Inventory[2].SetActive(false); Weapon = Inventory[0]; } if (cw == CurrentWeapon.sword) { Inventory[0].SetActive(false); Inventory[1].SetActive(true); Inventory[2].SetActive(false); Weapon = Inventory[1]; } if (cw == CurrentWeapon.hammer) { Inventory[0].SetActive(false); Inventory[1].SetActive(false); Inventory[2].SetActive(true); Weapon = Inventory[2]; } Debug.Log(cw); }
//获取当前武器上的属性脚本 public GunAtt GetCurrentWeaponScript() { if (CurrentWeapon) { return(CurrentWeapon.GetComponent <GunAtt>()); } return(null); }
private void SetCurrentWeaponGameObject() { foreach (Weapon weapon in Weapons.Values) { weapon.gameObject.SetActive(weapon.ModelType == CurrentWeaponModel); } CurrentWeapon.Show(); }
/* * Determines if the player can reload the weapon. */ public bool CanReload() { if (CurrentWeapon == null) { return(false); } return(CurrentWeapon.CanReload()); }
// Equip the weapon we Specify public void EquipWeapon(Weapon weapon, Transform weaponPosition) { CurrentWeapon = Instantiate(weapon, weaponPosition.position, weaponPosition.rotation); CurrentWeapon.transform.parent = weaponPosition; CurrentWeapon.SetOwner(character); WeaponAim = CurrentWeapon.GetComponent <WeaponAim>(); UpdateWeaponUI(); }
public void Shoot() { if (IsDead) { return; } CurrentWeapon.Shoot(); }
// Use this for initialization void Start() { timeSinceSwing = rateOfFire; audio = GetComponent <AudioSource>(); wep = GetComponent <CurrentWeapon> (); swinging = false; swingTime = 0; }
public void StopWeapon() { if (CurrentWeapon == null) { return; } CurrentWeapon.StopWeapon(); }
void Update() { if (!Loader.HasLoaded) { return; } // switch weapons if (GameManager.CanPlayerReadInput()) { if (Input.GetKeyDown(KeyCode.Q)) { this.SwitchWeapon(false); } else if (Input.GetKeyDown(KeyCode.E)) { this.SwitchWeapon(true); } } this.UpdateWeaponTransform(); if (CurrentWeapon != null) { CurrentWeapon.EnableOrDisableGunFlash(m_player); CurrentWeapon.UpdateGunFlashRotation(m_player); } // update aiming state if (this.IsAiming) { // check if we should exit aiming state if (!this.IsHoldingWeapon || m_player.IsInVehicle || !this.IsAimOn) { if (!this.IsFiring) { this.IsAiming = false; } } } else { // check if we should enter aiming state if (this.IsHoldingWeapon && this.IsAimOn && !m_player.IsInVehicle) { this.IsAiming = true; } } // update firing state if (!this.IsAiming) { this.IsFiring = false; } }
public void Test_CreateCurrentWeapon() { var player = new StubPlayer(); player.Components.Add(new SolidBody(player)); player.Components.Add(new Collector(player)); player.Setup(); CurrentWeapon currentWeapon = new CurrentWeapon(player); }
private void Update() { CurrentCooldown += Time.deltaTime; if (CurrentCooldown > CurrentWeapon.Cooldown) { CurrentWeapon.SpawnBullets(GunPosition, transform.forward, GetComponent <Collider>()); CurrentCooldown = 0f; } }
public void Shoot() { if (!CurrentWeapon) { return; } CurrentWeapon.Use(); }
public int GetСurrentWeaponId() { if (CurrentWeapon == null) { return(0); } return(CurrentWeapon.GetItem().GetId()); }
public void Reload() { if (!CurrentWeapon) { return; } CurrentWeapon.ReloadWeapon(); }
public void StopReloading() { if (!CurrentWeapon) { return; } CurrentWeapon.InterruptReloading(); }
// Reload Weapon public void Reload() { if (CurrentWeapon == null) { return; } CurrentWeapon.Reload(); UpdateWeaponUI(); }