예제 #1
0
        public void WriteTable(ResourceTable table, Stream stream)
        {
            this.stream = stream;

            using (writer = new BinaryWriter(stream))
            {
                writer.Write(Encoding.ASCII.GetBytes("WigRTB 1.0\0\0"));
                writer.Write(table.contents.Count);
                if (table.directories.Count != 4)
                {
                    throw new ArgumentOutOfRangeException("table", "RTB file must have exactly 4 directories!");
                }
                foreach (var directory in table.directories)
                {
                    writer.Write(Encoding.ASCII.GetBytes(directory + "\0"));
                    writer.Write(Enumerable.Repeat((byte)0xCD, (260 - (directory.Length + 1))).ToArray());
                }
                foreach (var file in table.contents)
                {
                    writer.Write(file.Key);                                         // id
                    writer.Write(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF });
                    writer.Write(Encoding.ASCII.GetBytes(file.Value + "\0\0\0\0")); // filename
                }
            }
        }
예제 #2
0
        /**
         * parse resource table.
         */
        private async Task parseResourceTable()
        {
            byte[] data = await getFileData(AndroidConstants.RESOURCE_FILE);

            //byte[] data = await getFileData(Disassembly.Util.CurrentApp.localAppRoot.Path + "\\" + AndroidConstants.RESOURCE_FILE);
            if (data == null)
            {
                // if no resource entry has been found, we assume it is not needed by this APK
                this.resourceTable = new ResourceTable();
                //this.locales = Collections.emptySet();
                this.locales = new HashSet <CultureInfo>();
                return;
            }

            this.resourceTable = new ResourceTable();
            //this.locales = Collections.emptySet();
            this.locales = new HashSet <CultureInfo>();

            ByteBuffer          buffer = ByteBuffer.wrap(data);
            ResourceTableParser resourceTableParser = new ResourceTableParser(buffer);
            await resourceTableParser.parse();

            this.resourceTable = resourceTableParser.getResourceTable();
            this.locales       = resourceTableParser.getLocales();
            //possible mem leak
            buffer.Dispose();
        }
예제 #3
0
        EventID ResourceCondition(EventTable table, EventID _eventId, GameEvent evt)
        {
            UI.Resource.Resource resource      = evt.GetResource;
            ResourceTable        resourceTable = resource.GetResourceTable;

            switch (_eventId)
            {
            case EventID.NO1:         // 인구 급증
                if (resourceTable.populationTable.Now > resourceTable.populationTable.Max)
                {
                    table.IsEventOn = true;
                    return(_eventId);
                }
                break;

            case EventID.NO2:         // 식중독 발생
                if (resourceTable.foodTable.Now > resourceTable.foodTable.Max)
                {
                    table.IsEventOn = true;
                    return(_eventId);
                }
                break;

            default:
                break;
            }
            return(EventID.None);
        }
예제 #4
0
 private void LoadResourceTable(IReader reader)
 {
     if (_resources == null)
     {
         _resources = _cacheFile.Resources.LoadResourceTable(reader);
     }
 }
예제 #5
0
            public override string toStringValue(ResourceTable resourceTable, CultureInfo locale)
            {
                // The low-order 4 bits of the data value specify the type of the fraction
                short  type = (short)(value & 0xf);
                string pstr;

                switch (type)
                {
                case ResValue.ResDataCOMPLEX.UNIT_FRACTION:
                    pstr = "%";
                    break;

                case ResValue.ResDataCOMPLEX.UNIT_FRACTION_PARENT:
                    pstr = "%p";
                    break;

                default:
                    pstr = "unknown type:0x" + type.ToString("X");
                    break;
                }

                float f = BitConverter.ToSingle(BitConverter.GetBytes(value >> 4), 0); //Float.intBitsToFloat(value >> 4);

                return(f + pstr);
            }
예제 #6
0
 public object Read( Stream stream, ResourceTable resourceTable, params object [] args )
 {
     PackageInfo packageInfo;
     if ( new PackageDecoder ().Decode ( stream, out packageInfo ) )
         return packageInfo;
     else throw new ArgumentException ();
 }
예제 #7
0
        static void Main(string[] args)
        {
            using (var dbContext = new Liyanjie.Jsonql.Sample.AspNetCore.DbContext())
            {
                var resources = new ResourceTable()
                                .AddResource("Orders", dbContext.Orders)
                                .AddResource("OrderStatusChanges", dbContext.OrderStatusChanges)
                                .AddResource("UserAccounts", dbContext.UserAccounts)
                                .AddResource("UserAccountRecords", dbContext.UserAccountRecords)
                                .AddResource("Users", dbContext.Users)
                                .AddResource("UserProfiles", dbContext.UserProfiles);
                var jsonqlIncluder  = new Liyanjie.Jsonql.DynamicInclude.DynamicJsonqlIncluder();
                var jsonqlEvaluator = new Liyanjie.Jsonql.DynamicEvaluation.DynamicJsonqlEvaluator();
                var jsonqlLinqer    = new Liyanjie.Jsonql.DynamicLinq.DynamicJsonqlLinqer();

                var query = @"
{
    min: UserAccounts[].select(Coins).min()
}
";
                using (var queryHandler = new QueryHandler(resources, jsonqlIncluder, jsonqlLinqer, jsonqlEvaluator))
                {
                    var handler = queryHandler.Handle(query, null);
                    handler.Wait();
                    var content = handler.Result;
                    System.Console.WriteLine(content);
                }
            }
        }
예제 #8
0
        public void TestResourceTableInsert()
        {
            const string testString = "this is a test string";
            ulong        pageId;
            byte         segmentId;

            using (var pageStore = TestUtils.CreateEmptyPageStore("ResourceTableInsert"))
            {
                var resourceTable = new ResourceTable(pageStore);
                resourceTable.Insert(0, testString, out pageId, out segmentId, null);
                Assert.AreEqual((ulong)1, pageId);
                Assert.AreEqual((byte)0, segmentId);

                // Test we can retrieve it from the currently open page store
                var resource = resourceTable.GetResource(pageId, segmentId, null);
                Assert.AreEqual(testString, resource);
                pageStore.Commit(0, null);
            }

            using (var pageStore = new AppendOnlyFilePageStore(PersistenceManager, "ResourceTableInsert", 4096, true, false))
            {
                var resourceTable = new ResourceTable(pageStore);
                var resource      = resourceTable.GetResource(pageId, segmentId, null);
                Assert.AreEqual(testString, resource);
            }
        }
