public void Fire()
 {
     if (_wielded != null)
     {
         _wielded.Fire();
     }
 }
Ejemplo n.º 2
0
 public void Secondary()
 {
     if (_secondaryWeapon != null)
     {
         _secondaryWeapon.Fire();
     }
 }
Ejemplo n.º 3
0
        public void Execute()
        {
            if (_weapon != null && _target != null)
            {
                Report("Target in sight, preparing to fire...");
                _weapon.PointAt(_target);

                while (!_target.IsDown && _weapon.AmmoLeft)
                {
                    Report("Firing shot...");
                    _weapon.Fire();
                }

                if (!_target.IsDown)
                {
                    Report("I'm out of ammo!!");
                    _missionStatus = MissionStatus.Failed;
                }
                else
                {
                    Report("Target down!!");
                    _missionStatus = MissionStatus.Success;
                }
            }
            else
            {
                Report("I was not prepared for this mission!!");
                _missionStatus = MissionStatus.Failed;
            }
        }
Ejemplo n.º 4
0
        public void Update(double elapsedTime)
        {
            if (_weapon.Ready(elapsedTime))
            {
                _weapon.Fire(_sprite.GetPosition(), _playerCharacter.GetPosition());
            }

            if (Path != null)
            {
                Path.UpdatePosition(elapsedTime, this);
            }

            // Set hit color
            //if (_hitFlashCountDown != 0)
            //{
            //    _hitFlashCountDown = Math.Max(0, _hitFlashCountDown - elapsedTime);
            //    double scaledTime = 1 - (_hitFlashCountDown / HitFlashTime);
            //    _sprite.SetColor(new PotatoEngine.Color(1, 0, (float)scaledTime, 1));
            //}
            //else if (Health < InitHealth)
            //{
            //    _sprite.SetColor(new PotatoEngine.Color(1, 1, 0, 1));
            //}

            _sprite.Update(elapsedTime);
            _sprite.SetScale(Scale, Scale);
        }
Ejemplo n.º 5
0
 public void Primary()
 {
     if (_primaryWeapon != null)
     {
         _primaryWeapon.Fire();
     }
 }
 public void Attack()
 {
     if (selectedWeapon.IsReady)
     {
         selectedWeapon.Fire();
     }
 }
Ejemplo n.º 7
0
 // Update is called once per frame
 void Update()
 {
     if (targetTransform != null)
     {
         if ((transform.position - targetTransform.position).magnitude < detectRadius)
         {
             foreach (GameObject weapon in weapons)
             {
                 IWeapon weaponInterface = weapon.GetComponent <IWeapon>();
                 if (weaponInterface != null)
                 {
                     weaponInterface.RotateToTarget(targetTransform);
                     weaponInterface.Fire(targetTransform);
                 }
             }
         }
     }
     else
     {
         GameObject player = GameObject.FindGameObjectWithTag(LayersAndTags.PLAYER_TAG);
         if (player != null)
         {
             targetTransform = player.transform;
         }
     }
 }
Ejemplo n.º 8
0
 // Update is called once per frame
 void Update()
 {
     if ((Input.GetKey(KeyCode.M) || Input.GetKey(KeyCode.Z)) && fireableWeapon != null)
     {
         fireableWeapon.Fire("Player-Fireball");
     }
 }
Ejemplo n.º 9
0
 public void Attack(ICharacter target)
 {
     mWeapon.Fire(target.Position);
     mGameObject.transform.LookAt(target.Position);      // 朝向目标位置
     PlayAnim("attack");
     target.UnderAttack(mWeapon.Atk + mAttr.CritValue);
 }
Ejemplo n.º 10
0
    // Update is called once per frame
    void Update()
    {
        fireRateTimer += Time.deltaTime;
        possessTimer  += Time.deltaTime;
        rotateTimer   += Time.deltaTime;

        if (Health != 0 && movingEnemy && movingEnabled && target != null)
        {
            Move();
        }
        if (Health <= 0)
        {
            possessTimer += Time.deltaTime;

            if (possessTimer > 2)
            {
                ToggleOutline();
                possessTimer = 0;
            }
        }
        if (fireRateTimer > attemptFirerate && movingEnabled && fireableWeapon != null)
        {
            fireableWeapon.Fire("Enemy-Fireball");
            fireRateTimer = 0;
        }

        if (!movingEnemy && rotateTimer > 3 && Health > 0)
        {
            //face the player
            Vector3 tVector = target.position - transform.position;
            tVector.y          = 0;
            transform.rotation = Quaternion.LookRotation(tVector);
            rotateTimer        = 0;
        }
    }
