コード例 #1
0
    protected virtual void Awake()
    {
        Owner   = GetComponent <AgentHuman>();
        Weapons = new Dictionary <E_WeaponID, WeaponBase>();

        CurrentWeapon = E_WeaponID.None;
    }
コード例 #2
0
    void Update()
    {
        if (null != AttackAction)
        {
            if (AttackAction.IsSuccess() || AttackAction.IsFailed())
            {
                WeaponBase weapon = Weapons[CurrentWeapon];

                if (false == weapon.HasAnyAmmo)
                {
                    mAutoSwitchWeapon = CurrentWeapon;
                }
            }
        }

        if (mAutoSwitchWeapon != E_WeaponID.None)
        {
            if (CurrentWeapon == mAutoSwitchWeapon)
            {
                if (Player.LocalInstance.CanChangeWeapon())
                {
                    WeaponAutoSwitch();
                    mAutoSwitchWeapon = E_WeaponID.None;
                }
            }
            else
            {
                mAutoSwitchWeapon = E_WeaponID.None;
            }
        }
    }
コード例 #3
0
    public void AddWeaponHit(E_WeaponID id)
    {
        if (PlayerData.InventoryList.Weapons.FindIndex(p => p.ID == id) < 0)
        {
            return;
        }

        PPIRoundScore.WeaponStatistics weaponStats;

        try
        {
            weaponStats = Score.WeaponStats[id];
            weaponStats.StatsHits++;
        }
        catch (KeyNotFoundException)
        {
            weaponStats           = new PPIRoundScore.WeaponStatistics();
            weaponStats.StatsHits = 1;
        }

        Score.WeaponStats[id] = weaponStats;
        Score.Hits++;

        // Debug.Log("Weapon hit " + PlayerData.InventoryList.Weapons[index].ToString() +  " " + PlayerData.Stats.Games[gameType].ToString());
    }
コード例 #4
0
    //activate weapon
    public void SwitchWeapons(E_WeaponID weaponType)
    {
        //Debug.Log(Owner.name +  "CW Add to owner, weapon " + weaponType);
        if (Weapons.ContainsKey(weaponType) == false)
        {
            return;
        }

        float busyTime = Weapons[CurrentWeapon].GetBusyTime();

        Weapons[CurrentWeapon].SetDefaultMaterial();
        Weapons[CurrentWeapon].UnlinkFromOwner();

        CurrentWeapon = weaponType;
        Weapons[weaponType].LinkToOwner(Owner, Hand);

        Owner.WorldState.SetWSProperty(E_PropKey.WeaponLoaded, Weapons[weaponType].ClipAmmo > 0);

        if (Owner.GadgetsComponent.IsBoostActive(E_ItemBoosterBehaviour.Invisible))
        {
            float power = Owner.GadgetsComponent.GetActiveBoostPower(E_ItemBoosterBehaviour.Invisible);

            Weapons[weaponType].SetInvisibleMaterial(power);
        }

        Weapons[weaponType].WeaponArm(busyTime);
    }
コード例 #5
0
    protected void ClientSetAmmo(E_WeaponID type, int clipAmmo, int weaponAmmo)
    {
        Weapons[type].SetAmmo(clipAmmo, weaponAmmo);
        Owner.SoundPlay(Player.LocalInstance.SoundTakeAmmo);

        //GuiHUD.Instance.ShowMessageTimed(GuiHUD.WeaponAmmoMessage(type), GuiHUD.InfoMessageTime);
    }
