Changeset 6705 for 2015/27


Ignore:
Timestamp:
2015-07-01 20:27:21 (8 years ago)
Author:
sieerinn
Message:

Junabossia, savua, sekä kaikenlaista ihme säätöä tehty.

Location:
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel
Files:
35 added
6 edited

Legend:

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

    r6701 r6705  
    260260                expl.ShockwaveReachesObject += delegate(IPhysicsObject o, Vector vector) 
    261261                { 
     262                    if (o.Tag == "boss") 
     263                    { 
     264                        ((TheLegendOfGabriel)Game.Instance).BossHealth.Value--; 
     265                    } 
     266 
    262267                    var cre = o as Creature; 
    263268                    if (cre != null) 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/LevelCreation.cs

    r6704 r6705  
    55using Jypeli; 
    66using Jypeli.Assets; 
     7using Jypeli.Widgets; 
    78 
    89/* 
     
    5455    void CreateBoss(Vector position, double width, double height, Angle angle, Shape shape, string name, Dictionary<string, string> properties) 
    5556    { 
    56         var bossHealth = new IntMeter(10); 
    57  
     57        BossHealth = new IntMeter(2, 0, 10); 
     58 
     59        var bar = new ProgressBar(Level.Width * 0.7, TILE_SIZE * 0.5); 
     60        bar.Y = Screen.Top - TILE_SIZE * 0.5; 
     61        bar.BindTo(BossHealth); 
     62        Add(bar); 
     63 
     64        // Juna ilmestyy välillä satunnaiseen spawniin. 
    5865        var bossTimer = new Timer(); 
    59         bossTimer.Interval = 4; 
     66        bossTimer.Interval = 8; 
    6067        bossTimer.Timeout += delegate 
    6168        { 
    62             Vector pos = RandomGen.SelectOne<Vector>(bossSpawnPositions); 
    63             //CreateBossTrainPart(pos, ); 
     69            // Luodaan päävaunu. 
     70            var pos = RandomGen.SelectOne<Vector>(bossSpawnPositions); 
     71            var train = CreateBossTrainPart(pos.X, pos.Y, trainAnimation); 
     72            double newPositionX = pos.X + train.Width; 
     73 
     74            // Luodaan muut vaunut. 
     75            int carriages = (int)(BossHealth.Value/(double)BossHealth.MaxValue * 6); 
     76            for (int i = 0; i < carriages; i++) 
     77            { 
     78                var part = CreateBossTrainPart(newPositionX, pos.Y, carriageAnimation); 
     79                newPositionX += part.Width; 
     80            } 
    6481        }; 
    6582        bossTimer.Start(); 
    66     } 
    67  
    68     void CreateBossTrainPart(Vector position, Animation anim) 
    69     { 
    70         var part = PhysicsObject.CreateStaticObject(150, 70); 
    71         part.Position = position; 
     83 
     84        BossHealth.LowerLimit += delegate 
     85        { 
     86            EnemyDieSound.Play(); 
     87            bossTimer.Stop(); 
     88            Timer.SingleShot(4.0, Victory); 
     89 
     90            foreach (var part in GetObjectsWithTag("boss")) 
     91            { 
     92                part.Destroy(); 
     93                var smoke = new GameObject(80, 160); 
     94                smoke.X = part.X; 
     95                smoke.Bottom = part.Bottom; 
     96                smoke.Animation = new Animation(smokeAnimation); 
     97                smoke.Animation.Start(1); 
     98                smoke.Animation.Played += () => smoke.Destroy(); 
     99                Add(smoke); 
     100            } 
     101        }; 
     102    } 
     103 
     104    PhysicsObject CreateBossTrainPart(double left, double y, Animation anim) 
     105    { 
     106        var part = PhysicsObject.CreateStaticObject(70, 40); 
     107        part.Left = left; 
     108        part.Y = y; 
    72109        part.Animation = anim; 
    73110        part.Animation.Start(); 
    74         part.Velocity = new Vector(-50, 0); 
     111        part.Velocity = new Vector(-80, 0); 
     112        part.Tag = "boss"; 
     113        part.CollisionIgnoreGroup = 3; 
    75114        Add(part); 
     115 
     116        // Pala on näkyvillä vain kentän sisäpuolella. 
     117        var appearTimer = new Timer(); 
     118        appearTimer.Interval = 0.05; 
     119        appearTimer.Timeout += delegate 
     120        { 
     121            part.IsVisible = part.Left < Level.Right; 
     122 
     123            if (part.Right < Level.Left) 
     124            { 
     125                part.Destroy(); 
     126                appearTimer.Stop(); 
     127            } 
     128        }; 
     129        appearTimer.Start(); 
     130 
     131        // Palat luo vihollisia jatkuvasti. 
     132        var enemySpawnTimer = new Timer(); 
     133        enemySpawnTimer.Interval = 2.0; 
     134        enemySpawnTimer.Timeout += delegate 
     135        { 
     136            if (part.Right < Level.Right) 
     137            { 
     138                CreateCoyote(part.Position, TILE_SIZE, TILE_SIZE, Angle.Zero, Shape.Rectangle, "", null); 
     139            } 
     140        }; 
     141        enemySpawnTimer.Start(); 
     142 
     143        part.Destroyed += delegate 
     144        { 
     145            appearTimer.Stop(); 
     146            enemySpawnTimer.Stop(); 
     147        }; 
     148 
     149        return part; 
    76150    } 
    77151 
     
    92166        var enemy = new Creature(width, height, 1); 
    93167        enemy.MoveAnimations = DirectionalAnimations(coyoteLeft, coyoteRight, coyoteUp, coyoteDown); 
     168        enemy.Image = enemy.MoveAnimations[Direction.Right].CurrentFrame; 
    94169        enemy.Position = position; 
    95170        enemy.Tag = "enemy"; 
    96171        enemy.Brain = new FollowerBrain(player) { Speed = 50 }; 
     172        enemy.CollisionIgnoreGroup = 3; 
    97173        Add(enemy, 1); 
    98174        enemies.Add(enemy); 
     
    103179        }); 
    104180 
    105         enemy.Health.LowerLimit += enemy.Destroy; 
     181        enemy.Health.LowerLimit += delegate 
     182        { 
     183            enemy.Destroy(); 
     184            RandomItemDrop(enemy.Position); 
     185 
     186            EnemyDieSound.Play(); 
     187 
     188            var smoke = new GameObject(20, 40); 
     189            smoke.X = enemy.X; 
     190            smoke.Bottom = enemy.Bottom; 
     191            smoke.Animation = new Animation(smokeAnimation); 
     192            smoke.Animation.Start(1); 
     193            smoke.Animation.Played += () => smoke.Destroy(); 
     194            Add(smoke); 
     195        }; 
     196    } 
     197 
     198    void RandomItemDrop(Vector position) 
     199    { 
     200        var chance = RandomGen.NextDouble(0, 100); 
     201        if (chance < 20) 
     202        { 
     203            int itemType = RandomGen.NextInt(1, 3); 
     204            var item = PhysicsObject.CreateStaticObject(10, 10); 
     205            item.Position = position; 
     206            item.Image = itemType == 1 ? GrenadeBoxImage : AmmoBoxImage; 
     207            item.Tag = itemType == 1 ? "grenadebox" : "ammobox"; 
     208            item.IgnoresCollisionResponse = true; 
     209            Add(item); 
     210        } 
    106211    } 
    107212 
     
    122227    } 
    123228 
    124         /// <summary> 
     229    /// <summary> 
    125230    /// Pelaajan päällä näkyvä tiili. 
    126231    /// </summary> 
     
    142247    /// Luo tavallisen tiilen. 
    143248    /// </summary> 
    144     GameObject CreateBasicTile(Vector position, double width, double height, Image image, int layer, Dictionary<string, string> properties) 
    145     { 
    146         var tile = properties.ContainsKey("collide") ? new PhysicsObject(width, height) : new GameObject(width, height); 
     249    void CreateBasicTile(Vector position, double width, double height, Image image, int layer, Dictionary<string, string> properties) 
     250    { 
     251        var tile = properties.ContainsKey("collide") ? PhysicsObject.CreateStaticObject(width, height) : new GameObject(width, height); 
    147252        tile.Image = image; 
    148253        tile.Position = position; 
    149254        Add(tile, layer); 
    150         return tile; 
    151255    } 
    152256 
     
    156260    void CreateExit(Vector position, double width, double height, Angle angle, Shape shape, string name, Dictionary<string, string> properties) 
    157261    { 
    158         var target = properties["goto"] == "disabled"? null : properties["goto"].Split('@'); // Jos peli kaatuu tälle riville niin joltain exitiltä puuttuu goto-property. 
     262        var target = properties["goto"] == "disabled" ? null : properties["goto"].Split('@'); // Jos peli kaatuu tälle riville niin joltain exitiltä puuttuu goto-property. 
    159263        var exit = new Exit(width, height); 
    160264        exit.Position = position; 
     
    162266        { 
    163267            exit.TargetLevel = target[0]; 
    164             exit.TargetExitName = target[1];    
     268            exit.TargetExitName = target[1]; 
    165269        } 
    166270        exit.Name = name; 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.cs

    r6704 r6705  
    7676    StoryItem[] storyItem = new StoryItem[3]; 
    7777 
     78    public IntMeter BossHealth; 
    7879    private List<Vector> bossSpawnPositions = new List<Vector>();  
    7980 
     
    8788    public static SoundEffect SwordSound = LoadSoundEffect("swordsound"); 
    8889    public static SoundEffect GunSound = LoadSoundEffect("gunsound"); 
     90    public static SoundEffect EnemyDieSound = LoadSoundEffect("enemydie"); 
    8991 
    9092    public static Image GunImage = LoadImage("gun"); 
     
    98100    public static Image GrenadeSmallImage = LoadImage("gransmall"); 
    99101 
     102    public static Image GrenadeBoxImage = LoadImage("grenadebox"); 
     103    public static Image AmmoBoxImage = LoadImage("ammobox"); 
     104 
    100105    public static Image FrameImage = LoadImage("frame"); 
    101106    public static Image ActiveItemFrameImageX = LoadImage("activeitemframe"); 
     
    146151    private Animation carriageAnimation; 
    147152 
     153    [AssetName("smoke")] 
     154    private Animation smokeAnimation; 
     155 
    148156    #endregion 
    149157 
     
    155163        StartGame(); 
    156164        Intro(); 
     165        BuildUI(); 
     166    } 
     167 
     168    void Victory() 
     169    { 
     170        ClearAll(); 
     171        Level.Background.Color = Color.Black; 
     172 
     173        var text = new Label("Voitit muutes belin."); // Tekstin voisi vaihtaa. 
     174        text.TextColor = Color.White; 
     175        Add(text); 
     176    } 
     177 
     178    void BuildUI() 
     179    { 
    157180        BuildRightBar(); 
    158181        BuildInventoryCycle(); 
     
    160183        UpdateItemCycleImages(); 
    161184    } 
    162  
    163     private void BuildHealthBar() 
     185     
     186    void BuildHealthBar() 
    164187    { 
    165188        var bar = new ProgressBar(32 * 10, 32); 
     
    358381        player.Inventory.Add(new Grenade(player)); 
    359382 
    360         player.Health.Value = 3; // Alkuun vain kolme sydäntä. 
     383        //player.Health.Value = 3; // Alkuun vain kolme sydäntä. 
     384        player.Health.Value = player.Health.MaxValue = 100; 
    361385 
    362386        AddCollisionHandler(player, "exit", CollidesWithExit); 
     
    365389            player.Health.Value--; 
    366390        }); 
     391 
     392        AddCollisionHandler(player, "ammobox", delegate(PhysicsObject p, PhysicsObject box) 
     393        { 
     394            box.Destroy(); 
     395            var gun = player.Inventory.FirstOrDefault(i => i is Pistol); 
     396            if (gun != null) 
     397            { 
     398                gun.Usages.Value += 5; 
     399            } 
     400        }); 
     401 
     402        AddCollisionHandler(player, "grenadebox", delegate(PhysicsObject p, PhysicsObject box) 
     403        { 
     404            box.Destroy(); 
     405            var grenades = player.Inventory.FirstOrDefault(i => i is Grenade); 
     406            if (grenades != null) 
     407            { 
     408                grenades.Usages.Value += 5; 
     409            } 
     410        }); 
    367411    } 
    368412 
    369413    void UseItem(Item item, Item otherItem, Action action) 
    370414    { 
     415        if (player.IsDestroyed) 
     416            return; 
     417 
    371418        bool inUse = false; 
    372419        if (otherItem != null) 
     
    402449        currentItem.UpdateImage(player.ActiveItem); 
    403450        nextItem.UpdateImage(player.NextItem); 
    404         /* 
    405         if (player.PrevItem != null) prevItem.Image = player.PrevItem.InventoryImage; 
    406         if (player.NextItem != null) nextItem.Image = player.NextItem.InventoryImage; 
    407         if (player.ActiveItem != null) currentItem.Image = player.ActiveItem.InventoryImage; 
    408          */ 
    409451 
    410452        if (player.Sword != null) 
     
    422464    { 
    423465        var oldExit = pExit as Exit; 
    424         if (oldExit == null || transition || oldExit.TargetLevel == null) 
     466        if (oldExit == null || transition || oldExit.TargetLevel == null || pExit.IsDestroying || pExit.IsDestroyed) 
    425467            return; 
    426468 
     469        oldExit.Destroy(); 
     470 
     471        var oldExitDirection = GetExitDirection(oldExit); 
    427472        transition = true; 
    428473 
     
    452497 
    453498        // Jompikumpi uloskäynti ei ole kentän laidalla, sulava siirtyminen ei ole mahdollista. 
    454         if (GetExitDirection(targetExit) == Direction.None || GetExitDirection(oldExit) == Direction.None) 
     499        if (GetExitDirection(targetExit) == Direction.None || oldExitDirection == Direction.None) 
    455500        { 
    456501            transition = false; 
     
    458503            oldObjects.Clear(); 
    459504 
    460             BuildRightBar(); 
    461             BuildInventoryCycle(); 
    462             UpdateItemCycleImages(); 
     505            BuildUI(); 
    463506 
    464507            // Yritetään päätellä pelaajalle joku järkevä paikka. 
    465508            player.Position = targetExit.Position + Direction.Inverse(targetExit.Position.Angle.MainDirection).GetVector() * TILE_SIZE * 2; 
    466             Camera.ZoomToLevel(); 
     509             
     510            Camera.Follow(player); 
     511            Camera.ZoomFactor = 2.0; 
    467512            return; 
    468513        } 
     
    497542        Camera.Position += transitionVector; 
    498543        Vector pos = Camera.Position; 
    499         Camera.ZoomToLevel(); 
     544        Camera.Follow(player); 
     545        Camera.ZoomFactor = 2.0; 
    500546        Camera.Position = pos; 
    501547    } 
     
    553599                oldObjects.Clear(); 
    554600 
    555                 BuildRightBar(); 
    556                 BuildInventoryCycle(); 
    557                 UpdateItemCycleImages(); 
     601                BuildUI(); 
    558602            } 
    559603        } 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/TheLegendOfGabrielContent.contentproj

    r6703 r6705  
    305305    </Compile> 
    306306  </ItemGroup> 
     307  <ItemGroup> 
     308    <Compile Include="goldenheart.png"> 
     309      <Name>goldenheart</Name> 
     310      <Importer>TextureImporter</Importer> 
     311      <Processor>TextureProcessor</Processor> 
     312    </Compile> 
     313  </ItemGroup> 
     314  <ItemGroup> 
     315    <Compile Include="ammobox.png"> 
     316      <Name>ammobox</Name> 
     317      <Importer>TextureImporter</Importer> 
     318      <Processor>TextureProcessor</Processor> 
     319    </Compile> 
     320    <Compile Include="grenadebox.png"> 
     321      <Name>grenadebox</Name> 
     322      <Importer>TextureImporter</Importer> 
     323      <Processor>TextureProcessor</Processor> 
     324    </Compile> 
     325  </ItemGroup> 
     326  <ItemGroup> 
     327    <Compile Include="enemydie.wav"> 
     328      <Name>enemydie</Name> 
     329      <Importer>WavImporter</Importer> 
     330      <Processor>SoundEffectProcessor</Processor> 
     331    </Compile> 
     332  </ItemGroup> 
     333  <ItemGroup> 
     334    <Compile Include="smoke.anim"> 
     335      <Name>smoke</Name> 
     336      <Importer>AnimationImporter</Importer> 
     337      <Processor>AnimationContentProcessor</Processor> 
     338    </Compile> 
     339  </ItemGroup> 
     340  <ItemGroup> 
     341    <Compile Include="level3.tmx"> 
     342      <Name>level3</Name> 
     343      <Importer>TextFileImporter</Importer> 
     344      <Processor>TextFileContentProcessor</Processor> 
     345      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     346    </Compile> 
     347  </ItemGroup> 
    307348  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    308349  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/level1.tmx

    r6702 r6705  
    3131   </properties> 
    3232  </object> 
    33   <object id="28" x="480" y="460" width="20" height="60"> 
     33  <object id="28" name="right" x="480" y="460" width="20" height="60"> 
    3434   <properties> 
    3535    <property name="goto" value="level3@left"/> 
Note: See TracChangeset for help on using the changeset viewer.