public TaxCollectorSimpleDialog(string title, int funds, List <ObjectPicker.TabInfo> listObjs, List <ObjectPicker.HeaderInfo> headers, bool viewTypeToggle, Vector2 position)
            : base("SimplePurchaseDialog", 1, true, ModalDialog.PauseMode.PauseSimulator, null)
        {
            if (this.mModalDialogWindow != null)
            {
                Text text = this.mModalDialogWindow.GetChildByID(99576787u, false) as Text;
                text.Caption = title;
                this.mFunds  = funds;
                text         = (this.mModalDialogWindow.GetChildByID(99576788u, false) as Text);
                text.Caption = Responder.Instance.LocalizationModel.LocalizeString("Ui/Caption/Shopping/Cart:AvailableFunds", new object[]
                {
                    UIUtils.FormatMoney(funds)
                });
                this.mTable = (this.mModalDialogWindow.GetChildByID(99576784u, false) as ObjectPicker);
                this.mTable.ObjectTable.TableChanged     += new TableContainer.TableChangedEventHandler(this.OnTableChanged);
                this.mTable.ObjectTable.SelectionChanged += new UIEventHandler <UISelectionChangeEventArgs>(this.OnSelectionChanged);
                this.mOkayButton         = (this.mModalDialogWindow.GetChildByID(99576785u, false) as Button);
                this.mOkayButton.Enabled = false;
                this.mOkayButton.Click  += new UIEventHandler <UIButtonClickEventArgs>(this.OnOkayButtonClick);
                this.mOkayButton.Caption = CMStoreSet.LocalizeString("Select", new object[0]);

                base.OkayID              = this.mOkayButton.ID;
                base.SelectedID          = this.mOkayButton.ID;
                this.mCloseButton        = (this.mModalDialogWindow.GetChildByID(99576786u, false) as Button);
                this.mCloseButton.Click += new UIEventHandler <UIButtonClickEventArgs>(this.OnCloseButtonClick);
                base.CancelID            = this.mCloseButton.ID;
                this.mTableOffset        = this.mModalDialogWindow.Area.BottomRight - this.mModalDialogWindow.Area.TopLeft - (this.mTable.Area.BottomRight - this.mTable.Area.TopLeft);
                this.mTable.Populate(listObjs, headers, 1);
                this.mTable.ViewTypeToggle   = viewTypeToggle;
                this.mModalDialogWindow.Area = new Rect(this.mModalDialogWindow.Area.TopLeft, this.mModalDialogWindow.Area.TopLeft + this.mTable.TableArea.BottomRight + this.mTableOffset);
                float x = position.x;
                float y = position.y;
                if (x < 0f && y < 0f)
                {
                    this.mModalDialogWindow.CenterInParent();
                }
                else
                {
                    Rect  area = this.mModalDialogWindow.Area;
                    float num  = area.BottomRight.x - area.TopLeft.x;
                    float num2 = area.BottomRight.y - area.TopLeft.y;
                    area.Set(x, y, x + num, y + num2);
                    this.mModalDialogWindow.Area = area;
                }
                this.mModalDialogWindow.Visible = true;
            }
        }
Exemple #2
0
        public static int ReturnPriceByQuality(Quality q, int defaultPrice)
        {
            int price = defaultPrice;

            try
            {
                switch (q)
                {
                case Quality.Foul:
                case Quality.Horrifying:
                case Quality.Bad:
                case Quality.Putrid:
                    price = (int)(defaultPrice * 0.5f);
                    break;

                case Quality.Nice:
                case Quality.VeryNice:
                    price = (int)(defaultPrice * 1.2f);
                    break;

                case Quality.Great:
                case Quality.Outstanding:
                case Quality.Excellent:
                    price = (int)(defaultPrice * 1.3f);
                    break;

                case Quality.Perfect:
                    price = (int)(defaultPrice * 1.4f);
                    break;

                default:
                    price = defaultPrice;
                    break;
                }
            }
            catch (System.Exception ex)
            {
                CMStoreSet.PrintMessage("Serving Price: " + ex.Message);
                throw;
            }
            return(price);
        }