예제 #9
0
    private AssetBundleBuild GetAssetBundleBuild(ResourceTable ru)
    {
        string path     = AssetDatabase.GetAssetPath(ru);
        string filename = Path.GetFileNameWithoutExtension(path);

        return(GetAssetBundleBuild(ru.objects, ru.names, filename));
    }
        public void TestAssertLongLiteral()
        {
            var longStringValue = "Long string value " + new string('!', 100);
            var pageStore       = TestUtils.CreateEmptyPageStore("TestAssertLongLiteral.data");
            var resourceStore   = TestUtils.CreateEmptyPageStore("TestAssertLongLiteral.resources");
            var resourceTable   = new ResourceTable(resourceStore);
            var resourceIndex   = new ResourceIndex(0, pageStore, resourceTable);

            var resourceId = resourceIndex.AssertResourceInIndex(0, longStringValue, true, "http://example.org/datatypes/string",
                                                                 "en-us");

            // Should now be able to find the resource id
            Assert.AreEqual(resourceId, resourceIndex.GetResourceId(longStringValue, true, "http://example.org/datatypes/string", "en-us", true));
            // data type URI and language code should have been inserted as resources
            Assert.AreNotEqual(StoreConstants.NullUlong, resourceIndex.GetResourceId("http://example.org/datatypes/string", false, null, null, true));
            Assert.AreNotEqual(StoreConstants.NullUlong, resourceIndex.GetResourceId("en-us", true, null, null, true));
            var resource = resourceIndex.GetResource(resourceId, true);

            Assert.IsNotNull(resource);
            Assert.IsTrue(resource.IsLiteral);
            Assert.AreEqual(longStringValue, resource.Value);
            var dtResource = resourceIndex.GetResource(resource.DataTypeId, true);

            Assert.IsNotNull(dtResource);
            Assert.IsFalse(dtResource.IsLiteral);
            Assert.AreEqual("http://example.org/datatypes/string", dtResource.Value);
            var lcResource = resourceIndex.GetResource(resource.LanguageCodeId, true);

            Assert.IsNotNull(lcResource);
            Assert.IsTrue(lcResource.IsLiteral);
            Assert.AreEqual("en-us", lcResource.Value);

            // Persist the index
            var resourceIndexRoot = resourceIndex.RootId;

            resourceIndex.Save(0, null);
            pageStore.Commit(0ul, null);
            pageStore.Close();
            resourceTable.Commit(0ul, null);
            resourceTable.Dispose();

            // Test we can still find the resource after reopening the store
            using (pageStore = TestUtils.OpenPageStore("TestAssertLongLiteral.data", false))
            {
                using (var rt = new ResourceTable(TestUtils.OpenPageStore("TestAssertLongLiteral.resources", false)))
                {
                    resourceIndex = new ResourceIndex(pageStore, rt, resourceIndexRoot);
                    // Should still be able to find the resource id
                    Assert.AreEqual(resourceId,
                                    resourceIndex.GetResourceId(longStringValue, true,
                                                                "http://example.org/datatypes/string", "en-us", true));
                    Assert.AreNotEqual(StoreConstants.NullUlong,
                                       resourceIndex.GetResourceId("http://example.org/datatypes/string", false, null,
                                                                   null,
                                                                   true));
                    Assert.AreNotEqual(StoreConstants.NullUlong,
                                       resourceIndex.GetResourceId("en-us", true, null, null, true));
                }
            }
        }
예제 #11
0
파일: Container.cs 프로젝트: Daramkun/Misty
        public override void Intro( params object [] args )
        {
            Core.GraphicsDevice.ImmediateContext.BlendState = BlendState.AlphaBlend;

            Add ( InputHelper.Instance );
            Add ( calc = new FpsCalculator () );

            contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
            Texture2DContentLoader.AddDefaultDecoders ();

            textures = new ITexture2D [ 6 ];
            textures [ 0 ] = contentManager.Load<ITexture2D> ( "Resources/PerformanceTest/0096x0096.tga" );
            textures [ 1 ] = contentManager.Load<ITexture2D> ( "Resources/PerformanceTest/0128x0128.png" );
            textures [ 2 ] = contentManager.Load<ITexture2D> ( "Resources/PerformanceTest/0256x0256.png" );
            textures [ 3 ] = contentManager.Load<ITexture2D> ( "Resources/PerformanceTest/0512x0512.png" );
            textures [ 4 ] = contentManager.Load<ITexture2D> ( "Resources/PerformanceTest/1024x1024.png" );
            textures [ 5 ] = contentManager.Load<ITexture2D> ( "Resources/PerformanceTest/2048x2048.png" );

            nodes = new Node [ 6 ];
            for ( int i = 0; i < 6; ++i )
            {
                nodes [ i ] = Add ( new Node () );
            }

            base.Intro ( args );
        }
예제 #12
0
        //override
        public void Initialize()
        {
            _resourceTable = evt.InitResourceTable;

            _foodController = new FoodControl(this);

            evt.SetElevenDayEvent(_foodController.FoodBalance);
        }
예제 #13
0
파일: Container.cs 프로젝트: Daramkun/Misty
 public override void Intro( params object [] args )
 {
     Core.GraphicsDevice.ImmediateContext.BlendState = BlendState.AlphaBlend;
     contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( FileSystemManager.ManifestFileSystem ) );
     font = contentManager.Load<TrueTypeFont> ( "Resources/test.ttf",  32 );
     Add ( InputHelper.Instance );
     base.Intro ( args );
 }
예제 #14
0
            public override string toStringValue(ResourceTable resourceTable, CultureInfo locale)
            {
                StringBuilder sb = new StringBuilder();

                for (int i = len / 2 - 1; i >= 0; i--)
                {
                    sb.Append(((value >> i * 8) & 0xff).ToString("X"));
                }
                return(sb.ToString());
            }
예제 #15
0
 public override string toStringValue(ResourceTable resourceTable, CultureInfo locale)
 {
     if (value >= 0)
     {
         return(stringPool.get(value));
     }
     else
     {
         return(null);
     }
 }
예제 #16
0
 /**
  * get value as string
  *
  * @return
  */
 public string toStringValue(ResourceTable resourceTable, CultureInfo locale)
 {
     if (data != null)
     {
         return(CDATA_START + data + CDATA_END);
     }
     else
     {
         return(CDATA_START + typedData.toStringValue(resourceTable, locale) + CDATA_END);
     }
 }
