コード例 #1
0
ファイル: Arena.cs プロジェクト: bmjoy/Blast-Server
        private void CreateLandAndObstaclesFromFile(string filepath)
        {
            obstacles.Clear();

            using (BinaryReader reader = new BinaryReader(new FileStream(filepath, FileMode.Open)))
            {
                int wC     = reader.ReadInt32();
                int hC     = reader.ReadInt32();
                int bCount = reader.ReadInt32(); // blockCount 'u okuduk. fuzuli

                land = new Land(this, wC, hC, 1);

                for (int i = 0; i < hC; i++)
                {
                    for (int j = 0; j < wC; j++)
                    {
                        string typename = reader.ReadString();
                        int    skinId   = reader.ReadInt32();

                        Type blockType;
                        if ((blockType = Type.GetType("Game_Core.Blocks." + typename)) != null)
                        {
                            land.blocks[i, j]        = Activator.CreateInstance(blockType) as Block;
                            land.blocks[i, j].skinId = skinId;
                        }
                        else
                        {
                            land.blocks[i, j] = null;
                        }
                    }
                }

                int obsCount = reader.ReadInt32();

                for (int i = 0; i < obsCount; i++)
                {
                    string  typename = reader.ReadString();
                    int     skinId   = reader.ReadInt32();
                    Vector3 position = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

                    Type obsType;
                    if ((obsType = Type.GetType("Game_Core.Obstacles." + typename)) != null)
                    {
                        obstacles.Add(Activator.CreateInstance(obsType, this, position, 40f, 0.15f, skinId) as Obstacle);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Arena.cs プロジェクト: bmjoy/Blast-Server
        private void CreateLandAndObstacles()
        {
            land = new Land(this, 20, 12, 1);

            obstacles.Clear();
            for (int i = 0; i < 4; i++)
            {
                int wDivisions = (int)(land.width / land.blockSize);
                int hDivisions = (int)(land.height / land.blockSize);

                Vector3 oPos = new Vector3(
                    (RandomInstance.instance.Next(wDivisions) + 0.5f) * land.blockSize + Land.center.x - land.width / 2f, 0,
                    (RandomInstance.instance.Next(hDivisions) + 0.5f) * land.blockSize + Land.center.z - land.height / 2f);

                obstacles.Add(new Obstacle(this, oPos, 40f * (1 + RandomInstance.instance.Next(26) / 100f), 0.17f * (1 + RandomInstance.instance.Next(26) / 100f)));
            }
        }