Ejemplo n.º 1
0
    private void PrepareLoading()
    {
        PanelMainMenu.SetActive(false);
        PanelBeforeMission.SetActive(false);
        PanelAfterMission.SetActive(false);
        PanelLoadingMission.SetActive(false);
        PanelLoading.SetActive(true);
        PanelMissionFailed.SetActive(false);
        PanelMinigame.SetActive(false);
        PanelSettings.SetActive(false);

        PanelLoading.GetComponent <PanelLoading>().TextTop = "Loading data";
        PanelLoading.GetComponent <PanelLoading>().TextTap = "";
        StartCoroutine(LoadDataCoroutine());
    }
Ejemplo n.º 2
0
    private void ParseInitialData(JSONNode n)
    {
        XmlDocument model = new XmlDocument();

        UserName = n["userName"].Value;
        string modelString = WWW.UnEscapeURL(n["model"]);

        model.LoadXml(modelString);

        XmlNode defaultsXml = model.GetElementsByTagName("defaults")[0];

        Dictionary <StatType, Dictionary <Element, float> > defaultStats = ParseStats(defaultsXml.ChildNodes);

        foreach (XmlNode buildingXml in model.GetElementsByTagName("building"))
        {
            Dictionary <StatType, Dictionary <Element, float> > thisStats = ParseStats(buildingXml.ChildNodes);
            foreach (StatType st in defaultStats.Keys.ToList())
            {
                foreach (Element el in defaultStats[st].Keys.ToList())
                {
                    if (!thisStats.ContainsKey(st))
                    {
                        thisStats.Add(st, defaultStats[st]);
                    }
                    if (!thisStats[st].ContainsKey(el))
                    {
                        thisStats[st].Add(el, defaultStats[st][el]);
                    }
                }
            }
            int    id         = int.Parse(buildingXml.Attributes["id"].Value);
            string name       = buildingXml.Attributes["name"].Value;
            int    population = int.Parse(buildingXml.Attributes["population"].Value);
            string imagePath  = buildingXml.Attributes["image"].Value;
            string imageDPath = buildingXml.Attributes["imageDestroyed"].Value;
            float  health     = float.Parse(buildingXml.Attributes["health"].Value == "" ? "1" : buildingXml.Attributes["health"].Value);

            Dictionary <Element, Sprite[]> effects = new Dictionary <Element, Sprite[]>();
            string fireEffectPath = buildingXml.Attributes["fireEffect"].Value == "" ? SpriteManager.DefaultEffectPaths[Element.Fire] : buildingXml.Attributes["fireEffect"].Value;
            effects.Add(Element.Fire, SpriteManager.ElementPerBuildingSprites[fireEffectPath]);

            string waterEffectPath = buildingXml.Attributes["waterEffect"].Value == "" ? SpriteManager.DefaultEffectPaths[Element.Water] : buildingXml.Attributes["waterEffect"].Value;
            effects.Add(Element.Water, SpriteManager.ElementPerBuildingSprites[waterEffectPath]);

            string electricityEffectPath = buildingXml.Attributes["electricityEffect"].Value == "" ? SpriteManager.DefaultEffectPaths[Element.Electricity] : buildingXml.Attributes["electricityEffect"].Value;
            effects.Add(Element.Electricity, SpriteManager.ElementPerBuildingSprites[electricityEffectPath]);

            string smokeAfterFireffectPath = buildingXml.Attributes["smokeAfterFireEffect"].Value == "" ? SpriteManager.DefaultEffectPaths[Element.SmokeAfterFire]: buildingXml.Attributes["smokeAfterFireEffect"].Value;
            effects.Add(Element.SmokeAfterFire, SpriteManager.ElementPerBuildingSprites[smokeAfterFireffectPath]);

            string crushEffectPath = buildingXml.Attributes["crushEffect"].Value == "" ? SpriteManager.DefaultEffectPaths[Element.Crush] : buildingXml.Attributes["crushEffect"].Value;
            effects.Add(Element.Crush, SpriteManager.ElementPerBuildingSprites[crushEffectPath]);

            string dieEffectPath = buildingXml.Attributes["dieEffect"].Value == "" ? SpriteManager.DefaultEffectPaths[Element.Die] : buildingXml.Attributes["dieEffect"].Value;
            effects.Add(Element.Die, SpriteManager.ElementPerBuildingSprites[dieEffectPath]);

            BuildingTemplates.Add(id, new BuildingTemplate(id, name, population, health, imagePath, imageDPath, thisStats, effects));
        }

        foreach (XmlNode power in model.GetElementsByTagName("power"))
        {
            TouchPowers.Add((Element)power.Attributes["elId"].Value);
        }

        PanelLoading pl = PanelLoading.GetComponent <PanelLoading>();

        PanelLoading.SetActive(false);
        PanelMainMenu.SetActive(true);
        PanelBeforeMission.SetActive(false);
        PanelAfterMission.SetActive(false);
        PanelLoadingMission.SetActive(false);
    }