예제 #17
0
        public static ResourceTable Deserialize(MultiPartFile file)
        {
            ResourceTable rt = new ResourceTable();

            rt.rscAlignShift    = file.ReadUInt16();
            rt.TypeInfo         = TYPEINFO.Deserialize(file);
            rt.rscEndTypes      = file.ReadUInt16();
            rt.rscResourceNames = null; // TODO: Figure out size
            rt.rscEndNames      = file.ReadByte();

            return(rt);
        }
예제 #18
0
파일: Container.cs 프로젝트: Daramkun/Misty
        public override void Intro( params object [] args )
        {
            contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );

            Add ( new ParticleEngine2D ( new Vector2 (), 10, null,
                contentManager.Load<ITexture2D> ( "Resources/Particle2D/circle.png" ),
                contentManager.Load<ITexture2D> ( "Resources/Particle2D/diamond.png" ),
                contentManager.Load<ITexture2D> ( "Resources/Particle2D/star.png" )
            ) );

            base.Intro ( args );
        }
예제 #19
0
        void SpecialEvts(EventTable table, EventID _eventId, GameEvent evt)
        {
            UI.Resource.Resource resource      = evt.GetResource;
            ResourceTable        resourceTable = resource.GetResourceTable;

            switch (_eventId)
            {
            case EventID.NO18:            // 식인 사건
                resource.ApplyPopulation(-(int)resource.GetPopulationResource(0.3d));
                resource.ApplyFood((int)resource.GetFoodResource(0.1d));
                resource.ApplyLeaderShip(-4);
                ApplyEventUI(table);
                break;

            case EventID.NO19:            // 인신 공양
                resource.ApplyPopulation(-(int)resource.GetPopulationResource(0.5d));
                resource.ApplyFood((int)resource.GetFoodResource(0.1d));
                resource.ApplyLeaderShip(-4);
                ApplyEventUI(table);
                break;

            case EventID.NO20:            // 반란 발생
                SpecialBubble.Instance.SpawnSpecialBubble(SpecialBubbleType.REBELLION);
                ApplyEventUI(table);
                break;

            case EventID.NO21:            // 집단 시위
                SpecialBubble.Instance.SpawnSpecialBubble(SpecialBubbleType.DEMONSTRATE);
                ApplyEventUI(table);
                break;

            case EventID.NO22:            // 알 수 없는 종교
                resource.ApplyLeaderShip(-1);
                SpecialBubble.Instance.SpawnSpecialBubble(SpecialBubbleType.FALSE_RELIGION);
                ApplyEventUI(table);
                break;

            case EventID.NO23:            // 만족하는 복지
                resource.ApplyLeaderShip(2);
                ApplyEventUI(table);
                break;

            case EventID.NO24:            // 만성 피로
                table._nextEvent = false;
                evt.SubscribeThreeDayEvent(() => { resource.ApplyLeaderShip(-1); });
                evt.SubscribeTwoDayEvent(() => { resource.ApplyPopulation(-1); });
                ApplyEventUI(table);
                break;

            default:
                break;
            }
        }
예제 #20
0
        public void WriteTable(ResourceTable table, string file)
        {
            var fileExt = Path.GetExtension(file).ToLower();

            if (fileExt == ".rtb")
            {
                file = Path.ChangeExtension(file, null);
            }
            stream = new FileStream(file + ".rtb", FileMode.CreateNew);

            WriteTable(table, stream);
        }
        /// <summary>
        ///     Saves the resource table back to the file.
        /// </summary>
        /// <param name="table">The resource table to save.</param>
        /// <param name="stream">The stream to save to.</param>
        public void SaveResourceTable(ResourceTable table, IStream stream)
        {
            if (_layoutTable == null || _gestalt == null)
            {
                return;
            }

            var pointers = _gestalt.SaveResources(table.Resources, stream);

            _layoutTable.SavePointers(pointers, stream);
            _layoutTable.SavePages(table.Pages, stream);
        }
예제 #22
0
파일: GameScene.cs 프로젝트: Daramkun/Misty
        public override void Intro( params object [] args )
        {
            Contents = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
            Contents.AddDefaultContentLoader ();

            Add ( new PlayerController () );
            Add ( new BulletController () );

            gameOverFont = Contents.Load<TrueTypeFont> ( "Resources/test.ttf", 64 );
            timeStampFont = Contents.Load<TrueTypeFont> ( "Resources/test.ttf", 32 );
            base.Intro ( args );
        }
예제 #23
0
파일: MenuScene.cs 프로젝트: Daramkun/Misty
 public override void Intro( params object [] args )
 {
     contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
     contentManager.AddDefaultContentLoader ();
     //Core.Launcher.InvokeInMainThread ( () =>
     //{
         titleFont = contentManager.Load<TrueTypeFont> ( "Resources/test.ttf", 64 );
         menuFont = contentManager.Load<TrueTypeFont> ( "Resources/test.ttf", 24 );
     //} );
     logo = new Sprite ( contentManager.Load<ITexture2D> ( "Resources/Dodge/logo.png" ) );
     logoWorld = new World2 ();
     base.Intro ( args );
 }
