コード例 #1
0
ファイル: Gun.cs プロジェクト: vrtex/Astro-Monkey
        public void ChangeAmmo(bool moveUp)
        {
            if (ammoClips.Count == 0)
            {
                return;
            }
            if (delayLeft > 0)
            {
                return;
            }
            currentClipIndex += moveUp ? 1 : -1;
            currentClipIndex  = currentClipIndex % ammoClips.Count;
            while (currentClipIndex < 0)
            {
                currentClipIndex += ammoClips.Count;
            }

            if (currentClip != null)
            {
                currentClip.OnReload -= ReloadHandler;
            }

            currentClip = ammoClips[currentClipIndex];
            if (currentClip.GetAmmoInfo().loaded == 0)
            {
                currentClip.StartReload();
            }
            OnWeaponChange?.Invoke(this);
            currentClip.OnReload += ReloadHandler;
        }
コード例 #2
0
        private void ChangeWeapon(int index)
        {
            _weapons[_currentWeaponIndex].gameObject.SetActive(false);
            _weapons[index].gameObject.SetActive(true);

            _currentWeaponIndex = index;
            OnWeaponChange?.Invoke(weaponProfiles[index]);
        }
コード例 #3
0
    public void ChangeWeapons()
    {
        Weapon weapon = weapon2;

        weapon2 = weapon1;
        weapon1 = weapon;
        OnWeaponChange.Invoke();
    }
コード例 #4
0
 public void EquipWeapon(Weapon weapon, int index)
 {
     if (weapons[index] != null)
     {
         UnequipWeapon(index);
     }
     weapons[index] = weapon;
     OnWeaponChange.Invoke();
 }
コード例 #5
0
    public void UnequipWeapon(int index)
    {
        GameObject pickWeapon = Instantiate(pickableWeapon, transform.position, Quaternion.identity);

        pickWeapon.GetComponent <PickableWeapon>().weapon = weapons[index];
        pickWeapon.GetComponent <SpriteRenderer>().sprite = weapons[index].sprite;
        Rigidbody2D rb = pickWeapon.GetComponent <Rigidbody2D>();

        rb.AddForce(Interactable.ThrowForce(), ForceMode2D.Impulse);
        OnWeaponChange.Invoke();
    }
コード例 #6
0
    private void MountWeapon(Weapon weapon)
    {
        if (currentWeapon != null)
        {
            currentWeapon.gameObject.SetActive(false);
        }

        currentWeapon = weapon;
        currentWeapon.gameObject.SetActive(true);
        currentWeapon.transform.SetParent(weaponLocation);
        currentWeapon.transform.localPosition = Vector3.zero;
        currentWeapon.transform.localRotation = Quaternion.identity;

        OnWeaponChange?.Invoke(weapon);
    }
コード例 #7
0
    // --------------------------------------------------------------------------------------------
    // Name	:	AddWeaponItem
    // Desc	:	Adding weapons is actually handled very differently from other
    //			objects. All this function does is record the object we wish
    //			to change to and send out a message to invoke the correct dismount/mount
    //          animations. The ACTUAL pickup is deferred until AssignWeapon function
    //          is called by the Listener.
    // Note :   In DeadEarth the listener is the CharacterManager's which handles syncing
    //          weapon animation.
    // --------------------------------------------------------------------------------------------
    protected bool AddWeaponItem(InventoryItemWeapon inventoryItemWeapon, CollectableWeapon collectableWeapon, bool playAudio)
    {
        // Is the weapon we are about to pick up single handled or two handed weapon
        int mountIndex = (inventoryItemWeapon.weaponType == InventoryWeaponType.SingleHanded) ? 0 : 1;

        // Create a mount info object to describe the weapon and instance data we wish
        // to change to.
        InventoryWeaponMountInfo wmi = new InventoryWeaponMountInfo();

        wmi.Weapon      = inventoryItemWeapon;
        wmi.Condition   = collectableWeapon.condition;
        wmi.InGunRounds = collectableWeapon.rounds;

        // Invoke event so the object in charge of weapon switching and animation (our CharacterManager for example)
        // can set the process of switching in motion.
        OnWeaponChange.Invoke(wmi);

        return(true);
    }
コード例 #8
0
ファイル: Player.cs プロジェクト: shabiyeshimei/HunterPie
 protected virtual void _onWeaponChange()
 {
     OnWeaponChange?.Invoke(this, EventArgs.Empty);
 }
コード例 #9
0
 protected virtual void _OnWeaponChange()
 {
     OnWeaponChange?.Invoke(this, new PartyMemberEventArgs(this));
 }
コード例 #10
0
 /// <summary>
 /// Invoke <see cref="OnWeaponChange"/>
 /// </summary>
 /// <param name="oldWeapon">The weapon that was active before the new one.</param>
 /// <param name="newWeapon">The new weapon being switched to.</param>
 public void WeaponChanged(BaseWeapon oldWeapon, BaseWeapon newWeapon)
 {
     OnWeaponChange?.Invoke(oldWeapon, newWeapon);
 }