コード例 #1
0
        /// <summary>
        ///     Executes this command.
        /// </summary>
        public override int Execute(LogicLevel level)
        {
            LogicClientAvatar playerAvatar = level.GetPlayerAvatar();

            if (playerAvatar != null)
            {
                if (this._source == 1)
                {
                    // listener.
                }

                playerAvatar.SetDiamonds(playerAvatar.GetDiamonds() + this._diamondsCount);

                if (this._freeDiamonds)
                {
                    int freeDiamonds = playerAvatar.GetFreeDiamonds();

                    if (this._diamondsCount < 0)
                    {
                        if (freeDiamonds - this._diamondsCount >= 0 && playerAvatar.GetDiamonds() != freeDiamonds)
                        {
                            playerAvatar.SetFreeDiamonds(freeDiamonds + this._diamondsCount);
                        }
                    }
                    else
                    {
                        playerAvatar.SetFreeDiamonds(freeDiamonds + this._diamondsCount);
                    }
                }
                else
                {
                    if (this._billingPackageId > 0)
                    {
                        LogicBillingPackageData billingPackageData = (LogicBillingPackageData)LogicDataTables.GetDataById(this._billingPackageId, 21);

                        if (billingPackageData != null)
                        {
                            if (billingPackageData.RED && !this._bundlePackage)
                            {
                                int redPackageState    = playerAvatar.GetRedPackageState();
                                int newRedPackageState = redPackageState | 0x10;

                                if ((redPackageState & 3) != 3)
                                {
                                    newRedPackageState = (int)(newRedPackageState & 0xFFFFFFFC);
                                }

                                playerAvatar.SetRedPackageState(newRedPackageState);
                            }
                        }
                    }

                    level.GetGameListener().DiamondsBought();
                    playerAvatar.AddCumulativePurchasedDiamonds(this._diamondsCount);
                }

                return(0);
            }

            return(-1);
        }