예제 #24
0
        /// <summary>
        /// Load flyff skills and levels.
        /// </summary>
        private void LoadSkills()
        {
            try
            {
                Log.Loading("Loading skills...");
                string propSkillPath  = Path.Combine(Global.DataPath, "res", "data", "propSkill.txt");
                var    propSkillTable = new ResourceTable(propSkillPath);

                propSkillTable.AddTexts(texts);
                propSkillTable.AddDefines(defines);
                propSkillTable.SetTableHeaders("ver", "dwID", "szName", "dwNum", "dwPackMax", "dwItemKind1", "dwItemKind2", "dwItemKind3", "dwItemJob", "bPermanence", "dwUseable", "dwItemSex", "dwCost", "dwEndurance", "nAbrasion", "nHardness", "dwHanded", "dwHeelH", "dwParts", "dwPartsub", "bPartFile", "dwExclusive", "dwBasePartsIgnore", "dwItemLV", "dwItemRare", "dwShopAble", "bLog", "bCharged", "dwLinkKindBullet", "dwLinkKind", "dwAbilityMin", "dwAbilityMax", "eItemType", "wItemEAtk", "dwparry", "dwblockRating", "dwAddSkillMin", "dwAddSkillMax", "dwAtkStyle", "dwWeaponType", "dwItemAtkOrder1", "dwItemAtkOrder2", "dwItemAtkOrder3", "dwItemAtkOrder4", "tmContinuousPain", "dwShellQuantity", "dwRecoil", "dwLoadingTime", "nAdjHitRate", "dwAttackSpeed", "dwDmgShift", "dwAttackRange", "dwProbability", "dwDestParam1", "dwDestParam2", "dwDestParam3", "nAdjParamVal1", "nAdjParamVal2", "nAdjParamVal3", "dwChgParamVal1", "dwChgParamVal2", "dwChgParamVal3", "dwdestData1", "dwdestData2", "dwdestData3", "dwactiveskill", "dwactiveskillLv", "dwactiveskillper", "dwReqMp", "dwRepFp", "dwReqDisLV", "dwReSkill1", "dwReSkillLevel1", "dwReSkill2", "dwReSkillLevel2", "dwSkillReadyType", "dwSkillReady", "dwSkillRange", "dwSfxElemental", "dwSfxObj", "dwSfxObj2", "dwSfxObj3", "dwSfxObj4", "dwSfxObj5", "dwUseMotion", "dwCircleTime", "dwSkillTime", "dwExeTarget", "dwUseChance", "dwSpellRegion", "dwSpellType", "dwReferStat1", "dwReferStat2", "dwReferTarget1", "dwReferTarget2", "dwReferValue1", "dwReferValue2", "dwSkillType", "fItemResistElecricity", "fItemResistFire", "fItemResistWind", "fItemResistWater", "fItemResistEarth", "nEvildoing", "dwExpertLV", "ExpertMax", "dwSubDefine", "dwExp", "dwComboStyle", "fFlightSpeed", "fFlightLRAngle", "fFlightTBAngle", "dwFlightLimit", "dwFFuelReMax", "dwAFuelReMax", "dwFuelRe", "dwLimitLevel1", "dwReflect", "dwSndAttack1", "dwSndAttack2", "szIcon", "dwQuestID", "szTextFile", "szComment");
                propSkillTable.Parse();

                while (propSkillTable.Read())
                {
                    var skill = new SkillData(propSkillTable);

                    if (skillData.ContainsKey(skill.ID))
                    {
                        skillData[skill.ID] = skill;
                    }
                    else
                    {
                        skillData.Add(skill.ID, skill);
                    }
                }

                string propSkillLevelPath  = Path.Combine(Global.DataPath, "res", "data", "propSkillAdd.csv");
                var    propSkillLevelTable = new ResourceTable(propSkillLevelPath);
                propSkillLevelTable.AddTexts(texts);
                propSkillLevelTable.AddDefines(defines);
                propSkillLevelTable.SetTableHeaders("dwLevelID", "dwSkillID", "dwSkillLevel", "dwAbilityMin", "dwAbilityMax", "dwAbilityMinPVP", "dwAbilityMaxPVP", "dwAttackSpeed", "dwDmgShift", "nProbability", "nProbabilityPVP", "dwTaunt", "dwDestParam1", "dwDestParam2", "nAdjParamVal1", "nAdjParamVal2", "dwChgParamVal1", "dwChgParamVal2", "dwDestData1", "dwDestData2", "dwDestData3", "dwActiveSkill", "dwActiveSkillRate", "dwActiveSkillRatePVP", "dwReqMp", "dwReqFp", "dwCooldown", "dwCastingTime", "dwSkillRange", "dwCircleTime", "dwPainTime", "dwSkillTime", "dwSkillCount", "dwSkillExp", "dwExp", "dwComboSkillTime");
                propSkillLevelTable.Parse();

                while (propSkillLevelTable.Read())
                {
                    var skillLevel = new SkillLevelData(propSkillLevelTable);

                    if (skillData.ContainsKey(skillLevel.SkillID))
                    {
                        skillData[skillLevel.SkillID].Levels.Add(skillLevel);
                    }
                }

                Log.Done("{0} skills loaded!\t\t\t", skillData.Count);
            }
            catch (Exception e)
            {
                Log.Error("Cannot load skills: {0}", e.Message);
            }
        }
예제 #25
0
    private HashSet <Object> GetUnitDependencies(ResourceTable ru)
    {
        var ds = EditorUtility.CollectDependencies(ru.objects.ToArray());
        HashSet <Object> sets = new HashSet <Object>();

        foreach (var d in ds)
        {
            if (!(d is Component) && !sets.Contains(d) && d != null)
            {
                sets.Add(d);
            }
        }
        return(sets);
    }
예제 #26
0
 public void SaveChanges(IStream stream)
 {
     if (_resources != null)
     {
         _cacheFile.Resources.SaveResourceTable(_resources, stream);
         _resources = null;
     }
     if (_zoneSets != null && _zoneSets.GlobalZoneSet != null)
     {
         _zoneSets.SaveChanges(stream);
         _zoneSets = null;
     }
     _cacheFile.SaveChanges(stream);
 }
예제 #27
0
        public ResourceTable ReadTable(Stream stream)
        {
            this.stream = stream;

            var table = new ResourceTable();

            using (reader = new BinaryReader(stream))
            {
                if (Encoding.ASCII.GetString(reader.ReadBytes(10)) != "WigRTB 1.0")
                {
                    throw new InvalidDataException("Incorrect RTB header!");
                }

                reader.BaseStream.Seek(12L, SeekOrigin.Begin);
                uint assetCount = reader.ReadUInt32();

                for (uint i = 0; i < 4; i++)
                {
                    var dirBytes = reader.ReadBytes(260);
                    var dir      = Encoding.ASCII.GetString(dirBytes);
                    dir = dir.Substring(0, dir.IndexOf("\0"));
                    table.directories.Add(dir);
                }

                for (uint i = 0; i < assetCount; i++)
                {
                    uint assetId = reader.ReadUInt32();

                    reader.BaseStream.Seek(4L, SeekOrigin.Current);

                    int  offset = 1;
                    byte nchar  = reader.ReadByte();
                    while (nchar != 0x00) // Seperator
                    {
                        offset++;
                        nchar = reader.ReadByte();
                    }

                    reader.BaseStream.Seek(-(offset), SeekOrigin.Current);
                    string path = Encoding.ASCII.GetString(reader.ReadBytes(offset - 1));

                    table.Add(assetId, path);

                    reader.BaseStream.Seek(4L, SeekOrigin.Current);
                }
            }

            return(table);
        }
        /// <summary>
        ///     Loads the resource table from the cache file.
        /// </summary>
        /// <param name="reader">The stream to read from.</param>
        /// <returns>
        ///     The loaded resource table, or <c>null</c> if loading failed.
        /// </returns>
        public ResourceTable LoadResourceTable(IReader reader)
        {
            if (_layoutTable == null || _gestalt == null)
            {
                return(null);
            }

            var result = new ResourceTable();

            result.Pages.AddRange(_layoutTable.LoadPages(reader));
            var pointers = _layoutTable.LoadPointers(reader, result.Pages);

            result.Resources.AddRange(_gestalt.LoadResources(reader, _tags, pointers.ToList()));
            return(result);
        }
