示例#1
0
        public override void Execute(StateManager state)
        {
            RuntimeWeapon t_weapon = state.inventory.curWeapon;

            Ammo            t_ammo    = t_weapon.ammoType;
            AmmoInInventory t_invAmmo = null;

            for (int i = 0; i < state.inventory.ammos.Count; i++)
            {
                if (state.inventory.ammos[i].ammoType == t_ammo)
                {
                    t_invAmmo = state.inventory.ammos[i];
                    break;
                }
            }

            int amount_To_Reload = t_invAmmo.amount >= t_weapon.magazineBullets - t_weapon.currentBullets ? t_weapon.magazineBullets - t_weapon.currentBullets : t_invAmmo.amount;

            state.animHook.PlayReloadAnim();
            state.inventory.curWeapon.weaponHook.Reload();

            t_invAmmo.amount        -= amount_To_Reload;
            t_weapon.currentBullets += amount_To_Reload;

            if (t_weapon.currentBullets > t_weapon.magazineBullets)
            {
                Debug.Log(t_weapon.weaponInstance.name + " has more bullets than is allowed in its' magazine!");
            }
        }
示例#2
0
        public override bool CheckCondition(StateManager state)
        {
            bool retVal = false;

            RuntimeWeapon   t_weapon  = state.inventory.curWeapon;
            Ammo            t_ammo    = t_weapon.ammoType;
            AmmoInInventory t_invAmmo = null;

            switch (state.type)
            {
            case StateManagerType.player:
                if (state.wantsToReload)
                {
                    for (int i = 0; i < state.inventory.ammos.Count; i++)
                    {
                        if (state.inventory.ammos[i].ammoType == t_ammo)
                        {
                            t_invAmmo = state.inventory.ammos[i];
                            break;
                        }
                    }

                    if (t_invAmmo.amount > 0 && t_weapon.currentBullets < t_weapon.magazineBullets)
                    {
                        retVal = true;
                    }
                }
                break;

            case StateManagerType.guard:

                for (int i = 0; i < state.inventory.ammos.Count; i++)
                {
                    if (state.inventory.ammos[i].ammoType == t_ammo)
                    {
                        t_invAmmo = state.inventory.ammos[i];
                        break;
                    }
                }

                if (t_invAmmo.amount > 0 && t_weapon.currentBullets == 0)
                {
                    retVal = true;
                }
                break;

            default:
                break;
            }



            return(retVal);
        }