コード例 #6
0
        // USERGUIDEACTION INTERFACE

        protected override bool OnExecute()
        {
            if (base.OnExecute() == false)
            {
                return(false);
            }

            E_WeaponID  weaponID  = ItemType == GuiShop.E_ItemType.Weapon ? (E_WeaponID)ItemId : E_WeaponID.None;
            E_ItemID    itemID    = ItemType == GuiShop.E_ItemType.Item ? (E_ItemID)ItemId : E_ItemID.None;
            E_UpgradeID upgradeID = ItemType == GuiShop.E_ItemType.Upgrade ? (E_UpgradeID)ItemId : E_UpgradeID.None;
            E_PerkID    perkID    = ItemType == GuiShop.E_ItemType.Perk ? (E_PerkID)ItemId : E_PerkID.None;

            ResearchItem[] items = ResearchSupport.Instance.GetItems();

            foreach (var item in items)
            {
                if (item.weaponID == weaponID && weaponID != E_WeaponID.None ||
                    item.itemID == itemID && itemID != E_ItemID.None ||
                    item.upgradeID == upgradeID && upgradeID != E_UpgradeID.None ||
                    item.perkID == perkID && perkID != E_PerkID.None)
                {
                    Item = item;
                    break;
                }
            }

            return(true);
        }
コード例 #7
0
    protected virtual void Break(AgentHuman attacker, E_WeaponID weaponID, E_ItemID itemID)
    {
        if (m_Explosion != null)
        {
            Explosion explosion = Mission.Instance.ExplosionCache.Get(m_Explosion, m_ExplosionOrigin.position, m_ExplosionOrigin.rotation);
            explosion.Agent = attacker;
            if (explosion != true && m_ExplosionDamage >= 0)
            {
                explosion.BaseDamage = m_ExplosionDamage;
            }

            explosion.m_WeaponID = weaponID;
            explosion.m_ItemID   = itemID;
        }

        foreach (GameObject go in m_HideObjects)
        {
            go.SetActive(false);
        }
        foreach (GameObject go in m_ShowObjects)
        {
            go.SetActive(true);
        }

        if (uLink.Network.isServer)
        {
            NetworkView.RPC("BreakOnClients", uLink.RPCMode.Others);
        }
    }
コード例 #8
0
    public void AddWeaponUse(E_WeaponID id)
    {
        int index = PlayerData.InventoryList.Weapons.FindIndex(p => p.ID == id);

        if (index < 0)
        {
            return;
        }

        PPIRoundScore.WeaponStatistics weaponStats;

        try
        {
            weaponStats = Score.WeaponStats[id];
            weaponStats.StatsFire++;
        }
        catch (KeyNotFoundException)
        {
            weaponStats           = new PPIRoundScore.WeaponStatistics();
            weaponStats.StatsFire = 1;
        }

        Score.WeaponStats[id] = weaponStats;
        Score.Shots++;
    }
コード例 #9
0
ファイル: DamageVersions.cs プロジェクト: huokele/shadow-gun
    public void OnExplosionHit(Agent attacker, float inDamage, Vector3 impulse, E_WeaponID weaponId, E_ItemID itemId, HitZone inHitZone)
    {
        if (CurrentVersion == Versions.Count - 1)
        {
            return;
        }

        DoDamage(inDamage);
    }
コード例 #10
0
    //activate weapon
    protected void AddWeaponToOwnerHand(WeaponBase weapon)
    {
//        Debug.Log(Owner.name +  "CW Add to owner");
        CurrentWeapon = weapon.WeaponID;

        Owner.WorldState.SetWSProperty(E_PropKey.WeaponLoaded, weapon.ClipAmmo > 0);

        weapon.LinkToOwner(Owner, Hand);
    }
コード例 #11
0
    void ChangeWeapon(int idx)
    {
        E_WeaponID id = GuiHUD.Instance.GetWeaponInInventoryIndex(idx);

        if (id != E_WeaponID.None && id != Player.LocalInstance.Owner.WeaponComponent.CurrentWeapon)
        {
            States.ChangeWeaponDelegate(id);
        }
    }
コード例 #12
0
    void ChangeWeapon(int slotId)
    {
        E_WeaponID id = GuiHUD.Instance.GetWeaponInInventoryIndex(slotId);

        //weapon is different then current one
        if (id != E_WeaponID.None && id != Player.LocalInstance.Owner.WeaponComponent.CurrentWeapon)
        {
            States.ChangeWeaponDelegate(id);
        }
    }