예제 #29
0
파일: Container.cs 프로젝트: Daramkun/Misty
        public override void Intro( params object [] args )
        {
            Core.Window.Title = "Cube";

            contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
            cubeEffect = contentManager.Load<IEffect> ( "Resources/Cube/CubeShader.xml", "i_pos", "i_col" );

            cubeVertices = Core.GraphicsDevice.CreateBuffer<CubeVertex>( BufferType.VertexBuffer, new CubeVertex []
            {
                new CubeVertex () { Position = new Vector3 ( -1, -1, -1 ), Diffuse = Color.Red },
                new CubeVertex () { Position = new Vector3 ( +1, -1, -1 ), Diffuse = Color.Blue },
                new CubeVertex () { Position = new Vector3 ( -1, -1, +1 ), Diffuse = Color.Green },
                new CubeVertex () { Position = new Vector3 ( +1, -1, +1 ), Diffuse = Color.White },

                new CubeVertex () { Position = new Vector3 ( -1, +1, -1 ), Diffuse = Color.Magenta },
                new CubeVertex () { Position = new Vector3 ( -1, +1, +1 ), Diffuse = Color.Cyan },
                new CubeVertex () { Position = new Vector3 ( +1, +1, -1 ), Diffuse = Color.Yellow },
                new CubeVertex () { Position = new Vector3 ( +1, +1, +1 ), Diffuse = Color.White },
            } );
            cubeIndices = Core.GraphicsDevice.CreateBuffer<CubeIndex> ( BufferType.IndexBuffer, new CubeIndex []
            {
                // TOP
                new CubeIndex () { I0 = 0, I1 = 1, I2 = 2 },
                new CubeIndex () { I0 = 1, I1 = 3, I2 = 2 },
                // LEFT
                new CubeIndex () { I0 = 0, I1 = 2, I2 = 4 },
                new CubeIndex () { I0 = 2, I1 = 5, I2 = 4 },
                // FRONT
                new CubeIndex () { I0 = 2, I1 = 3, I2 = 5 },
                new CubeIndex () { I0 = 3, I1 = 7, I2 = 5 },
                // RIGHT
                new CubeIndex () { I0 = 3, I1 = 1, I2 = 7 },
                new CubeIndex () { I0 = 1, I1 = 6, I2 = 7 },
                // BACK
                new CubeIndex () { I0 = 1, I1 = 0, I2 = 6 },
                new CubeIndex () { I0 = 6, I1 = 0, I2 = 4 },
                // BOTTOM
                new CubeIndex () { I0 = 5, I1 = 6, I2 = 4 },
                new CubeIndex () { I0 = 5, I1 = 7, I2 = 6 },
            } );
            vertexDeclarataion = Core.GraphicsDevice.CreateVertexDeclaration ( Utilities.CreateVertexElementArray<CubeVertex> () );

            proj = new PerspectiveFieldOfViewProjection ();
            lookAt = new LookAt ( new Vector3 ( 5, 5, 5 ), new Vector3 ( 0, 0, 0 ), new Vector3 ( 0, 1, 0 ) );
            world = World3.Identity;

            base.Intro ( args );
        }
예제 #30
0
		public override void Intro ( params object [] args )
		{
			contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( FileSystemManager.ManifestFileSystem ) );
			contentManager.AddDefaultContentLoader ();
			AudioContentLoader.AddDefaultDecoders ();
			AudioContentLoader.Decoders.Add ( new MpegDecoder () );

			Core.GraphicsDevice.BlendState = true;
			Core.GraphicsDevice.BlendOperation = BlendOperation.AlphaBlend;

			font = contentManager.Load<TrueTypeFont> ( "test.ttf", 40 );
			audio1 = contentManager.Load<IAudioBuffer> ( "test.mp3" );
			audio1.Play ();

			base.Intro ( args );
		}
예제 #31
0
 public string toStringValue(ResourceTable resourceTable, CultureInfo locale)
 {
     if (rawValue != null)
     {
         return(rawValue);
     }
     else if (typedValue != null)
     {
         return(typedValue.toStringValue(resourceTable, locale));
     }
     else
     {
         // something happen;
         return("");
     }
 }
예제 #32
0
파일: Container.cs 프로젝트: Daramkun/Misty
        public override void Intro( params object [] args )
        {
            contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( FileSystemManager.ManifestFileSystem ) );

            Core.GraphicsDevice.ImmediateContext.BlendState = BlendState.AlphaBlend;
            Add ( InputHelper.Instance );

            stt = contentManager.Load<StringTable> ( "Resources/stringTable.json" );

            font = contentManager.Load<TrueTypeFont> ( "Resources/test.ttf", 22 );
            font.IsPrerenderMode = true;
            font2 = contentManager.Load<TrueTypeFont> ( "Resources/test.ttf", 32 );
            font2.SeconaryFont = contentManager.Load<TrueTypeFont> ( "Resources/segoeui.ttf", 32 );

            base.Intro ( args );
        }
예제 #33
0
        public static void Initalize()
        {
            heap1 = new ResourceHeap(4);

            CameraBuffer = new ConstantBuffer <CameraBuffer>(1);
            GridBuffer   = new ConstantBuffer <GridBuffer>(1);

            Texture = Texture2D.FromFile(@"..\..\Resources\Dream.png");

            heap1.AddResource(CameraBuffer);
            heap1.AddResource(GridBuffer);
            heap1.AddResource(Texture);

            ConstantBufferTable = new ResourceTable(heap1, 0);
            TextureTable        = new ResourceTable(heap1, 2);
        }
예제 #34
0
    private void FillResourceGrid()
    {
        string searchText = txtSearchText.Text.Trim();

        int totalRecords   = 0;
        int fetchedRecords = _pageSize * ResourceTable.PageIndex;

        ResourceTable.PageSize = _pageSize;
        List <Resource> resourceList = new List <Resource>();

        using (ResourceDataAccess dataAccess = new ResourceDataAccess(Utility.CreateContext()))
        {
            IEnumerable <Resource> resources = null;

            if (!rbSearchOptions.SelectedItem.Text.Equals(Resources.Resources.SearchInExistingList))
            {
                resources = dataAccess.GetResources(searchText);
            }
            else
            {
                resources = dataAccess.GetResourcesWithExplicitPermissions(Id, searchText, userToken);
            }
            resourceList = resources.OrderBy(tuple => tuple.Title).Skip(fetchedRecords).Take(_pageSize).ToList();
            totalRecords = resources.Count();

            Utility.UpdateResourcesEmptyTitle(resourceList);
        }

        if (!(totalRecords > 0))
        {
            lblErrorResourcePermission.Text      = Resources.Resources.NoRecordsFound;
            lblErrorResourcePermission.ForeColor = System.Drawing.Color.Red;
            lblErrorResourcePermission.Visible   = true;
        }

        if (resourceList != null)
        {
            //Update page count
            UpdatePageCount(ResourceTable, totalRecords);

            if (resourceList.Count > 0)
            {
                ResourceTable.DataSource = resourceList;
                ResourceTable.DataBind();
            }
        }
    }
