Пример #1
0
        public Hashtable GetInfo()
        {
            emptyBonuses.Clear();
            Hashtable result = new Hashtable();

            foreach (var b in this.bonuses)
            {
                if (b.Value.count > 0)
                {
                    result.Add((int)b.Key, b.Value.value);
                }
                else
                {
                    emptyBonuses.Add(b.Key);
                }
            }

            PlayerBonus removedBonus = null;

            foreach (var emptyBonusType in emptyBonuses)
            {
                bonuses.TryRemove(emptyBonusType, out removedBonus);
            }
            return(result);
        }
Пример #2
0
        public PlayerBonus GetBonus(BonusType bonus)
        {
            PlayerBonus result = null;

            bonuses.TryGetValue(bonus, out result);
            return(result);
        }
Пример #3
0
        public void RemoveAnyBuff()
        {
            BonusType removedKey = BonusType.block_heal;
            bool      found      = false;

            foreach (var pBonus in mBonuses)
            {
                if (IsBuff(pBonus.Key))
                {
                    if (pBonus.Value.hasAny)
                    {
                        removedKey = pBonus.Key;
                        found      = true;
                        break;
                    }
                }
            }
            if (found)
            {
                PlayerBonus removedBonus = null;
                if (mBonuses.TryRemove(removedKey, out removedBonus))
                {
                    log.InfoFormat("PlayerBonuses.RemoveAnyBuff(): removed buff = {0} [yellow]", removedKey);
                    SendPropertyUpdate(false);
                }
            }
        }
Пример #4
0
    private IEnumerator StartBonusEffectCoroutine(Bonus collideBonus)
    {
        playerBonusEnum |= collideBonus.TargetBonus;

        yield return(new WaitForSeconds(collideBonus.TimeDuration));

        playerBonusEnum &= ~collideBonus.TargetBonus;
    }
Пример #5
0
        public void RemoveBuff(BonusType type, string buffId)
        {
            PlayerBonus bon = null;

            if (bonuses.TryGetValue(type, out bon))
            {
                bon.RemoveBuff(buffId);
            }
        }
Пример #6
0
 void Awake()
 {
     anim           = GetComponent <Animator>();
     hurtSound      = GetComponent <AudioSource>();
     playerMovement = GetComponent <PlayerMovement>();
     playerShooting = GetComponentInChildren <PlayerShooting>();
     playerBonus    = GetComponentInChildren <PlayerBonus>();
     InitHealth();
     SliderUpdate();
 }
Пример #7
0
        public Buff GetBuff(BonusType bonusType, string buffId)
        {
            PlayerBonus bon = null;

            if (bonuses.TryGetValue(bonusType, out bon))
            {
                return(bon.GetBuff(buffId));
            }
            return(null);
        }
        public void LoadPlayerBonus()
        {
            PlayerBonus bonus = PlayerManager.getPlayerBonusDB(player_id);

            if (bonus.ownerId == 0)
            {
                PlayerManager.CreatePlayerBonusDB(player_id);
                bonus.ownerId = player_id;
            }
            _bonus = bonus;
        }
Пример #9
0
        public void LoadPlayerBonus()
        {
            PlayerBonus playerBonusDb = PlayerManager.getPlayerBonusDB(this.player_id);

            if (playerBonusDb.ownerId == 0L)
            {
                PlayerManager.CreatePlayerBonusDB(this.player_id);
                playerBonusDb.ownerId = this.player_id;
            }
            this._bonus = playerBonusDb;
        }
Пример #10
0
 public void SimpleClear()
 {
     _config      = null;
     _titles      = null;
     _bonus       = null;
     _event       = null;
     _connection  = null;
     _inventory   = new PlayerInventory();
     FriendSystem = new FriendSystem();
     _clanPlayers = new List <Account>();
     _equip       = new PlayerEquipedItems();
     _mission     = new PlayerMissions();
     _status      = new AccountStatus();
 }