コード例 #13
0
ファイル: BlackBoard.cs プロジェクト: huokele/shadow-gun
        public void Reset()
        {
            IsValid       = false;
            Death         = false;
            CurrentWeapon = E_WeaponID.None;

            Cover         = null;
            CoverPosition = E_CoverDirection.Unknown;
            CoverFiring   = false;
        }
コード例 #14
0
 public PreviewItem(E_WeaponID weaponID)
 {
     if (weaponID != E_WeaponID.None)
     {
         WeaponSettings settings = WeaponSettingsManager.Instance.Get(weaponID);
         m_ItemDescription = TextDatabase.instance[settings.Description];
         m_NumberOfParams  = 4;
         m_WeaponID        = weaponID;
     }
 }
コード例 #15
0
 // -----
 public bool ContainsWeapon(E_WeaponID weaponID)
 {
     foreach (PPIWeaponData data in Weapons)
     {
         if (data.ID == weaponID)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #16
0
    protected void WeaponAutoSwitch()
    {
        //FIXME tady se ( proted ) musim oprit o GUI - jinak nevim poradi zbrani

        List <E_WeaponID> weapons = new List <E_WeaponID>();

        int weaponsCount = GuiHUD.Instance.GetInventoryWeaponsCount();
        int startIndex   = -1;

        for (int i = 0; i < weaponsCount; i++)
        {
            E_WeaponID W = GuiHUD.Instance.GetWeaponInInventoryIndex(i);

            if (E_WeaponID.None == W)
            {
                continue;
            }

            if (W == CurrentWeapon)
            {
                startIndex = weapons.Count;
            }

            WeaponBase wBase = GetWeapon(W);

            if (null != wBase && wBase.HasAnyAmmo)
            {
                weapons.Add(W);

                if (startIndex > 0)
                {
                    break;
                }
            }
        }

        if (startIndex >= 0 && weapons.Count > 0)
        {
            if (startIndex == weapons.Count)
            {
                startIndex = 0;
            }
            // take it

            Owner.BlackBoard.Desires.Weapon = weapons[startIndex];

            //workaround to avoid sliding during weapon change (when this goes through GOAP, the GOAPMove action is terminated and it goes through Idle to the GOAPMove again)
//			Owner.WorldState.SetWSProperty( E_PropKey.WeaponChange, true );
            AgentActionWeaponChange Action = AgentActionFactory.Create(AgentActionFactory.E_Type.WeaponChange) as AgentActionWeaponChange;
            Action.NewWeapon = Owner.BlackBoard.Desires.Weapon;
            Owner.BlackBoard.ActionAdd(Action);
        }
    }
コード例 #17
0
    public void OnExplosionHit(Agent attacker, float damage, Vector3 impuls, E_WeaponID weaponType)
    {
        if (Active == false)
        {
            return;
        }

        Health -= damage;
        if (Health < 0)
        {
            Break();
        }
    }
コード例 #18
0
    public void AddWeaponAndSelect(E_WeaponID weapon)
    {
        if (Weapons.ContainsKey(weapon))
        {
            Weapons[weapon].AddAmmo(-1);
            return;
        }

        WeaponBase newWeapon = WeaponManager.Instance.GetWeapon(Owner, weapon);

        Weapons.Add(newWeapon.WeaponID, newWeapon);
        Owner.BlackBoard.Desires.Weapon = weapon;
    }
コード例 #19
0
    int GetCurrentWeaponSlot()
    {
        E_WeaponID curId       = Player.LocalInstance.Owner.WeaponComponent.CurrentWeapon;
        int        currentSlot = 0;

        for (int i = 0; i < slotCOUNT; i++)
        {
            if (GuiHUD.Instance.GetWeaponInInventoryIndex(i) == curId)
            {
                currentSlot = i;
                break;
            }
        }
        return(currentSlot);
    }
コード例 #20
0
    void ActionChangeWeapon(E_WeaponID weaponType)
    {
        if (CanChangeWeapon() == false)
        {
            return;
        }

        Owner.BlackBoard.Desires.Weapon = weaponType;

        //workaround to avoid sliding during weapon change (when this goes through GOAP, the GOAPMove action is terminated and it goes through Idle to the GOAPMove again)
        //Owner.WorldState.SetWSProperty(E_PropKey.WeaponChange, true);
        AgentActionWeaponChange Action = AgentActionFactory.Create(AgentActionFactory.E_Type.WeaponChange) as AgentActionWeaponChange;

        Action.NewWeapon = Owner.BlackBoard.Desires.Weapon;
        Owner.BlackBoard.ActionAdd(Action);
    }
コード例 #21
0
    protected void Deactivate()
    {
        //Debug.Log(gameObject.name + "CW deactivate");

        foreach (KeyValuePair <E_WeaponID, WeaponBase> weaponPair in Weapons)
        {
            if (WeaponManager.Instance)
            {
                WeaponManager.Instance.Return(weaponPair.Value);
            }
        }

        Weapons.Clear();

        CurrentWeapon = E_WeaponID.None;
    }
コード例 #22
0
    public void Read(BitStream stream)
    {
        CreateUpgradesIfNotExisting();
        ID           = stream.Read <E_WeaponID>();
        EquipSlotIdx = stream.ReadByte();

        Upgrades.Clear();
        int count = stream.ReadByte();

        for (int i = 0; i < count; i++)
        {
            WeaponUpgrade upg = new WeaponUpgrade();
            upg.ID = stream.Read <E_WeaponUpgradeID>();
            Upgrades.Add(upg);
        }
    }
コード例 #23
0
    public void AddWeaponKill(E_WeaponID id, E_BodyPart bodyPart, int num = 1)
    {
        if (uLink.Network.isServer == false)
        {
            throw new uLink.NetworkException("AddWeaponKill: could be called only on server");
        }

        int index = PlayerData.InventoryList.Weapons.FindIndex(p => p.ID == id);

        if (index < 0)
        {
            return;
        }

        PPIWeaponData weaponData = PlayerData.InventoryList.Weapons[index];

        //DebugUtils.Assert( weaponData.IsValid() );

        // nemusi byt validni napriklad pri pouziti itemu se spatne nastavenym ID itemu (takze se vola WeaponKill na zadanou zbran)
        if (weaponData.IsValid())
        {
            PPIRoundScore.WeaponStatistics weaponStats;

            try
            {
                weaponStats             = Score.WeaponStats[id];
                weaponStats.StatsKills += num;
            }
            catch (KeyNotFoundException)
            {
                weaponStats            = new PPIRoundScore.WeaponStatistics();
                weaponStats.StatsKills = num;
            }

            Score.WeaponStats[id] = weaponStats;
        }
        else
        {
            Debug.LogError("AddWeaponKill() with weapon '" + id + "' : weapon not found");
        }

        Score.HeadShots += bodyPart == E_BodyPart.Head ? 1 : 0;

        // Debug.Log("Weapon kill " + PlayerData.InventoryList.Weapons[index].ToString() +  " " + PlayerData.Stats.Games[(int)Game.GetMultiplayerGameType()].ToString());
    }
コード例 #24
0
        // Copy constructor. Create clone of inSettings object.
        public InitSettings(InitSettings inSettings)
        {
            Damage   = inSettings.Damage;
            Impulse  = inSettings.Impulse;
            Speed    = inSettings.Speed;
            Agent    = inSettings.Agent;
            WeaponID = inSettings.WeaponID;
            ItemID   = inSettings.ItemID;
            Homing   = inSettings.Homing;
            Silencer = inSettings.Silencer;

            IgnoreTransform = inSettings.IgnoreTransform;

            if (null == Agent)
            {
                Debug.LogWarning("### Projectile.InitSettings() : unexpected null agent. WeaponID : " + WeaponID + ", ItemID : " + ItemID);
            }
        }
コード例 #25
0
    public void OnExplosionHit(Agent attacker, float inDamage, Vector3 impulse, E_WeaponID weaponId, E_ItemID itemId, HitZone inHitZone)
    {
        if (uLink.Network.isServer == false)
        {
            return;
        }

        if (m_HitPoints <= 0)
        {
            return;
        }

        m_HitPoints -= inDamage * inHitZone.DamageModifier;
        if (m_HitPoints <= 0)
        {
            Break(attacker as AgentHuman, weaponId, itemId);
        }
    }
コード例 #26
0
    void TakeDamage(AgentHuman inAttacker, float inDamage, Vector3 inImpuls, E_WeaponID weaponID, E_ItemID itemID)
    {
        // Only server players should take damage or die as a consequence of damage. Client players die from server messages.
        if (uLink.Network.isServer)
        {
            if (m_Health - inDamage > 0)
            {
                m_Health = Mathf.Max(0, m_Health - inDamage);
            }
            else if (m_Health > 0)
            {
                m_Health = 0;

                PPIManager.Instance.ServerAddScoreForTurretKill(inAttacker.NetworkView.owner, GoldReward);
                OnDeactivation();
            }
        }
    }
コード例 #27
0
ファイル: GuiShopItemId.cs プロジェクト: huokele/shadow-gun
    int RifleSubtype(E_WeaponID id)
    {
        switch (id)
        {
        case E_WeaponID.AR1:
            return(1);

        case E_WeaponID.AR2:
            return(1);

        case E_WeaponID.AR3:
            return(1);

        case E_WeaponID.AR4:
            return(1);

        case E_WeaponID.SMG1:
            return(2);

        case E_WeaponID.SMG2:
            return(2);

        case E_WeaponID.SMG3:
            return(2);

        case E_WeaponID.SMG4:
            return(2);

        case E_WeaponID.MG1:
            return(3);

        case E_WeaponID.MG2:
            return(3);

        case E_WeaponID.MG3:
            return(3);

        case E_WeaponID.MG4:
            return(3);

        default:
            return(0);
        }
    }
コード例 #28
0
    void ChangeWeaponC(E_WeaponID weapon, uLink.NetworkMessageInfo info)
    {
#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportPotentialCheatAttempt("ChangeWeaponC", "should never be called on the server side", Owner.NetworkView.owner);
            return;
        }
#endif

        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

        AgentActionWeaponChange action = AgentActionFactory.Create(AgentActionFactory.E_Type.WeaponChange) as AgentActionWeaponChange;
        action.NewWeapon = weapon;
        Owner.BlackBoard.ActionAdd(action);
    }
コード例 #29
0
ファイル: WeaponBase.cs プロジェクト: huokele/shadow-gun
    // -----------------

    // -----
    public void Initialize(AgentHuman owner, E_WeaponID id)
    {
        Settings                  = WeaponSettingsManager.Instance.Get(id);
        InitProjSettings          = new Projectile.InitSettings();
        InitProjSettings.WeaponID = Settings.ID;
        InitProjSettings.Impulse  = Settings.BaseData.Impulse;
        InitProjSettings.Speed    = Settings.BaseData.Speed;      // to have valid valid values here if InitializeModifiersFromUpgrades fails
        InitProjSettings.Damage   = Settings.BaseData.Damage;

        InitializeModifiersFromUpgrades(owner);
        _AmmoInClip   = MaxAmmoInClip;
        _AmmoInWeapon = MaxAmmoInWeapon;
        GameObject    = gameObject;
        Transform     = transform;
        Audio         = GetComponent <AudioSource>();
        RBody         = GetComponent <Rigidbody>();
//		Renderer		= renderer;
        TransformShot = transform.FindChild("Shoot");
    }
コード例 #30
0
    //add weapon to list only
    public virtual void AddWeapon(E_WeaponID weapon)
    {
        if (Weapons == null)
        {
            throw new System.MissingMemberException();
        }

        if (WeaponManager.Instance == null)
        {
            throw new System.ArgumentNullException();
        }

        if (Weapons.ContainsKey(weapon))
        {
            throw new System.Exception(weapon + " already exist in the list");
        }

        Weapons.Add(weapon, WeaponManager.Instance.GetWeapon(Owner, weapon));
    }