예제 #35
0
파일: Container.cs 프로젝트: Daramkun/Misty
        public override void Intro( params object [] args )
        {
            Core.Window.Title = "Simple Dodge";
            Core.GraphicsDevice.ImmediateContext.BlendState = BlendState.AlphaBlend;

            Add ( InputHelper.Instance );
            InputHelper.IsKeyboardEnabled = true;
            Add ( SceneContainer = new SceneContainer ( new MenuScene () ) );
            SceneContainer.SceneTransitor = new FadeTransitor ();

            contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
            fpsFont = contentManager.Load<TrueTypeFont> ( "Resources/test.ttf", 20 );

            Add ( calc = new FpsCalculator () );

            base.Intro ( args );
        }
예제 #36
0
        public object Read( Stream stream, ResourceTable resourceTable, params object [] args )
        {
            try
            {
                return new Sprite ( textureContentLoader.Read ( stream, resourceTable, args ) as ITexture2D );
            }
            catch
            {
                JsonContainer data = new JsonContainer ( stream );

                Sprite sprite = new Sprite ( null );
                if ( data.Contains ( "colorkey" ) )
                {
                    JsonContainer colorKey = data [ "colorkey" ] as JsonContainer;
                    sprite.Texture = textureContentLoader.Read ( new MemoryStream ( Convert.FromBase64String ( data [ "image" ] as string ) ),
                        resourceTable,
                        new Color ( ( byte ) colorKey [ 0 ], ( byte ) colorKey [ 1 ], ( byte ) colorKey [ 2 ], ( byte ) colorKey [ 3 ] ) ) as ITexture2D;
                }
                else
                    sprite.Texture = textureContentLoader.Read ( new MemoryStream ( Convert.FromBase64String ( data [ "image" ] as string ) ),
                        resourceTable ) as ITexture2D;

                if ( data.Contains ( "cliparea" ) )
                {
                    JsonContainer clipArea = data [ "clipArea" ] as JsonContainer;
                    if ( clipArea.ContainerType == ContainType.Object )
                    {
                        sprite.ClippingArea = new Rectangle ( ( int ) clipArea [ "left" ], ( int ) clipArea [ "top" ],
                            ( int ) clipArea [ "right" ] - ( int ) clipArea [ "left" ], ( int ) clipArea [ "bottom" ] - ( int ) clipArea [ "top" ] );
                    }
                    else
                    {
                        sprite.ClippingArea = new Rectangle ( ( int ) clipArea [ 0 ], ( int ) clipArea [ 1 ],
                            ( int ) clipArea [ 2 ] - ( int ) clipArea [ 0 ], ( int ) clipArea [ 3 ] - ( int ) clipArea [ 1 ] );
                    }
                }

                if ( data.Contains ( "overlay" ) )
                {
                    JsonContainer overlay = data [ "overlay" ] as JsonContainer;
                    sprite.OverlayColor = new Color ( ( byte ) overlay [ 0 ], ( byte ) overlay [ 1 ], ( byte ) overlay [ 2 ], ( byte ) overlay [ 3 ] );
                }

                return sprite;
            }
        }
예제 #37
0
 public object Read( Stream stream, ResourceTable resourceTable, params object [] args )
 {
     bool isLoadComplete = false;
     ImageInfo imageInfo = null;
     foreach ( IDecoder<ImageInfo> decoder in Decoders )
     {
         stream.Position = 0;
         if ( decoder.Decode ( stream, out imageInfo ) )
         {
             isLoadComplete = true;
             break;
         }
     }
     if ( isLoadComplete )
         return Core.GraphicsDevice.CreateTexture2D ( imageInfo, ( args.Length == 1 ) ? new Color? ( ( Color ) args [ 0 ] ) : null );
     else throw new ArgumentException ();
 }
예제 #38
0
파일: Container.cs 프로젝트: Daramkun/Misty
        public override void Intro( params object [] args )
        {
            Core.GraphicsDevice.ImmediateContext.BlendState = BlendState.AlphaBlend;

            contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
            Texture2DContentLoader.AddDefaultDecoders ();
            AudioContentLoader.AddDefaultDecoders ();

            font = contentManager.Load<TrueTypeFont> ( "Resources/test.ttf", 24 );

            audio1 = contentManager.Load<IAudioBuffer> ( "Resources/Audio/audio1.ogg" );
            //audio2 = contentManager.Load<IAudioBuffer> ( "Resources/Audio/audio2.flac" );
            audio3 = contentManager.Load<IAudioBuffer> ( "Resources/Audio/audio3.ogg" );

            Add ( InputHelper.Instance );

            base.Intro ( args );
        }
예제 #39
0
    private AssetBundleBuild GetAssetBundleBuild(ResourceTable ru, List <Object> commonAssets)
    {
        string        path     = AssetDatabase.GetAssetPath(ru);
        string        filename = Path.GetFileNameWithoutExtension(path);
        List <Object> assets   = ru.objects;
        List <string> names    = ru.names;

        foreach (var a in commonAssets)
        {
            int id = assets.IndexOf(a);
            if (id != -1)
            {
                assets.RemoveAt(id);
                names.RemoveAt(id);
            }
        }
        return(GetAssetBundleBuild(assets, names, filename));
    }
    public ResourceType GetResource <ResourceType>(ResourceGuid guid) where ResourceType : Resource
    {
        Resource resource = ResourceTable.FirstOrDefault((Resource s) => s.Guid == guid);

        if (resource == null)
        {
            Debug.LogWarning("Could not find resource: " + guid);
            return((ResourceType)null);
        }
        ResourceType val = (ResourceType)resource;

        if (val == null)
        {
            Debug.LogError("Resource type mismatch for resource: " + resource.Id + "\nExpecting Type: " + typeof(ResourceType).Name + "\nGot Type: " + resource.GetType().Name);
            return((ResourceType)null);
        }
        return(val);
    }
