Пример #1
0
    public void HandleMessage(int flags, ISFSObject msgObj)
    {
        ProductValueType valueType = ProductHelper.GetProductValueType(flags);

        if (valueType != ProductValueType.TAB)
        {
            string newValue       = msgObj.GetUtfString("v");
            string newSliderValue = msgObj.GetUtfString("sv");
            switch (valueType)
            {
            case ProductValueType.PRODUCTION:
                UpdateProductValue(valueType, newValue, newSliderValue, ref production);
                UpdateProductionDisplay();
                break;

            case ProductValueType.MARKETING_BUDGET:
                UpdateProductValue(valueType, newValue, newSliderValue, ref marketingBudget);
                UpdateMarketingBudgetDisplay();
                break;

            case ProductValueType.SALES_PRICE:
                UpdateProductValue(valueType, newValue, newSliderValue, ref sales);
                break;
            }
        }
        else
        {
            Debug.LogError("Tab switches should be handled via a room variable now.");
        }
    }
Пример #2
0
 private void UpdateProductValue(ProductValueType valueType, string newValue, string newSliderValue, ref ProductVals valsToUpdate)
 {
     UpdateSlider(ProductHelper.GetSliderElemName(valueType), newSliderValue);
     UpdateDisplayValue(ProductHelper.GetValueDivName(valueType, IDTag), newValue);
     valsToUpdate.val       = newValue;
     valsToUpdate.sliderVal = newSliderValue;
 }
Пример #3
0
    private void UpdateValueType(ProductValueType productType, ref ProductVals currentVals)
    {
        if (productType == ProductValueType.TAB)
        {
            string newVal = GetActiveTab();
            if (newVal != currentActiveTab && newVal != "")
            {
                currentActiveTab = newVal;
                dirtyFlags      |= (int)productType;
            }
        }
        else
        {
            ProductVals newVals  = new ProductVals();
            string      elemName = ProductHelper.GetValueDivName(productType, IDTag);
            string      cmd      = ProductHelper.GetDisplayValueCmd(elemName);
            newVals.val = GetCmdStrResult(cmd);
            if (newVals.val != currentVals.val)
            {
                elemName          = ProductHelper.GetSliderElemName(productType);
                cmd               = ProductHelper.GetSliderPositionCmd(elemName);
                newVals.sliderVal = GetCmdStrResult(cmd);

                currentVals = newVals;
                dirtyFlags |= (int)productType;
            }
        }
    }
Пример #4
0
    public static string GetSliderElemName(ProductValueType valueType)
    {
        switch (valueType)
        {
        case ProductValueType.SALES_PRICE:
            return("sl0slider");

        case ProductValueType.MARKETING_BUDGET:
            return("sl1slider");

        case ProductValueType.PRODUCTION:
            return("sl2slider");

        default:
            Debug.LogError("Unhandled product id: " + valueType);     // should assert instead.
            return("");
        }
    }
Пример #5
0
    public static string GetValueDivName(ProductValueType valueType, string idTag)
    {
        string productID = "";

        switch (valueType)
        {
        case ProductValueType.SALES_PRICE:
            productID = "P";
            break;

        case ProductValueType.MARKETING_BUDGET:
            productID = "M";
            break;

        case ProductValueType.PRODUCTION:
            productID = "L";
            break;

        default:
            Debug.LogError("Unhandled product id: " + valueType);     // should assert instead.
            return("");
        }
        return("ajaxDiv_" + productID + "_" + idTag);
    }
Пример #6
0
    public string GetDisplayValue(ProductValueType valueType)
    {
        string cmd = ProductHelper.GetDisplayValueCmd(ProductHelper.GetValueDivName(valueType, IDTag));

        return(GetCmdStrResult(cmd));
    }