コード例 #1
0
ファイル: FrmPrincipal.cs プロジェクト: brunoviske/CogEngine
 private void CarregarCena(CenaWinForm cena)
 {
     GrpGameView.Controls.Clear();
     GrpGameView.Controls.Add(cena.Painel);
     _CenaAtual = cena;
 }
コード例 #2
0
ファイル: Jogo.cs プロジェクト: brunoviske/CogEngine
        private void LerArquivoProjeto()
        {
            Type type = typeof(ConcentradorObjeto);
            Type baseInterface;
            ConcentradorObjeto o;
            XmlAttribute attribute;
            PropertyInfo p;

            XmlDocument document = new XmlDocument();
            document.Load(Arquivo);

            XmlNode scripts = document.GetElementsByTagName("Scripts")[0];
            if (scripts.ChildNodes != null)
            {
                foreach (XmlNode scriptNode in scripts.ChildNodes)
                {
                    Script script = new Script();
                    script.NomeAmigavel = scriptNode.Attributes.GetNamedItem("Nome").Value;
                    script.ID = scriptNode.Attributes.GetNamedItem("ID").Value;
                    script.CodigoScript = scriptNode.Attributes.GetNamedItem("Codigo").Value;
                    ListaScripts.Add(script);
                }
            }
            XmlNode jogo = document.GetElementsByTagName("Jogo")[0];

            //Itero as cenas do jogo
            Cena cena;
            foreach (XmlNode cenaNode in jogo.SelectNodes("Cena"))
            {
                cena = new CenaWinForm();
                cena.Nome = cenaNode.Attributes["Nome"].Value;
                cena.Cor = System.Drawing.Color.FromArgb(int.Parse(cenaNode.Attributes["Cor"].Value));

                //Adiciono a lista de cenas para controle
                ListaCena.Add(cena);

                //Itero os objetos
                Type typeOriginal;
                foreach (XmlNode objetoNode in cenaNode.SelectNodes("Objetos/Objeto"))
                {
                    typeOriginal = Assembly.GetAssembly(type).GetType(objetoNode.Attributes["type"].Value);
                    o = (ConcentradorObjeto)typeOriginal.GetConstructor(new Type[] { typeof(Jogo) }).Invoke(new object[] { this });
                    baseInterface = o.BaseInterface;
                    foreach (XmlNode nodeProp in objetoNode.ChildNodes[0].ChildNodes)
                    {
                        attribute = nodeProp.Attributes[0];
                        if (attribute.Name == "Nome")
                        {
                            o.Nome = attribute.Value;
                        }
                        else
                        {
                            p = baseInterface.GetProperty(attribute.Name);
                            if (p.PropertyType == typeof(int))
                            {
                                p.SetValue(o.WinControl, Convert.ToInt32(attribute.Value), null);
                            }
                            else if (p.PropertyType == typeof(float))
                            {
                                p.SetValue(o.WinControl, float.Parse(attribute.Value), null);
                            }
                            else if (p.PropertyType == typeof(System.Drawing.Color))
                            {
                                System.Drawing.Color c = System.Drawing.Color.FromArgb(int.Parse(attribute.Value));
                                p.SetValue(o.WinControl, c, null);
                            }
                            else
                            {
                                p.SetValue(o.WinControl, attribute.Value, null);
                            }
                        }
                    }

                    //Atribuo o script caso exista
                    if (objetoNode.ChildNodes.Count > 1)
                    {
                        o.WinControl.IDScript = objetoNode.ChildNodes[1].Attributes[1].Value;
                    }
                    cena.AdicionarObjeto(o);
                }
            }

            Som som;
            foreach (XmlNode nodeSom in jogo.SelectNodes("Sons/Som"))
            {
                som = new SomWinForm(this);
                attribute = nodeSom.Attributes["CaminhoArquivo"];
                som.CaminhoRelativo = attribute.Value;
                attribute = nodeSom.Attributes["Nome"];
                som.Nome = attribute.Value;
                ListaSom.Add(som);
            }
        }
コード例 #3
0
ファイル: FrmPrincipal.cs プロジェクト: brunoviske/CogEngine
 private CenaWinForm AdicionarCena(string nome)
 {
     CenaWinForm cena = new CenaWinForm();
     cena.Nome = nome;
     cena.Painel.Size = GrpGameView.Size;
     cena.OnNomeChanged += OnNomeChanged;
     cena.AlteracaoObjeto += ListaAlterada;
     ProjetoJogo.AdicionarCena(cena);
     CarregarCena(cena);
     return cena;
 }
コード例 #4
0
ファイル: Jogo.cs プロジェクト: brunoviske/CogEngine
 public static Jogo CriarProjeto(string pasta, string nomeJogo)
 {
     if (!pasta.EndsWith("\\")) pasta += '\\';
     string caminhoArquivo = pasta + nomeJogo + EXTENSAO_PROJETO;
     Jogo jogo = new Jogo(caminhoArquivo);
     CriarEstruturaPasta(pasta, true);
     CenaWinForm cena = new CenaWinForm();
     cena.Nome = "Principal";
     jogo.ListaCena.Add(cena);
     return jogo;
 }