예제 #41
0
        static ResourceTable ReadResourceTable(int rsrcOffset, int offset, byte[] rsrc, uint type)
        {
            var  directory   = Struct <IMAGE_RESOURCE_DIRECTORY>(rsrc, offset);
            bool hasLanguage = false;
            var  table       = new ResourceTable()
            {
                Type = type
            };

            for (int i = 0; i < directory.NumberOfNamedEntries + directory.NumberOfIdEntries; i++)
            {
                var off   = offset + 16 + (i * 8);
                var entry = Struct <IMAGE_RESOURCE_DIRECTORY_ENTRY>(rsrc, off);
                var res   = new Resource()
                {
                    Name = entry.Name
                };
                if ((IMAGE_RESOURCE_DATA_IS_DIRECTORY & entry.OffsetToData) == IMAGE_RESOURCE_DATA_IS_DIRECTORY)
                {
                    var langDirectory = Struct <IMAGE_RESOURCE_DIRECTORY>(rsrc, DirOffset(entry.OffsetToData));
                    for (int j = 0; j < langDirectory.NumberOfIdEntries + langDirectory.NumberOfNamedEntries; j++)
                    {
                        var langOff   = DirOffset(entry.OffsetToData) + 16 + (j * 8);
                        var langEntry = Struct <IMAGE_RESOURCE_DIRECTORY_ENTRY>(rsrc, langOff);
                        if ((IMAGE_RESOURCE_DATA_IS_DIRECTORY & langEntry.OffsetToData) == IMAGE_RESOURCE_DATA_IS_DIRECTORY)
                        {
                            throw new Exception("Malformed .rsrc section");
                        }
                        var dataEntry = Struct <IMAGE_RESOURCE_DATA_ENTRY>(rsrc, (int)langEntry.OffsetToData);
                        var dat       = new ArraySegment <byte>(rsrc, (int)dataEntry.OffsetToData - rsrcOffset, (int)dataEntry.Size);
                        res.Locales.Add(new ResourceData()
                        {
                            Locale = langEntry.Name, Data = dat
                        });
                    }
                }
                else
                {
                    throw new Exception("Malformed .rsrc section");
                }
                table.Resources.Add(res);
            }
            return(table);
        }
예제 #42
0
파일: Container.cs 프로젝트: Daramkun/Misty
        public override void Intro( params object [] args )
        {
            Core.GraphicsDevice.ImmediateContext.BlendState = BlendState.AlphaBlend;

            Core.Window.Title = "Information Viewer";

            contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
            font = contentManager.Load<TrueTypeFont> ( "Resources/test.ttf", 24 );
            font.IsPrerenderMode = true;

            Add ( InputHelper.Instance );

            infoText = string.Format (
            @"Platform Type: {0}
            Platform Version: {1}
            Machine Unique ID: {2}
            User Name: {3}

            Base Renderer: {4}
            Renderer Version: {5}
            Shader Version: {6}
            Device Vendor: {7}
            Maximum Anisotropic Level: {8}
            Is Support Geometry Shader: {9}

            ==Available Resolutions ==
            {10}",
                Core.Launcher.PlatformInformation.PlatformType,
                Core.Launcher.PlatformInformation.PlatformVersion,
                Core.Launcher.PlatformInformation.MachineUniqueIdentifier,
                Core.Launcher.PlatformInformation.UserName,

                Core.GraphicsDevice.Information.BaseRenderer,
                Core.GraphicsDevice.Information.RendererVersion,
                Core.GraphicsDevice.Information.ShaderVersion,
                Core.GraphicsDevice.Information.DeviceVendor,
                Core.GraphicsDevice.Information.MaximumAnisotropicLevel,
                Core.GraphicsDevice.Information.IsSupportGeometryShader,

                ConvertToString ( Core.GraphicsDevice.Information.AvailableScreenResolutions )
            );

            base.Intro ( args );
        }
예제 #43
0
파일: Container.cs 프로젝트: Daramkun/Misty
        public override void Intro( params object [] args )
        {
            Core.GraphicsDevice.ImmediateContext.BlendState = BlendState.AlphaBlend;

            contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
            contentManager.AddDefaultContentLoader ();
            Texture2DContentLoader.AddDefaultDecoders ();
            sprite = contentManager.Load<Sprite> ( "Resources/test.jpg", Color.Magenta );
            font = contentManager.Load<TrueTypeFont> ( "Resources/test.ttf", 24 );

            animate = new Animate ( TimeSpan.FromSeconds ( 4 ), 400 );
            loopAnimate = new Animate ( TimeSpan.FromSeconds ( 4 ), 400 ) { IsLoopingMode = true };
            loopAnimate.Start ();
            Add ( InputHelper.Instance );

            world = new World2 ();

            base.Intro ( args );
        }
예제 #44
0
            //private Long parentId;

            internal AssignmentWithResource(object[] res, bool fetchPersisted)
            {
                //parentId = (Long)res[0];
                assignmentTable = (ResourceToAssignmentTable)res[1];
                resourceTable   = (ResourceTable)res[2];

                assignmentTable = (ResourceToAssignmentTable)assignmentTable.clone(false, false);
                if (resourceTable is ResourceToResourceTable)
                {
                    bool isPredicted = fetchPersisted && resourceTable.Predicted != null && resourceTable.Predicted.booleanValue();
                    if (isPredicted)
                    {
                        // Very slow without fetching here:
                        ISet <object> historySet = resourceTable.ResourceHistorySet;
                        resourceTable = ((ResourceToResourceTable)resourceTable).copyWithParent();
                        resourceTable.ResourceHistorySet = historySet;
                    }
                    else
                    {
                        resourceTable = ((ResourceToResourceTable)resourceTable).copyWithParent();
                    }
                }
                else
                {
                    bool isPredicted = fetchPersisted && resourceTable.Predicted != null && resourceTable.Predicted.booleanValue();
                    if (isPredicted)
                    {
                        // Very slow without fetching here:
                        ISet <object> historySet = resourceTable.ResourceHistorySet;
                        resourceTable = (ResourceTable)resourceTable.clone();
                        resourceTable.ResourceHistorySet = historySet;
                    }
                    else
                    {
                        resourceTable = (ResourceTable)resourceTable.clone();
                    }

                    //System.out.println("Loaded -> "+resourceTable.getTitle()+" -> "+resourceTable.getClass()+" -> "+resourceTable.getTableRate());
                }

                assignmentTable.AssignmentResourceTable = resourceTable;
            }
