Exemplo n.º 1
0
    private void _ShowMainMenu()
    {
        // Create main menu stuff
        CToolkitUI ui = CGame.ToolkitUI;

        CJSONParser json       = new CJSONParser();
        CJSONValue  levelArray = json.Parse(CGame.DataDirectory + "campaign.txt");

        GameObject button;

        if (levelArray != null)
        {
            int levelCount = 0;

            for (int i = 0; i < levelArray.GetCount(); ++i)
            {
                CJSONValue level = levelArray[i];

                string levelName = level.GetString("name", "unknown");
                string assetName = level.GetString("asset", "unknown");
                bool   playable  = level.GetBool("playable");
                bool   visible   = level.GetBool("visible");

                if (visible)
                {
                    button = ui.CreateMenuButton(_base, levelName + " (" + assetName + ".pwa)", () =>
                    {
                        CGame.UIManager.PlaySound(CGame.PrimaryResources.AudioClips[15]);
                        _PlayLevel(assetName);
                    }, 1, playable);
                    ui.SetTransform(button, 50, -100 - (levelCount++ *30), 512, 50);
                }
            }
        }

        /*
         * button = CreateButton(_base, "Sample (cutscene)", null);
         * ui.SetTransform(button, 50, -150, 256, 50);
         */

        /*
         * button = CreateButton(_base, "Multiplayer", null);
         * ui.SetTransform(button, 50, -200, 256, 50);
         *
         * button = CreateButton(_base, "Options", null);
         * ui.SetTransform(button, 50, -250, 256, 50);
         */

        button = ui.CreateMenuButton(_base, "Quit", _Exit);
        ui.SetTransform(button, 50, -30, 256, 50);
    }
Exemplo n.º 2
0
    public CUnitRules()
    {
        mTiers = new List <CTierInfo>();
        CJSONParser tiers      = new CJSONParser();
        CJSONValue  tiersArray = tiers.Parse(CGame.DataDirectory + "rules.txt");

        if (tiersArray == null)
        {
            Debug.LogError("Can't load rules");
            return;
        }

        for (int i = 0; i < tiersArray.GetCount(); ++i)
        {
            CJSONValue t = tiersArray[i];

            CTierInfo tier = new CTierInfo();
            tier.mTitle     = t.GetString("title", "unknown");
            tier.mTierIndex = i;
            tier.mMaxLevel  = t.GetInt("max_level");
            tier.mSalary.Set(t["salary"]);
            tier.mIntelligence.Set(t["intelligence"]);
            tier.mMaxStamina.Set(t["max_stamina"]);
            tier.mMaxSpeed.Set(t["max_speed"]);
            tier.mHungerRate.Set(t["hunger_rate"]);
            tier.mMaxHunger.Set(t["max_hunger"]);
            tier.mPaperCapacity.Set(t["paper_capacity"]);
            tier.mAttackDamage.Set(t["attack_damage"]);
            tier.mDefense.Set(t["defense"]);
            tier.mIdleTime.Set(t["idle_time"]);
            tier.mWorkStaminaRate.Set(t["work_stamina_rate"]);
            tier.mRequiredXP.Set(t["required_xp"]);
            tier.mPromotionDemand.Set(t["promotion_demand"]);
            mTiers.Add(tier);
        }
    }