Exemple #3
0
        public static GameObject CreateRestockItem(GameObject src, int value, bool isRug)
        {
            try
            {
                RestockItem item = null;

                if (isRug)
                {
                    item = GlobalFunctions.CreateObject(ResourceKey.FromString("319e4f1d:00000000:4d2d76202832ac21"),
                                                        src.PositionOnFloor, src.mLevel, src.ForwardVector) as RestockItem;
                }
                else
                {
                    item = GlobalFunctions.CreateObject(ResourceKey.FromString("319e4f1d:00000000:74eadf6231a9cf5e"),
                                                        src.PositionOnFloor, src.mLevel, src.ForwardVector) as RestockItem;
                }
                item.info.Key   = src.GetResourceKeyForClone(true);
                item.info.Type  = RestockItemHelperClass.GetItemType(src);
                item.info.Name  = src.GetLocalizedName();
                item.info.Price = value;

                switch (item.info.Type)
                {
                case ItemType.Buy:
                case ItemType.Craftable:
                    item.info.DesignPreset = ObjectDesigner.GetObjectDesignPreset(src.ObjectId);
                    break;

                case ItemType.Ingredient:
                    //item.info.IngData = (IngredientData)((Ingredient)src).Data;
                    // item.info.Key = ((Ingredient)src).GetResourceKey();
                    //item.info.IngredientKey = ((Ingredient)src).IngredientKey;
                    break;

                case ItemType.Fish:
                    item.info.FType = ((Fish)src).mFishType;
                    break;

                case ItemType.Herb:
                    //item.info.PlantData = ((PlantableNonIngredient)src).mData;
                    // item.info.Key = ((Herb)src).GetResourceKey();
                    break;

                case ItemType.Metal:
                    item.info.RockData = ((Metal)src).mGuid;
                    item.info.Key      = ((Metal)src).GetResourceKey();
                    break;

                case ItemType.Gem:
                    item.info.RockData = ((Gem)src).mGuid;
                    item.info.Key      = ((Gem)src).GetResourceKey();
                    break;

                case ItemType.Nectar:
                    item.info.Key       = ((NectarBottle)src).GetResourceKey();
                    item.info.NectarAge = ((NectarBottle)src).mBottleInfo.DateNum;

                    if (item.info.NectarAge == 0)
                    {
                        item.info.NectarAge = 1;
                    }

                    item.info.NectarFruitHash   = ((NectarBottle)src).mBottleInfo.FruitHash;
                    item.info.NectarIngredients = ((NectarBottle)src).Ingredients;                    //.in.mBottleInfo;
                    break;

                case ItemType.AlchemyPotion:

                    break;

                case ItemType.Bug:
                    item.info.BugType = ((NormalTerrarium)src).mInsectType;
                    break;

                case ItemType.Food:
                    item.info.cookingProcess = ((ServingContainer)src).CookingProcess;
                    break;

                case ItemType.Flowers:
                    item.info.TypeOfWildFlower = ((Wildflower)src).TypeOfWildFlower;
                    break;

                case ItemType.BookAlchemyRecipe_:
                case ItemType.BookComic_:
                case ItemType.BookFish_:
                case ItemType.BookGeneral_:
                case ItemType.BookRecipe_:
                case ItemType.BookSkill_:
                case ItemType.BookToddler_:
                case ItemType.SheetMusic_:
                case ItemType.AcademicTextBook_:
                    item.info.Name = ((Book)src).CatalogName;
                    break;

                case ItemType.JamJar:
                    Type         tInfo = src.GetType();
                    BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
                    FieldInfo    ingredientDataField = tInfo.GetField("mData", flags);
                    FieldInfo    ingredientKeyField  = tInfo.GetField("mIngredientKey", flags);
                    FieldInfo    qualityField        = tInfo.GetField("mQuality", flags);
                    FieldInfo    preservesField      = tInfo.GetField("mIsPreserves", flags);

                    item.info.IngData       = (IngredientData)ingredientDataField.GetValue(src);
                    item.info.IngredientKey = (string)ingredientKeyField.GetValue(src);
                    item.info.JamQuality    = (Quality)qualityField.GetValue(src);
                    item.info.JamIsPreserve = (bool)preservesField.GetValue(src);
                    break;

                default:
                    break;
                }
                return(item);
            }
            catch (System.Exception ex)
            {
                CMStoreSet.PrintMessage("CreateRestockItem: " + ex.Message);
                return(null);
            }
        }
Exemple #4
0
        public static bool AddPurchaseInteraction(Sim sim, GameObject o, StoreSetBase sBase, bool isAutonomous)
        {
            if (o.GetType() == typeof(FoodProp))
            {
                return(false);
            }

            if (o.GetType() == typeof(RestockItem))
            {
                return(false);
            }

            if (o.Charred)
            {
                return(false);
            }

            //Custom tests
            //Find register and then the owner
            if (sim != null && sBase != null)
            {
                StoreSetRegister register = null;

                if (sBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
                {
                    register = CMStoreSet.ReturnRegister(sBase.Info.RegisterId, sBase.LotCurrent);
                }

                //If linked to register and nobody tending, can't buy
                //TODO

                //If sim is not in the active household and BuyWhenActive = true
                //Can buy autonomously only if store owner is the active hosuehold
                if (isAutonomous && StoreSetBase.ReturnBuyWhenActive())
                {
                    SimDescription owner = null;

                    if (sBase.Info.Owner != 0uL)
                    {
                        owner = CMStoreSet.ReturnSim(sBase.Info.Owner);
                    }
                    else if (sBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
                    {
                        if (register != null && register.Info.OwnerId != 0uL)
                        {
                            owner = CMStoreSet.ReturnSim(register.Info.OwnerId);
                        }
                    }

                    //in-active sims shouldn't buy unless from the store of the active sim
                    if ((!sim.Household.IsActive && owner == null) || (!sim.Household.IsActive && owner != null && !owner.Household.IsActive))
                    {
                        return(false);
                    }

                    //Sims in the active household can buy if they don't own the store
                    if (sim.Household.IsActive && owner != null && owner.Household.IsActive)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }