Ignore:
Timestamp:
2015-07-02 08:32:56 (4 years ago)
Author:
sieerinn
Message:

Pelin voi nyt teoriassa pelata alusta loppuun läpi.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/LevelCreation.cs

    r6716 r6717  
    3939        level.SetObjectMethod("boss", CreateBoss); 
    4040        level.SetObjectMethod("bossspawn", CreateBossSpawn); 
     41        level.SetObjectMethod("itemdrop", CreateItem); 
    4142        level.Execute(); 
    4243 
     
    4647    } 
    4748 
     49    private void CreateItem(Vector position, double width, double height, Angle angle, Shape shape, string name, Dictionary<string, string> properties) 
     50    { 
     51        string itemname = properties["name"]; 
     52 
     53        var images = new Dictionary<string, Image>(); 
     54        images["pistol"] = GunImage; 
     55        images["grenade"] = GrenadeImage; 
     56        images["mask"] = MaskImage; 
     57 
     58        var item = PhysicsObject.CreateStaticObject(width, height, shape); 
     59        item.Tag = itemname; 
     60        item.Image = images[itemname]; 
     61        item.Position = position; 
     62        item.IgnoresCollisionResponse = true; 
     63        Add(item); 
     64    } 
     65 
    4866    void CreateEncounter(Vector position, double width, double height, Angle angle, Shape shape, string name, Dictionary<string, string> properties) 
    4967    { 
    5068        if (storyItems.Count < 2) 
    5169        { 
    52             PhysicsObject invisible = new PhysicsObject(width, height) { IsVisible = false, Tag = "storyTime" }; 
     70            PhysicsObject invisible = new PhysicsObject(width, height) { IsVisible = false, Tag = "storyTime", IgnoresCollisionResponse = true }; 
    5371            invisible.MakeStatic(); 
    5472            Add(invisible); 
     
    223241        { 
    224242            int itemType = RandomGen.NextInt(1, 3); 
     243 
     244            if (itemType == 1 && player.Inventory.FirstOrDefault(i => i is Grenade) == null) 
     245                return; 
     246 
     247            if (itemType == 2 && player.Inventory.FirstOrDefault(i => i is Pistol) == null) 
     248                return; 
     249 
    225250            var item = PhysicsObject.CreateStaticObject(10, 10); 
    226251            item.Position = position; 
     
    270295    void CreateBasicTile(Vector position, double width, double height, Image image, int layer, Dictionary<string, string> properties) 
    271296    { 
    272         //var tile = new GameObject(width, height); 
    273         var tile = properties.ContainsKey("collide") ? PhysicsObject.CreateStaticObject(width, height) : new GameObject(width, height); //new PhysicsObject(width, height)  PhysicsObject.CreateStaticObject(width, height) 
     297        bool oil = properties.ContainsKey("damage") && properties["damage"] == "true"; 
     298 
     299        bool solidTile = properties.ContainsKey("collide") || oil; 
     300        var tile =  solidTile? PhysicsObject.CreateStaticObject(width, height) : new GameObject(width, height); 
    274301        tile.Image = image; 
    275302        tile.Position = position; 
     303        if (oil) 
     304        { 
     305            ((PhysicsObject) tile).CollisionIgnoreGroup = 4; 
     306        } 
    276307        Add(tile, layer); 
    277308    } 
Note: See TracChangeset for help on using the changeset viewer.