コード例 #1
0
ファイル: Test.cs プロジェクト: Ragzouken/smooltool
    public void HostGame(string name, string password)
    {
        world = new World();
        info = new World.Info
        {
            version = version,
            lastPlayed = System.DateTime.Now,
            name = name,
            root = string.Format("{0}-{1}", name, System.DateTime.Now.Ticks),
        };

        for (int i = 0; i < 1024; ++i) world.tilemap[i] = (byte) Random.Range(0, 23);
        for (int i = 0; i < 256; ++i)
        {
            if (Random.value > 0.5f) world.walls.Add((byte)i);
        }

        world.tileset.SetPixels32(testtex.GetPixels32());
        world.RandomisePalette();
        world.PalettiseTexture(world.tileset);

        SetWorld(world);

        var create = new CreateMatchRequest();
        create.name = name;
        create.size = 8;
        create.advertise = true;
        create.password = password;

        create.name += "!" + (int)version + "?0";

        testLAN.broadcastData = create.name;
        match.CreateMatch(create, OnMatchCreate);
        testLAN.StopBroadcast();
        testLAN.StartAsServer();
    }