예제 #45
0
        public void SaveChanges(IStream stream)
        {
            if (_resources != null)
            {
                _cacheFile.Resources.SaveResourceTable(_resources, stream);
                _resources = null;
            }
            if (_zoneSets != null && _zoneSets.GlobalZoneSet != null)
            {
                _zoneSets.SaveChanges(stream);
                _zoneSets = null;
            }
            if (_soundResources != null)
            {
                _cacheFile.SoundGestalt.SaveSoundResourceTable(_soundResources, stream);
            }

            _languageCache.SaveAll(stream);
            _languageCache.ClearCache();
            _cacheFile.SaveChanges(stream);
        }
예제 #46
0
 public object Read( Stream stream, ResourceTable resourceTable, params object [] args )
 {
     bool isLoadComplete = false;
     AudioInfo audioInfo = null;
     foreach ( IDecoder<AudioInfo> decoder in Decoders )
     {
         try
         {
             stream.Position = 0;
             if ( decoder.Decode ( stream, out audioInfo ) )
             {
                 isLoadComplete = true;
                 break;
             }
         }
         catch { }
     }
     if ( isLoadComplete )
         return Core.AudioDevice.CreateAudioBuffer ( audioInfo );
     else throw new ArgumentException ();
 }
예제 #47
0
        public PackageInfo( string packageName, string author, string copyright, string description, Version version, DateTime releaseDate,
			bool isSubPackage, Guid [] mainPackageIds, StringTable stringTable, ResourceTable resourceTable, ImageInfo imageInfo = null, Guid? packageId = null )
        {
            PackageName = packageName;

            Author = author;
            Copyright = copyright;
            Description = description;

            PackageID = ( packageId == null ) ? Guid.NewGuid () : packageId.Value;
            Version = version;
            ReleaseDate = releaseDate;

            if ( imageInfo != null )
                PackageCover = imageInfo;

            IsSubPackage = isSubPackage;
            MainPackageIDs = mainPackageIds;

            StringTable = stringTable;
            ResourceTable = resourceTable;

            IsSettingCompleted = true;
        }
예제 #48
0
 public object Read( Stream stream, ResourceTable resourceTable, params object [] args )
 {
     return new LsfFont ( stream );
 }
예제 #49
0
 public object Read( Stream stream, ResourceTable resourceTable, params object [] args )
 {
     return new TrueTypeFont ( stream, ( int ) args [ 0 ] );
 }
예제 #50
0
 public object Read( Stream stream, ResourceTable resourceTable, params object [] args )
 {
     return Core.GraphicsDevice.CreateEffect ( stream );
 }
예제 #51
0
파일: Container.cs 프로젝트: Daramkun/Misty
        public override void Intro( params object [] args )
        {
            Core.GraphicsDevice.ImmediateContext.CullMode = CullMode.ClockWise;

            contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
            contentManager.AddDefaultContentLoader ();

            texture1 = contentManager.Load<ITexture2D> ( "Resources/Terrain/terrain_02.png" );
            texture2 = contentManager.Load<ITexture2D> ( "Resources/Terrain/terrain_01.png" );
            Color [] colours = texture2.Buffer;
            effect = contentManager.Load<IEffect> ( "Resources/Terrain/TerrainShader.xml" );

            textureArgs = new SamplerState ( texture1, TextureFilter.Anisotropic, TextureAddressing.Clamp,
                Core.GraphicsDevice.Information.MaximumAnisotropicLevel );

            vertexBuffer = Core.GraphicsDevice.CreateBuffer ( BufferType.VertexBuffer, typeof ( TerrainVertex ), texture2.Width * texture2.Height );
            vertexDeclaration = Core.GraphicsDevice.CreateVertexDeclaration ( Utilities.CreateVertexElementArray<TerrainVertex> () );
            numOfIndices = ( texture2.Width - 1 ) * ( texture2.Height - 1 ) * 2;
            indexBuffer = Core.GraphicsDevice.CreateBuffer ( BufferType.IndexBuffer, typeof ( TerrainIndex ), numOfIndices );

            TerrainVertex [] vertices = new TerrainVertex [ texture2.Width * texture2.Height ];
            int index = 0;
            for ( int x = 0; x < texture2.Height; x++ )
            {
                for ( int z = 0; z < texture2.Width; z++ )
                {
                    int location = x * texture2.Width + z;
                    vertices [ index ] = new TerrainVertex ()
                    {
                        Position = new Vector3 (
                            ( x - texture2.Height / 2 ) * 5.0f,
                            colours [ location ].RedValue * 5.0f / 3,
                            ( z - texture2.Width / 2 ) * 5.0f
                        ),
                        UV = new Vector2 (
                            z / ( float ) texture2.Width,
                            x / ( float ) texture2.Height
                        )
                    };
                    ++index;
                }
            }
            vertexBuffer.SetBufferDatas<TerrainVertex> ( vertices );

            TerrainIndex [] indices = new TerrainIndex [ numOfIndices ];
            index = 0;
            for ( int z = 0; z < texture2.Height - 1; z++ )
            {
                for ( int x = 0; x < texture2.Width - 1; x++ )
                {
                    indices [ index ]._0 = z * texture2.Width + x;
                    indices [ index ]._1 = z * texture2.Width + ( x + 1 );
                    indices [ index ]._2 = ( z + 1 ) * texture2.Width + x;
                    ++index;
                    indices [ index ]._0 = ( z + 1 ) * texture2.Width + x;
                    indices [ index ]._1 = z * texture2.Width + ( x + 1 );
                    indices [ index ]._2 = ( z + 1 ) * texture2.Width + ( x + 1 );
                    ++index;
                }
            }
            indexBuffer.SetBufferDatas<TerrainIndex> ( indices );

            proj = new PerspectiveFieldOfViewProjection ( 3.141592f / 4, 4 / 3f, 1, 10000 );
            look = new LookAt ( new Vector3 ( 1000, 2000, 1000 ), new Vector3 ( 0, 0, 0 ), new Vector3 ( 0, 1, 0 ) );
            world = new World3 ();

            sprite = new Sprite ( null );
            spriteWorld = new World2 ();

            Add ( new FpsCalculator () );

            base.Intro ( args );
        }
예제 #52
0
 public object Read( Stream stream, ResourceTable resourceTable, params object [] args )
 {
     return new StringTable ( stream );
 }
예제 #53
0
 public object Read( Stream stream, ResourceTable resourceTable, params object [] args )
 {
     return new ZipFileSystem ( stream );
 }
예제 #54
0
 public object Read( Stream stream, ResourceTable resourceTable, params object [] args )
 {
     return new JsonContainer ( stream );
 }