private object StrToObject(string str)
        {
            int    ClassStrStart       = str.IndexOf('?') + 1;
            int    ClassStrEnd         = str.IndexOf('{');
            int    ClassDeclarationEnd = GetCloseBracketPos(str, ClassStrEnd);
            string class_str           = str.Substring(ClassStrStart, ClassStrEnd - ClassStrStart);
            Type   ClassType           = Type.GetType(class_str, false, true);
            object obj = Activator.CreateInstance(ClassType);

            str = str.Substring(ClassStrEnd + 1, ClassDeclarationEnd - ClassStrEnd - 1);

            var SubObjects = new List <object>();

            while (str.Contains("?"))
            {
                SubObjects.Add(StrToObject(str));
                int remStart = str.IndexOf("?");
                int remEnd   = GetCloseBracketPos(str, remStart);
                str = str.Remove(remStart, remEnd - remStart + 1);
            }

            string[] ItemList = str.Split(';');
            foreach (string item in ItemList)
            {
                if (item != "")
                {
                    string FieldStr = item.Split(':')[0];
                    string value    = item.Split(':')[1];

                    foreach (FieldInfo field in ClassType.GetFields())
                    {
                        if (field.Name == FieldStr)
                        {
                            if (value != "")
                            {
                                SetFieldValue(obj, field, value);
                            }
                            else
                            {
                                foreach (object SubObj in SubObjects)
                                {
                                    if (field.FieldType == SubObj.GetType())
                                    {
                                        field.SetValue(obj, SubObj);
                                        SubObjects.Remove(SubObj);
                                        break;
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
            }
            return(obj);
        }
Пример #2
0
 public void Draw(SpriteBatch spriteBatch)
 {
     backround.Draw(spriteBatch);
     foreach (MenuObject obj in objects)
     {
         obj.Draw(spriteBatch);
     }
     foreach (MenuObject SubObj in subObjects)
     {
         SubObj.Draw(spriteBatch);
     }
 }
Пример #3
0
    void ShowGrassObj(bool show)
    {
        GrassShow = show;

        GameObject SubObj;

        for (int i = 0; i < gameObject.transform.childCount; i++)
        {
            SubObj = gameObject.transform.GetChild(i).gameObject;
            if (SubObj.name.Contains("grass") || SubObj.name.Contains("flare"))
            {
                SubObj.SetActive(GrassShow);
            }
        }
    }
Пример #4
0
        public void Load(ContentManager Content)
        {
            backround = new Backround(Content.Load <Texture2D>("Textures/Backrounds/BackroundOptions"), new Rectangle(0, 0, graphicsDevice.PreferredBackBufferWidth, graphicsDevice.PreferredBackBufferHeight));
            if (graphicsDevice.IsFullScreen)
            {
                ScreenMode = "FullScreen";
            }
            else
            {
                ScreenMode = "Window";
            }

            select = Content.Load <SoundEffect>("Sounds/MenuSelect");
            push   = Content.Load <SoundEffect>("Sounds/MenuPush");
            back   = Content.Load <SoundEffect>("Sounds/MenuBack");
            choose = Content.Load <SoundEffect>("Sounds/MenuSelect");

            size = new Vector2(graphicsDevice.PreferredBackBufferWidth / 16, graphicsDevice.PreferredBackBufferHeight / 16);
            Vector2 center = new Vector2(graphicsDevice.PreferredBackBufferWidth / 2, graphicsDevice.PreferredBackBufferHeight / 2);

            objects.Add(new MenuObject(new Rectangle((int)(center.X - size.X * 2), (int)(center.Y + size.Y * 2 - size.Y * 5), (int)size.X, (int)size.Y), "Music"));
            objects.Add(new MenuObject(new Rectangle((int)(center.X - size.X * 2), (int)(center.Y + size.Y * 2 - size.Y * 4), (int)size.X, (int)size.Y), "ScreenMode"));
            objects.Add(new MenuObject(new Rectangle((int)(center.X - size.X * 2), (int)(center.Y + size.Y * 2 - size.Y * 3), (int)size.X, (int)size.Y), "Level"));
            objects.Add(new MenuObject(new Rectangle((int)(center.X - size.X * 2), (int)(center.Y + size.Y * 2 - size.Y * 2), (int)size.X, (int)size.Y), "Health"));
            objects.Add(new MenuObject(new Rectangle((int)(center.X - size.X * 2), (int)(center.Y + size.Y * 2 - size.Y * 1), (int)size.X, (int)size.Y), "Back to Menu"));

            //Default
            CanChange   = false;
            level       = 1;
            healthPoint = 3;

            subObjects.Add(new MenuObject(new Rectangle((int)(center.X + size.X * 2), (int)(center.Y + size.Y * 2 - size.Y * 5), (int)size.X, (int)size.Y), ((int)(MediaPlayer.Volume * 100)).ToString() + " % "));
            subObjects.Add(new MenuObject(new Rectangle((int)(center.X + size.X * 2), (int)(center.Y + size.Y * 2 - size.Y * 4), (int)size.X, (int)size.Y), ScreenMode));
            subObjects.Add(new MenuObject(new Rectangle((int)(center.X + size.X * 2), (int)(center.Y + size.Y * 2 - size.Y * 3), (int)size.X, (int)size.Y), level.ToString()));
            subObjects.Add(new MenuObject(new Rectangle((int)(center.X + size.X * 2), (int)(center.Y + size.Y * 2 - size.Y * 2), (int)size.X, (int)size.Y), healthPoint.ToString()));

            foreach (MenuObject obj in objects)
            {
                obj.Load(Content);
            }
            foreach (MenuObject SubObj in subObjects)
            {
                SubObj.Load(Content);
            }


            SelecRect = new Rectangle((int)(center.X - size.X * 2), (int)(center.Y - size.Y * 5), (int)size.X, (int)size.Y);
        }
Пример #5
0
        public void LoadModel(EFile file, API_Device D)
        {
            List<List<Vector3>> verts = new List<List<Vector3>>();
            List<List<Vector3>> tverts = new List<List<Vector3>>();
            List<List<int>> faces = new List<List<int>>();
            List<int> vcounts = new List<int>();
            List<int> icounts = new List<int>();
            List<string> matnames = new List<string>();
            int allinds = 0;
            int allverts = 0;
            int numoldverts = 0;
            float x = 0, y = 0, z = 0, u = 0, v = 0, w = 0;

            this.SubObjekte = new List<SubObj>();
            //FileStream fStream = new FileStream(file., FileMode.Open, FileAccess.Read);
            Stream fStream = file.Open(FileAccess.Read);
            bReader = new BinaryReader(fStream);
            Skip(70);
            int vd = bReader.ReadInt32();
            Skip(53);
            numSubMehshes = bReader.ReadInt32();
            for (int h = 0; h < numSubMehshes; h++)
            {
                verts.Add(new List<Vector3>());
                tverts.Add(new List<Vector3>());
                faces.Add(new List<int>());
                Suche((int)vd, 77, 97, 116, 101, 114, 105, 97, 108);
                Skip(20);
                short len = Math.Abs(bReader.ReadInt16());
                //string name = bReader.ReadString();
                //matnames.Add(name.Replace("._xmat", ".dds"));
                byte[] namebs = bReader.ReadBytes(len);
                string name = new System.Text.ASCIIEncoding().GetString(namebs);
                matnames.Add(name);
                Suche((int)vd, 73, 110, 100, 101, 120, 67, 111, 117, 110, 116);
                Skip(12);
                int indcount = Math.Abs(bReader.ReadInt32());
                icounts.Add(indcount);
                allinds += indcount;
                Skip(54);
                int vertcount = Math.Abs(bReader.ReadInt32());
                vcounts.Add(vertcount);
                allverts += vertcount;
            }
            bReader.BaseStream.Position = (vd + 202);
            int vdsize = Math.Abs(bReader.ReadInt32());
            Skip(12);
            int o = Math.Abs(bReader.ReadInt32());
            o /= 4;
            Skip(56);
            int svd = (int)bReader.BaseStream.Position;
            for (int ii = 0; ii < numSubMehshes; ii++)
            {
                for (int i = 0; i < (o * vcounts[ii]) ; i++)
                {
                    float f = bReader.ReadSingle();
                    int id = (i + 1) % o;
                    if (id == 1)
                    {
                        y = -f;
                    }
                    if (id == 2)
                    {
                        z = f;
                    }
                    if (id == 3)
                    {
                        x = f;
                        verts[ii].Add(new Vector3(x,y,z));
                    }
                    if (o == 13)
                    {
                        if (id == 11)
                        {
                            w = f;
                        }
                        if (id == 12)
                        {
                            u = f;
                        }
                        if (id == 0)
                        {
                            v = f;//v = 1 - f;
                            tverts[ii].Add(new Vector3(u,v,w));
                        }
                    }
                   if (o == 15)
                    {
                        if (id == 11)
                        {
                             w = f;
                        }
                        if (id == 12)
                        {
                            u = f;
                        }
                        if (id == 13)
                        {
                            v = f;
                            tverts[ii].Add(new Vector3(u,v,w));
                        }
                    }
                }
            }
            for (int jj = 0; jj < numSubMehshes; jj++)
            {
                for (int n = 0; n < icounts[jj]; n++)
                {
                    int f = (int)bReader.ReadUInt32();
                    f -= numoldverts;
                    float id = (n + 1) % 3;
                    if (id == 1)
                    {
                        x = f;
                    }
                    if (id == 2)
                    {
                        y = f;
                    }
                    if (id == 0)
                    {
                        z = f;
                        faces[jj].Add((int)x);
                        faces[jj].Add((int)y);
                        faces[jj].Add((int)z);
                    }
                }
                numoldverts += vcounts[jj];
            }
            for (int s = 0; s < numSubMehshes; s++)
            {
                SubObj so = new SubObj(matnames[s], s);
                List<Tri> ts = new List<Tri>();
                for (int fl = 0; fl < faces[s].Count; fl += 3)
                    ts.Add(new Tri(faces[s][fl], faces[s][fl + 1], faces[s][fl + 2], faces[s][fl], faces[s][fl + 1], faces[s][fl + 2], faces[s][fl], faces[s][fl + 1], faces[s][fl + 2], s));
                int c = verts[s].Count + 1;
                Vector3[] vtmp = new Vector3[c];
                List<Vector3> ns = new List<Vector3>(vtmp);
                for (int h = 0; h < verts[s].Count; h++)
                    verts[s][h] = Vector3.Transform(verts[s][h], mRot).ToVec3();
                var tmp = SubObj.CreateData(verts[s], tverts[s], ns, ts);
                so.CreateVertexBuffer(tmp, true);
                so.LoadMaterial(D);
                SubObjekte.Add(so);
            }
            file.Close();
        }
Пример #6
0
        public void LoadModel(EFile file, API_Device D)
        {
            //fStream = new FileStream(FileName, FileMode.Open, FileAccess.Read);
            fStream = file.Open(FileAccess.Read);
            bReader = new BinaryReader(fStream);

            Seek(136);
            UInt32 xacFileSize = bReader.ReadUInt32();
            char[] cs = bReader.ReadChars(3);
            string s = cs[0].ToString() + cs[1].ToString() + cs[2].ToString();
            if (s != "XAC")
                throw new Exception("This is not a valid XMAC file.");
            Seek(146);
            if (bReader.ReadByte() != 0)
            {
                long p = bReader.BaseStream.Position;
                bReader = new bReader2(fStream);
                bReader.BaseStream.Position = p;
            }
            Seek(148);
            while ((xacFileSize + 140) != Tell())
            {
                UInt32 secID = bReader.ReadUInt32();
                if (secID == 1)
                { // Mesh.
                    readMeshSection();
                }
                else if (secID == 2)
                { // Weighting.
                    readWeightingSection();
                }
                else if (secID == 7)
                { // General scene information.
                    readInfoSection();
                }
                else if (secID == 11)
                { // Nodes.
                    readNodesSection();
                }
                else if (secID == 13)
                { // Mats.
                    readMatsSection();
                }
                // (secID == 3) would belong to "MatSection" but all of them are read by readMatsSection().
                //else throw new EngineError("Unknown Error", EngineErrorType.NoInformation);
                else break;//this prevents it from crashing while loading faces, some other models can't be seen when this is activated due to some problems
            }

            var tmp = SubObj.CreateData(Vertices, TVertices, Normals, Tris);
            for (int i = 0; i < Materials.Count; i++)
            {
                if ((Materials[i].n.Contains("EMFX")) || (Materials[i].n.Contains("collision", StringComparison.CurrentCultureIgnoreCase)))
                    continue;
                string qs = Materials[i].n;
                SubObj so = new SubObj(qs, i);
                so.CreateVertexBuffer(tmp, true);
                so.LoadMaterial(D);
                SubObjekte.Add(so);
                //Matrix rm = Matrix.RotationAxis(Vector3.UnitY, MathHelper.PiOver2);
                //for (int i2 = 0; i2 < so.Vertices.Length; i2++)
                //    so.Vertices[i2].Position = Core.TransformVec3(so.Vertices[i2].Position.ToVec3(), rm).ToVec4(1.0f);
            }
            SubObjekte.Remove(null);
        }
Пример #7
0
 private void _readLE()
 {
     _insides = new SubObj(m_io, this, m_root, m_isLe);
 }