Пример #11
0
        public void SetBuff(BonusType type, Buff buff, NebulaObject source)
        {
            InitVariables();
            if (mSpeedDebuffs.Contains(type))
            {
                if (BuffNotZero(BonusType.speed_debuff_immunity))
                {
                    log.InfoFormat("exist speed debuff immunity, ignore speed debuff, yellow");
                    return;
                }
                if (BuffNotZero(BonusType.decrease_time_of_negative_speed_buffs))
                {
                    buff.MultInterval(Value(BonusType.decrease_time_of_negative_speed_buffs));
                }
            }

            if (IsDebuffBlocked(buff))
            {
                SendPropertyUpdate();
                return;
            }


            bool success = true;

            if (bonuses.ContainsKey(type) == false)
            {
                success = bonuses.TryAdd(type, new PlayerBonus(type));
            }
            if (success)
            {
                PlayerBonus bon = null;
                if (bonuses.TryGetValue(type, out bon))
                {
                    bon.SetBuff(buff);
                }
            }
            if (success && nebulaObject.IsPlayer())
            {
                SendPropertyUpdate();
            }

            if (success && m_Target != null)
            {
                if (source != null)
                {
                    m_Target.OnBuffSetted(buff, source);
                }
            }
        }
Пример #12
0
 public void SimpleClear()
 {
     this._config      = (PlayerConfig)null;
     this._titles      = (PlayerTitles)null;
     this._bonus       = (PlayerBonus)null;
     this._event       = (PlayerEvent)null;
     this._connection  = (LoginClient)null;
     this._inventory   = new PlayerInventory();
     this.FriendSystem = new FriendSystem();
     this._clanPlayers = new List <Account>();
     this._equip       = new PlayerEquipedItems();
     this._mission     = new PlayerMissions();
     this._status      = new AccountStatus();
 }
Пример #13
0
        public void GetAccountInfos(int LoadType)
        {
            if (LoadType <= 0 || this.player_id <= 0L)
            {
                return;
            }
            if ((LoadType & 1) == 1)
            {
                this._titles = TitleManager.getInstance().getTitleDB(this.player_id);
            }
            if ((LoadType & 2) == 2)
            {
                this._bonus = PlayerManager.getPlayerBonusDB(this.player_id);
            }
            if ((LoadType & 4) == 4)
            {
                List <Friend> friendList = PlayerManager.getFriendList(this.player_id);
                if (friendList.Count > 0)
                {
                    this.FriendSystem._friends = friendList;
                    AccountManager.getFriendlyAccounts(this.FriendSystem);
                }
            }
            if ((LoadType & 8) == 8)
            {
                this._event = PlayerManager.getPlayerEventDB(this.player_id);
            }
            if ((LoadType & 16) == 16)
            {
                this._config = PlayerManager.getConfigDB(this.player_id);
            }
            if ((LoadType & 32) != 32)
            {
                return;
            }
            List <Friend> friendList1 = PlayerManager.getFriendList(this.player_id);

            if (friendList1.Count <= 0)
            {
                return;
            }
            this.FriendSystem._friends = friendList1;
        }
Пример #14
0
        /// <summary>
        /// Remove any positive Bonus Type from object
        /// </summary>
        public void RemoveAnyPositiveBuff()
        {
            bool      buffFounded     = false;
            BonusType foundedBuffType = BonusType.block_heal;

            foreach (var pBonus in bonuses)
            {
                if (BuffUtils.IsBuff(pBonus.Key))
                {
                    foundedBuffType = pBonus.Key;
                    buffFounded     = true;
                    break;
                }
            }

            if (buffFounded)
            {
                PlayerBonus removedBonus = null;
                bonuses.TryRemove(foundedBuffType, out removedBonus);
            }
        }
 /// <summary>
 /// Gera informações adicionais a conta\n0 = Nada\n1 = Títulos\n2 = Bônus\n4 = Amigos (Completo)\n8 = Eventos\n16 = Configurações\n32 = Amigos (Básico)
 /// </summary>
 /// <param name="LoadType">Detalhes</param>
 public void GetAccountInfos(int LoadType)
 {
     if (LoadType > 0 && player_id > 0)
     {
         if ((LoadType & 1) == 1)
         {
             _titles = TitleManager.getInstance().getTitleDB(player_id);
         }
         if ((LoadType & 2) == 2)
         {
             _bonus = PlayerManager.getPlayerBonusDB(player_id);
         }
         if ((LoadType & 4) == 4)
         {
             List <Friend> fs = PlayerManager.getFriendList(player_id);
             if (fs.Count > 0)
             {
                 FriendSystem._friends = fs;
                 AccountManager.getFriendlyAccounts(FriendSystem);
             }
         }
         if ((LoadType & 8) == 8)
         {
             _event = PlayerManager.getPlayerEventDB(player_id);
         }
         if ((LoadType & 16) == 16)
         {
             _config = PlayerManager.getConfigDB(player_id);
         }
         if ((LoadType & 32) == 32)
         {
             List <Friend> fs = PlayerManager.getFriendList(player_id);
             if (fs.Count > 0)
             {
                 FriendSystem._friends = fs;
             }
         }
     }
 }
