コード例 #1
0
ファイル: MainScript.cs プロジェクト: Ckpyt/ColonyRuler-code
    /// <summary>
    /// Starting new game
    /// </summary>
    public void StartGame()
    {
        m_isItInitialized = false;
        GameInitialization();
        Loading();
        PlaceOpenedItems(AbstractObject.GetOpennedItems());
        m_isItInitialized = true;

        LearningTip.CreateTip("tip1");
    }
コード例 #2
0
ファイル: Save.cs プロジェクト: Ckpyt/ColonyRuler-code
    /// <summary>
    /// load game from json string
    /// !!! move it to Game !!!
    /// </summary>
    void Load(string json)
    {
        Game       gm = Game.Load(json);
        MainScript ms = Camera.main.GetComponent <MainScript>();

        ms.ClearEverything();
        ms.Loading();

        CopyItems(gm.m_allArmy);
        CopyItems(gm.m_allBuildings);
        CopyItems(gm.m_allItems);
        CopyItems(gm.m_allMaterails);
        CopyItems(gm.m_allScience);
        CopyItems(gm.m_allResources);
        CopyItems(gm.m_allProcesses);
        CopyItems(gm.m_allWildAnimals);
        CopyItems(gm.m_allDomestic);

        AbstractObject.m_sEverything[AbstractObject.m_sEverything.Count - 1].
        Copy(gm.m_population);

        ms.PlaceOpenedItems(AbstractObject.GetOpennedItems());

        CopyTools(gm.m_allArmy);
        CopyTools(gm.m_allBuildings);
        CopyTools(gm.m_allItems);
        CopyTools(gm.m_allMaterails);
        CopyTools(gm.m_allProcesses);

        foreach (GameObject go in MainScript.m_sAllItems)
        {
            try
            {
                IconScript    ics = go.GetComponent <IconScript>();
                Game.GameIcon gic = null;
                foreach (var itm in gm.m_allGameIcons)
                {
                    if (itm.m_itmName == ics.m_thisItem.m_name)
                    {
                        gic = itm;
                        break;
                    }
                }
                if (gic == null)
                {
                    continue;             //throw new System.Exception("Object not found");
                }
                gm.m_allGameIcons.Remove(gic);
                ics.transform.position = gic.m_pos;
            }
            catch (Exception ex)
            {
                Debug.Log(ex.Message);
            }
        }

#if !UNITY_WEBGL
        Localization.GetLocalization().ChangeLanguage(Settings.GetSettings().m_localization.m_currentLanguage);
#endif
        TimeScript tsc = Camera.main.GetComponent <TimeScript>();
        tsc.m_day   = gm.m_day;
        tsc.m_year  = gm.m_year;
        tsc.m_speed = gm.m_speed;

        LearningTip.m_sCanShow = gm.m_canShowTooltips;

        gameObject.SetActive(false);
    }