Ignore:
Timestamp:
2014-07-02 14:59:44 (8 years ago)
Author:
mijoilmo
Message:

kaiken muutin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor.cs

    r5284 r5299  
    1212{ 
    1313    Player player; 
    14     ColorTileMap map; 
    15     static public Dictionary<string, Image> images = new Dictionary<string, Image>(); 
     14    private ColorTileMap map; 
     15    public ColorTileMap Map { get { return map; } set { map = value; } } 
     16    private Dictionary<string, Image> images = new Dictionary<string, Image>(); 
     17    public Dictionary<string, Image> Images { get { return images; } set { images = value; } } 
     18 
    1619    void AssignKeys() 
    1720    { 
     
    2629    void LoadAllImages() 
    2730    { 
    28         images["background0"] =                 LoadImage("graphics/backgrounds/space_background"); 
    29         images["player"] =                      LoadImage("graphics/ships/player"); 
    30         images["player_thruster"] =             LoadImage("graphics/effects/thrusters/thruster0.1"); 
    31         images["tile0"] =                       LoadImage("graphics/tiles/tile0.png"); 
     31        images["background0"] = LoadImage("graphics/backgrounds/space_background"); 
     32        images["player"] = LoadImage("graphics/ships/player"); 
     33        images["player_thruster"] = LoadImage("graphics/effects/thrusters/thruster0.1"); 
     34        images["tile0"] = LoadImage("graphics/tiles/tile0"); 
    3235    } 
    3336    void LoadLevel(string level) 
     
    4144    void LevelFromImage(string levelName) 
    4245    { 
     46        Dictionary<String, String> convert = new Dictionary<String, String>(); 
     47        convert.Add("000000","tile0"); 
    4348        ColorTileMap tileMap = ColorTileMap.FromLevelAsset(levelName); 
    44         tileMap.SetTileMethod(Color.FromHexCode("000000"), createTile, ""); 
     49        tileMap.SetTileMethod(Color.FromHexCode("000000"), createTile, convert["000000"]); 
    4550        tileMap.SetTileMethod(Color.FromHexCode("ff0000"), spawnPlayer); 
    46         tileMap.Execute(40,40); 
     51        double w=40, h=40; 
     52        tileMap.Execute(w, h); 
    4753        map = tileMap; 
     54        for (int x = 0; x < tileMap.RowCount; x++) 
     55        { 
     56            for (int y = 0; y < tileMap.ColumnCount; y++) 
     57            { 
     58                String hexColor=tileMap.GetTile(x,y).ToString().Substring(0,6); 
     59                int lask = 0; 
     60                if (hexColor == "FFFFFF"||hexColor=="FF00FF") { continue; } 
     61                if (hexColor == "FF0000") { lask++; continue; } 
     62                if (convert.ContainsKey(hexColor)) 
     63                { 
     64                    createTile(new Vector((x * w)+20, y * h+20), w, h, convert[hexColor]); 
     65                } 
     66            } 
     67        } 
    4868    } 
    4969    void createTile(Vector position, double w, double h, string id) 
    5070    { 
     71        if (id == "") { return; } 
    5172        MikonPhysicsObject tile = new MikonPhysicsObject(this, w, h); 
    5273        tile.MakeStatic(); 
    5374        tile.Position = position; 
    54         if (id != "") 
    55         { 
    56             tile.Image = images[id]; 
    57         } 
     75        tile.Image = images[id]; 
    5876        Add(tile); 
    5977    } 
Note: See TracChangeset for help on using the changeset viewer.