Пример #16
0
 public void GetAccountInfos(int LoadType)
 {
     if (LoadType == 0 || this.player_id == 0L)
     {
         return;
     }
     if ((LoadType & 1) == 1)
     {
         this._titles = TitleManager.getInstance().getTitleDB(this.player_id);
     }
     if ((LoadType & 2) == 2)
     {
         this._bonus = PlayerManager.getPlayerBonusDB(this.player_id);
     }
     if ((LoadType & 4) == 4)
     {
         List <Friend> friendList = PlayerManager.getFriendList(this.player_id);
         if (friendList.Count > 0)
         {
             this.FriendSystem._friends = friendList;
         }
     }
     if ((LoadType & 8) == 8)
     {
         this._event = PlayerManager.getPlayerEventDB(this.player_id);
         if (this._event == null)
         {
             PlayerManager.addEventDB(this.player_id);
             this._event = new PlayerEvent();
         }
     }
     if ((LoadType & 16) != 16)
     {
         return;
     }
     this._config = PlayerManager.getConfigDB(this.player_id);
 }
Пример #17
0
 public void GetAccountInfos(int LoadType)
 {
     if (LoadType == 0 || player_id == 0)
     {
         return;
     }
     if ((LoadType & 1) == 1)
     {
         _titles = TitleManager.getInstance().getTitleDB(player_id);
     }
     if ((LoadType & 2) == 2)
     {
         _bonus = PlayerManager.getPlayerBonusDB(player_id);
     }
     if ((LoadType & 4) == 4)
     {
         List <Friend> fs = PlayerManager.getFriendList(player_id);
         if (fs.Count > 0)
         {
             FriendSystem._friends = fs;
         }
     }
     if ((LoadType & 8) == 8)
     {
         _event = PlayerManager.getPlayerEventDB(player_id);
         if (_event == null)
         {
             PlayerManager.addEventDB(player_id);
             _event = new PlayerEvent();
         }
     }
     if ((LoadType & 16) == 16)
     {
         _config = PlayerManager.getConfigDB(player_id);
     }
 }
Пример #18
0
 public BASE_USER_EFFECTS_PAK(int type, PlayerBonus bonus)
 {
     this._type  = type;
     this._bonus = bonus;
 }
Пример #19
0
 public void RemoveBonus(PlayerBonus bonus)
 {
     _passiveBonus.Remove(bonus);
 }