Ejemplo n.º 11
0
    // Update is called once per frame
    // Fix framerate nuke eventually
    void Update()
    {
        if (decay > heat)
        {
            heat = 0.0f;
        }
        else
        {
            heat -= (decay + Time.deltaTime);
        }


        if (firing)
        {
            current_weapon_firerate = CurrentWeapon.GetFireRate();
            current_weapon_heatrate = CurrentWeapon.GetHeatRate();

            fire_timer += Time.deltaTime;
            if (fire_timer > current_weapon_firerate)
            {
                CurrentWeapon.Fire();
                heat      += current_weapon_heatrate;
                fire_timer = 0;
            }
        }
        else
        {
        }
    }
Ejemplo n.º 12
0
 public void Attack(ICharacter targetCharacter)
 {
     mWeapon.Fire(targetCharacter.position);
     //角色朝向攻击方向
     mGameObject.transform.LookAt(targetCharacter.position);
     PlayAnim("attack");
     targetCharacter.UnderAttack(mWeapon.atk + mAttr.critValue);
 }
Ejemplo n.º 13
0
    //攻击目标
    public void Attack(ICharacter theTarget)////后面的注释是改代码之前的注释====由子类去实现自己的攻击函数,调用WeaponAttackTarget(ICharacter Target)来攻击敌人
    {
        //设置额外攻击力
        m_Weapon.SetAtkPlusValue(m_Attribute.GetAtkPlusValue());

        //使用武器攻击目标
        m_Weapon.Fire(theTarget);
    }
Ejemplo n.º 14
0
 private void FireWeapon()
 {
     if (fireableWeapon != null)
     {
         fireableWeapon.Fire("Player-Fireball");
     }
     // TODO
 }
