Example #1
0
    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;
        }
    }
Example #2
0
 protected void Shoot()
 {
     if (HasWeapons)
     {
         CurrentWeapon.Shoot(_body.Position + Vector2.Normalize(_locationToFace - _body.Position) * (EntitySize / 1.5f), _locationToFace - _body.Position);
     }
 }
Example #3
0
    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();
     }
 }
Example #5
0
 //hand off the reloading/shooting stuff to the currently equipped weapon
 protected void Reload()
 {
     if (HasWeapons)
     {
         CurrentWeapon.Reload();
     }
 }
Example #6
0
 // 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();
     }
 }
Example #10
0
        /// <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);
            }
        }
Example #11
0
        /// <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();
        }
Example #12
0
 /// <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);
        }
Example #14
0
    private IEnumerator Reloading()
    {
        CurrentWeapon.ReloadWeapon(this, _animation);
        yield return(new WaitForSeconds(CurrentWeapon.ReloadSpeed * _agent.Stats.ReloadSpeed));

        _weaponReload = null;
    }
Example #15
0
    /*
     * 손에 든 무기를 교체한다
     */
    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);
 }
Example #17
0
 private void SetCurrentWeaponGameObject()
 {
     foreach (Weapon weapon in Weapons.Values)
     {
         weapon.gameObject.SetActive(weapon.ModelType == CurrentWeaponModel);
     }
     CurrentWeapon.Show();
 }
Example #18
0
 /*
  * Determines if the player can reload the weapon.
  */
 public bool CanReload()
 {
     if (CurrentWeapon == null)
     {
         return(false);
     }
     return(CurrentWeapon.CanReload());
 }
Example #19
0
 // 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();
 }
Example #21
0
 // Use this for initialization
 void Start()
 {
     timeSinceSwing = rateOfFire;
     audio          = GetComponent <AudioSource>();
     wep            = GetComponent <CurrentWeapon> ();
     swinging       = false;
     swingTime      = 0;
 }
Example #22
0
 public void StopWeapon()
 {
     if (CurrentWeapon == null)
     {
         return;
     }
     CurrentWeapon.StopWeapon();
 }
Example #23
0
        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;
            }
        }
Example #24
0
        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);
        }
Example #25
0
 private void Update()
 {
     CurrentCooldown += Time.deltaTime;
     if (CurrentCooldown > CurrentWeapon.Cooldown)
     {
         CurrentWeapon.SpawnBullets(GunPosition, transform.forward, GetComponent <Collider>());
         CurrentCooldown = 0f;
     }
 }
Example #26
0
        public void Shoot()
        {
            if (!CurrentWeapon)
            {
                return;
            }

            CurrentWeapon.Use();
        }
Example #27
0
    public int GetСurrentWeaponId()
    {
        if (CurrentWeapon == null)
        {
            return(0);
        }

        return(CurrentWeapon.GetItem().GetId());
    }
Example #28
0
        public void Reload()
        {
            if (!CurrentWeapon)
            {
                return;
            }

            CurrentWeapon.ReloadWeapon();
        }
Example #29
0
        public void StopReloading()
        {
            if (!CurrentWeapon)
            {
                return;
            }

            CurrentWeapon.InterruptReloading();
        }
Example #30
0
    // Reload Weapon
    public void Reload()
    {
        if (CurrentWeapon == null)
        {
            return;
        }

        CurrentWeapon.Reload();
        UpdateWeaponUI();
    }