Пример #20
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (player == null)
         {
             return;
         }
         ItemsModel item = player.inventory.GetItem(objectId);
         if (item == null)
         {
             client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
             return;
         }
         else if (Utilities.GetIdStatics(item.id, 1) == 12)
         {
             PlayerBonus bonus = player.bonus;
             if (bonus == null)
             {
                 client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                 return;
             }
             bool changed = bonus.RemoveBonuses(item.id);
             if (!changed)
             {
                 if (item.id == 1200014000)
                 {
                     if (player.ExecuteQuery($"UPDATE player_bonus SET sightcolor='4' WHERE player_id='{player.playerId}'"))
                     {
                         bonus.sightColor = 4;
                         client.SendPacket(new PROTOCOL_BASE_USER_EFFECTS_ACK(0, bonus));
                     }
                     else
                     {
                         client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                         return;
                     }
                 }
                 else if (item.id == 1200010000)
                 {
                     if (bonus.fakeNick.Length == 0)
                     {
                         client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                         return;
                     }
                     if (player.ExecuteQuery($"UPDATE accounts SET nickname='{bonus.fakeNick}' WHERE id='{player.playerId}'") &&
                         player.ExecuteQuery($"UPDATE player_bonus SET fakenick='{""}' WHERE player_id='{player.playerId}'"))
                     {
                         player.nickname = bonus.fakeNick;
                         bonus.fakeNick  = "";
                         client.SendPacket(new PROTOCOL_BASE_USER_EFFECTS_ACK(0, bonus));
                         client.SendPacket(new PROTOCOL_AUTH_CHANGE_NICKNAME_ACK(player.nickname));
                     }
                     else
                     {
                         client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                         return;
                     }
                 }
                 else if (item.id == 1200009000)
                 {
                     if (player.ExecuteQuery($"UPDATE player_bonus SET fakerank='55' WHERE player_id='{player.playerId}'"))
                     {
                         bonus.fakeRank = 55;
                         client.SendPacket(new PROTOCOL_BASE_USER_EFFECTS_ACK(0, bonus));
                     }
                     else
                     {
                         client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                         return;
                     }
                 }
                 else if (item.id == 1200006000)
                 {
                     if (player.ExecuteQuery($"UPDATE accounts SET nickcolor='0' WHERE id='{player.playerId}'"))
                     {
                         player.nickcolor = 0;
                         client.SendPacket(new BASE_2612_PAK(player));
                         Room room = player.room;
                         if (room != null)
                         {
                             using (PROTOCOL_ROOM_GET_NICKNAME_ACK packet = new PROTOCOL_ROOM_GET_NICKNAME_ACK(player.slotId, player.nickname, player.nickcolor))
                             {
                                 room.SendPacketToPlayers(packet);
                             }
                         }
                     }
                     else
                     {
                         client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                         return;
                     }
                 }
             }
             else
             {
                 player.UpdatePlayerBonus();
             }
         }
         if (item != null)
         {
             if (player.DeleteItem(item.objectId))
             {
                 player.inventory.RemoveItem(item);
             }
             else
             {
                 client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                 return;
             }
         }
         client.SendPacket(new INVENTORY_ITEM_EXCLUDE_PAK(1, objectId));
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }
Пример #21
0
        public bool RemoveBuffs(BonusType type)
        {
            PlayerBonus old = null;

            return(bonuses.TryRemove(type, out old));
        }
Пример #22
0
 public void SetPlayerId()
 {
     this._titles = new PlayerTitles();
     this._bonus  = new PlayerBonus();
     this.GetAccountInfos(8);
 }
Пример #23
0
 public void SetPlayerId()
 {
     _titles = new PlayerTitles();
     _bonus  = new PlayerBonus();
     GetAccountInfos(8);
 }