Ejemplo n.º 15
0
 public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination)
 {
     if (_module.Fire(rayEnlonged, destination) == true)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 16
0
 public virtual void Attack()
 {
     Debug.Log(m_Name + " Attack");
     if (m_Weapon != null)
     {
         m_Weapon.Fire();
     }
 }
Ejemplo n.º 17
0
    public virtual void Attack(IEntity target)
    {
        //设置武器攻击值
        m_weapon.attackValue = m_attribute.CalcAttackVal();

        //攻击目标
        m_weapon.Fire(target);
    }
Ejemplo n.º 18
0
        public static void FireRightWeapon()
        {
            _rightWeapon = ActiveRightWeapons.OfType <IWeapon>().FirstOrDefault();

            if (_rightWeapon != null)
            {
                _rightWeapon.Fire();
            }
        }
Ejemplo n.º 19
0
    // Update is called once per frame
    void Update()
    {
        // Add the time since Update was last called to the timer.
        timer += Time.deltaTime;
        bool attack  = Input.GetButton("Fire1") && (!craftmenu.activeSelf);
        bool canFire = (_equipmentManager.CanFire() && currentWeapon.IsAmmoNeeded());

        if (!attack || !canFire)
        {
            anim.SetBool("attack", false);
        }

        // If the Fire1 button is being press and it's time to fire...
        if (isLocalPlayer && canFire && attack && timer >= currentWeapon.getTimeBetweenBullet())
        {
            // ... shoot the gun  and start animation
            anim.SetBool("attack", true);
            //isAnimationWorking = true;
            if (anim.GetLayerWeight(currentWeapon.GetLayerNumber()) != 1.0f)  // if not active yet

            {
                Debug.LogError("Je passe ici");
                resetWeight();
                anim.SetLayerWeight(currentWeapon.GetLayerNumber(), 1.0f);
            }
            isShooting = true;
            currentWeapon.SetCanHit(isShooting);
        }
        else if (attack && !canFire)
        {
            Debug.LogError("Not enough ammo!");
            playerInfo.DisplayMessage("error", "Pas assez de munitions.");
        }

        if (anim.GetCurrentAnimatorStateInfo(currentWeapon.GetLayerNumber()).IsName(currentWeapon.GetLayerName()) && anim.GetCurrentAnimatorStateInfo(currentWeapon.GetLayerNumber()).normalizedTime > currentWeapon.GetFiringTime() && isShooting && canFire) // Firing during the animation
        {
            timer = 0f;
            float angle = AimCone.GetAngle(Statistics, PlayerMovement.GetSpeed() / 3) / 2;
            currentWeapon.Fire(angle);
            isShooting = false;
            _equipmentManager.RemoveAmmo();
        }

        /* if(anim.GetCurrentAnimatorStateInfo(currentWeapon.GetLayerNumber()).IsName(currentWeapon.GetLayerName()) && anim.GetCurrentAnimatorStateInfo(currentWeapon.GetLayerNumber()).normalizedTime > .99f && isAnimationWorking ) // reset timer when animation is finished
         * {
         *   isAnimationWorking = false;
         *   timer = 0f;
         * }*/

        if (timer >= currentWeapon.getTimeBetweenBullet() * currentWeapon.getEffectsDisplayTime())
        {
            // ... disable the effects.
            currentWeapon.DisableEffects();
        }
    }
Ejemplo n.º 20
0
 public void Fire()
 {
     if (_unlockWeapon.IsUnlock)
     {
         _weapon.Fire();
     }
     else
     {
         Debug.Log("Weapon is Lock");
     }
 }
 public void Fire()
 {
     if (_elapsedTime >= cooldown)
     {
         foreach (GameObject l in lasers)
         {
             IWeapon w = l.GetComponent <MonoBehaviour>() as IWeapon;
             w.Fire();
         }
         _elapsedTime = 0f;
     }
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 攻击
 /// </summary>
 /// <param name="target"></param>
 public void Attack(ICharacter target)
 {
     if (mWeapon == null)
     {
         DebugMy.Log("No weapone", this);
         return;
     }
     mWeapon.Fire(target.position);
     PlayAnim("attack");
     mContent.transform.LookAt(target.position);
     target.UnderAttack(mWeapon.atk + mAttr.critValue);
 }
Ejemplo n.º 23
0
    public void Attack(ICharacter target)
    {
        if (mWapon != null)
        {
            mWapon.Fire(target.position);

            //调整朝向
            mGameObject.transform.LookAt(target.position);
            PlayAnimation("attack");
            target.UnderAttack(mWapon.atk + mAttr.critValue);
        }
    }
        public void OnFire(InputAction.CallbackContext context)
        {
            if (!context.canceled)
            {
                return;
            }

            if (!_weapon.CanFire())
            {
                return;
            }

            _weapon.Fire(transform.position, _directionCalculator.Direction);
        }
    // Update is called once per frame
    void Update()
    {
        if (fireableWeapon == null)
        {
            return;
        }

        timer += Time.deltaTime;
        if (timer > attemptFirerate)
        {
            fireableWeapon.Fire("Enemy-Fireball");
            timer = 0;
        }
    }
Ejemplo n.º 26
0
        private void Update()
        {
            //weapon testing
            if (Input.GetButton("Fire2"))
            {
                _blasterTest.Fire();
            }

            //This effectively queues up a jump.
            IsJumpDesired = Input.GetButton("Jump");

            ChangeDirectionDesired = Input.GetButton("Fire1");
            GetComponent <Renderer>().material.color = StickyGrounded ? Color.white : Color.red;
        }
Ejemplo n.º 27
0
 public bool Play()
 {
     if (_curWeapon.Fire())
     {
         _heroCtrl.Player.Rigidbody.AddForce(-_heroCtrl.Player.transform.forward * _curWeapon.Config.Recoil);
         if (_heroCtrl.IsOnGround && _heroCtrl.fireDustEffect)
         {
             GameObject _temGo = UnityEngine.Object.Instantiate(_heroCtrl.fireDustEffect);
             _temGo.transform.SetParent(GameManager.Instance.EffectGoRoot);
             _temGo.transform.position = _heroCtrl.footPos.position;
         }
         _heroCtrl.handAnimator.SetTrigger("Fire");
         return(true);
     }
     return(false);
 }
Ejemplo n.º 28
0
    void Update()
    {
        horz = Input.GetAxis("Horizontal");
        vert = Input.GetAxis("Vertical");

        if (Input.GetButtonDown("Jump") && curDashCooldown <= 0 && !dashing)
        {
            dashStart = true;
        }
        else if (Input.GetButtonDown("Fire1"))
        {
            weapon.Fire();
        }

        cursorPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    }
Ejemplo n.º 29
0
        public void Fire()
        {
            _weapon.Fire();

            var msg = _element switch
            {
                Elements.Fire => $"Enemy is now burning for {_weapon.Damage / 9.4:0.###} damage per second.",
                Elements.Electricity => "Enemy is now stunned.",
                Elements.Toxin => $"Enemy is now taking DoT damage for {_weapon.Damage / 6.7:0.###} damage per second.",
                Elements.Cold => "Enemy is now frozen.",
                _ => throw new ArgumentOutOfRangeException()
            };

            Console.WriteLine(msg);
        }
    }
Ejemplo n.º 30
0
 void Update()
 {
     if (SWITCH_BTN_HELD)
     {
         if (weapon.equals(w1))
         {
             SetWeapon(w2);
         }
         if (weapon.equals(w2))
         {
             SetWeapon(w1);
         }
     }
     if (FIRE_BTN_HELD)
     {
         weapon.Fire();
     }
 }