Пример #24
0
        public override void run()
        {
            try
            {
                Account p = _client._player;
                if (p == null)
                {
                    return;
                }
                ItemsModel  item  = p._inventory.getItem(objId);
                PlayerBonus bonus = p._bonus;
                if (item == null)
                {
                    erro = 0x80000000;
                }
                else if (ComDiv.getIdStatics(item._id, 1) == 12)
                {
                    if (bonus == null)
                    {
                        _client.SendPacket(new INVENTORY_ITEM_EXCLUDE_PAK(0x80000000));
                        return;
                    }
                    bool changed = bonus.RemoveBonuses(item._id);
                    if (!changed)
                    {
                        if (item._id == 1200014000)
                        {
                            if (ComDiv.updateDB("player_bonus", "sightcolor", 4, "player_id", p.player_id))
                            {
                                bonus.sightColor = 4;
                                _client.SendPacket(new BASE_USER_EFFECTS_PAK(0, bonus));
                            }
                            else
                            {
                                erro = 0x80000000;
                            }
                        }
                        else if (item._id == 1200010000)
                        {
                            if (bonus.fakeNick.Length == 0)
                            {
                                erro = 0x80000000;
                            }
                            else
                            {
                                if (ComDiv.updateDB("contas", "player_name", bonus.fakeNick, "player_id", p.player_id) &&
                                    ComDiv.updateDB("player_bonus", "fakenick", "", "player_id", p.player_id))
                                {
                                    p.player_name  = bonus.fakeNick;
                                    bonus.fakeNick = "";
                                    _client.SendPacket(new BASE_USER_EFFECTS_PAK(0, bonus));
                                    _client.SendPacket(new AUTH_CHANGE_NICKNAME_PAK(p.player_name));
                                }
                                else
                                {
                                    erro = 0x80000000;
                                }
                            }
                        }
                        else if (item._id == 1200009000)
                        {
                            if (ComDiv.updateDB("player_bonus", "fakerank", 55, "player_id", p.player_id))
                            {
                                bonus.fakeRank = 55;
                                _client.SendPacket(new BASE_USER_EFFECTS_PAK(0, bonus));
                            }
                            else
                            {
                                erro = 0x80000000;
                            }
                        }
                        else if (item._id == 1200006000)
                        {
                            if (ComDiv.updateDB("contas", "name_color", 0, "player_id", p.player_id))
                            {
                                p.name_color = 0;
                                _client.SendPacket(new BASE_2612_PAK(p));
                                Room room = p._room;
                                if (room != null)
                                {
                                    using (ROOM_GET_NICKNAME_PAK packet = new ROOM_GET_NICKNAME_PAK(p._slotId, p.player_name, p.name_color))
                                        room.SendPacketToPlayers(packet);
                                }
                            }
                            else
                            {
                                erro = 0x80000000;
                            }
                        }
                    }
                    else
                    {
                        PlayerManager.updatePlayerBonus(p.player_id, bonus.bonuses, bonus.freepass);
                    }

                    CupomFlag cupom = CupomEffectManager.getCupomEffect(item._id);
                    if (cupom != null && cupom.EffectFlag > 0 && p.effects.HasFlag(cupom.EffectFlag))
                    {
                        p.effects -= cupom.EffectFlag;
                        PlayerManager.updateCupomEffects(p.player_id, p.effects);
                    }
                }
                if (erro == 1 && item != null)
                {
                    if (PlayerManager.DeleteItem(item._objId, p.player_id))
                    {
                        p._inventory.RemoveItem(item);
                    }
                    else
                    {
                        erro = 0x80000000;
                    }
                }
                _client.SendPacket(new INVENTORY_ITEM_EXCLUDE_PAK(erro, objId));
            }
            catch (Exception ex)
            {
                SaveLog.fatal(ex.ToString());
                Printf.b_danger("[INVENTORY_ITEM_EXCLUDE_REC.INVENTORY_ITEM_EXCLUDE_REC] Erro fatal!");
                _client.SendPacket(new INVENTORY_ITEM_EXCLUDE_PAK(0x80000000));
            }
        }
Пример #25
0
 public PROTOCOL_BASE_USER_EFFECTS_ACK(int type, PlayerBonus bonus)
 {
     this.type  = type;
     this.bonus = bonus;
 }
Пример #26
0
 public void AddBonus(PlayerBonus newBonus)
 {
     _passiveBonus.Add(newBonus);
 }
Пример #27
0
 public override void run()
 {
     try
     {
         Account player = this._client._player;
         if (player == null)
         {
             return;
         }
         ItemsModel  itemsModel = player._inventory.getItem(this.objId);
         PlayerBonus bonus      = player._bonus;
         if (itemsModel == null)
         {
             this.erro = 2147483648U;
         }
         else if (ComDiv.getIdStatics(itemsModel._id, 1) == 12)
         {
             if (bonus == null)
             {
                 this._client.SendPacket((SendPacket) new INVENTORY_ITEM_EXCLUDE_PAK(2147483648U, 0L));
                 return;
             }
             if (!bonus.RemoveBonuses(itemsModel._id))
             {
                 if (itemsModel._id == 1200014000)
                 {
                     if (ComDiv.updateDB("player_bonus", "sightcolor", (object)4, "player_id", (object)player.player_id))
                     {
                         bonus.sightColor = 4;
                         this._client.SendPacket((SendPacket) new BASE_USER_EFFECTS_PAK(0, bonus));
                     }
                     else
                     {
                         this.erro = 2147483648U;
                     }
                 }
                 else if (itemsModel._id == 1200010000)
                 {
                     if (bonus.fakeNick.Length == 0)
                     {
                         this.erro = 2147483648U;
                     }
                     else if (ComDiv.updateDB("accounts", "player_name", (object)bonus.fakeNick, "player_id", (object)player.player_id) && ComDiv.updateDB("player_bonus", "fakenick", (object)"", "player_id", (object)player.player_id))
                     {
                         player.player_name = bonus.fakeNick;
                         bonus.fakeNick     = "";
                         this._client.SendPacket((SendPacket) new BASE_USER_EFFECTS_PAK(0, bonus));
                         this._client.SendPacket((SendPacket) new AUTH_CHANGE_NICKNAME_PAK(player.player_name));
                     }
                     else
                     {
                         this.erro = 2147483648U;
                     }
                 }
                 else if (itemsModel._id == 1200009000)
                 {
                     if (ComDiv.updateDB("player_bonus", "fakerank", (object)55, "player_id", (object)player.player_id))
                     {
                         bonus.fakeRank = 55;
                         this._client.SendPacket((SendPacket) new BASE_USER_EFFECTS_PAK(0, bonus));
                     }
                     else
                     {
                         this.erro = 2147483648U;
                     }
                 }
                 else if (itemsModel._id == 1200006000)
                 {
                     if (ComDiv.updateDB("accounts", "name_color", (object)0, "player_id", (object)player.player_id))
                     {
                         player.name_color = 0;
                         this._client.SendPacket((SendPacket) new BASE_2612_PAK(player));
                         Room room = player._room;
                         if (room != null)
                         {
                             using (ROOM_GET_NICKNAME_PAK roomGetNicknamePak = new ROOM_GET_NICKNAME_PAK(player._slotId, player.player_name, player.name_color))
                                 room.SendPacketToPlayers((SendPacket)roomGetNicknamePak);
                         }
                     }
                     else
                     {
                         this.erro = 2147483648U;
                     }
                 }
             }
             else
             {
                 PlayerManager.updatePlayerBonus(player.player_id, bonus.bonuses, bonus.freepass);
             }
             CupomFlag cupomEffect = CupomEffectManager.getCupomEffect(itemsModel._id);
             if (cupomEffect != null && cupomEffect.EffectFlag > (CupomEffects)0 && player.effects.HasFlag((Enum)cupomEffect.EffectFlag))
             {
                 player.effects -= cupomEffect.EffectFlag;
                 PlayerManager.updateCupomEffects(player.player_id, player.effects);
             }
         }
         if (this.erro == 1U && itemsModel != null)
         {
             if (PlayerManager.DeleteItem(itemsModel._objId, player.player_id))
             {
                 player._inventory.RemoveItem(itemsModel);
             }
             else
             {
                 this.erro = 2147483648U;
             }
         }
         this._client.SendPacket((SendPacket) new INVENTORY_ITEM_EXCLUDE_PAK(this.erro, this.objId));
     }
     catch (Exception ex)
     {
         Logger.info("[INVENTORY_ITEM_EXCLUDE_REC] " + ex.ToString());
         this._client.SendPacket((SendPacket) new INVENTORY_ITEM_EXCLUDE_PAK(2147483648U, 0L));
     }
 }
Пример #28
0
 private void Start()
 {
     playerBonus = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <PlayerBonus>();
 }
Пример #29
0
 void Start()
 {
     anim        = GetComponent <Animator>();
     laserAudio  = GetComponent <AudioSource>();
     playerBonus = GetComponentInChildren <PlayerBonus>();
 }