Changeset 6632 for 2015/27


Ignore:
Timestamp:
2015-07-01 08:30:26 (4 years ago)
Author:
sieerinn
Message:

Kojootteja vastaan voi taistella, pelaajalla elämät, kenttiä korjailtu, hoboluola tehty.

Location:
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel
Files:
9 edited

Legend:

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

    r6550 r6632  
    1010    public Direction LastDirection { get; private set; } 
    1111 
    12     public Creature(double width, double height) 
     12    public IntMeter Health { get; set; } 
     13 
     14    public Creature(double width, double height, int health) 
    1315        : base(width, height) 
    1416    { 
     17        Health = new IntMeter(health, 0, health); 
    1518        MovementSpeed = new DoubleMeter(2000, 0, 2000); 
    1619        LastDirection = Direction.Down; 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/Item.cs

    r6631 r6632  
    8282                    var swordAngle = swordAngles[player.Animation.CurrentFrameIndex]; 
    8383                    if (dir == Direction.Left) 
    84                         swordAngle = Angle.FromDegrees(swordAngle.Degrees*-1); 
    85                     SwordObject.Position = player.Position + (dir.Angle + swordAngle).GetVector()*15; 
     84                        swordAngle = Angle.FromDegrees(swordAngle.Degrees * -1); 
     85                    SwordObject.Position = player.Position + (dir.Angle + swordAngle).GetVector() * 15; 
    8686                    SwordObject.Angle = swordAngle + 
    8787                                        Angle.FromDegrees(dir == Direction.Left || dir == Direction.Right ? 90 : 0); 
     
    9090                catch (IndexOutOfRangeException ex) 
    9191                { 
    92                      
     92 
    9393                } 
    9494            } 
     
    107107 
    108108        SwordObject = PhysicsObject.CreateStaticObject(6, 16); 
     109        SwordObject.Tag = "playerattack"; 
    109110        SwordObject.CollisionIgnoreGroup = player.CollisionIgnoreGroup; 
    110111        SwordObject.Position = player.Position; 
     
    201202 
    202203            var bullet = new PhysicsObject(4, 4); 
     204            bullet.Tag = "playerattack"; 
    203205            bullet.Image = TheLegendOfGabriel.BulletImage; 
    204206            bullet.Position = player.Position + ShootDirection.GetVector() * player.Width * 0.7; 
    205207            bullet.Hit(ShootDirection.GetVector() * 500); 
    206208            Game.Instance.Add(bullet); 
     209 
     210            ((TheLegendOfGabriel)Game.Instance).AddCollisionHandler(bullet, 
     211                delegate(PhysicsObject b, PhysicsObject e) 
     212                { 
     213                    bullet.Destroy(); 
     214                }); 
    207215        } 
    208216        CancelUse(); 
     
    223231class Grenade : Item 
    224232{ 
    225     public Grenade(Player player) : base(player) 
     233    public Grenade(Player player) 
     234        : base(player) 
    226235    { 
    227236        Usages.MaxValue = 15; 
     
    249258                var expl = new Explosion(50); 
    250259                expl.Position = grenade.Position; 
     260                expl.ShockwaveReachesObject += delegate(IPhysicsObject o, Vector vector) 
     261                { 
     262                    var cre = o as Creature; 
     263                    if (cre != null) 
     264                    { 
     265                        cre.Health.Value--; 
     266                    } 
     267                }; 
    251268                Game.Instance.Add(expl); 
    252269                grenade.Destroy(); 
     
    261278    private GameObject bigMonocle; 
    262279 
    263     public Monocle(Player player) : base(player) 
     280    public Monocle(Player player) 
     281        : base(player) 
    264282    { 
    265283        InventoryImage = TheLegendOfGabriel.MonocleImage; 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/LevelCreation.cs

    r6631 r6632  
    44using System.Text; 
    55using Jypeli; 
     6using Jypeli.Assets; 
    67 
    78/* 
     
    2829        level.SetObjectMethod("exit", CreateExit); 
    2930        level.SetTileMethod("decoration", CreateDecoration); 
    30         level.SetObjectMethod("player", CreatePlayer); 
     31        //level.SetObjectMethod("player", CreatePlayer); 
    3132        level.SetObjectMethod("blockade", CreateBlock); 
    32         // level.SetObjectMethod("coyote", CreateEnemy); 
     33        level.SetObjectMethod("coyote", CreateCoyote); 
    3334        level.Execute(); 
    3435 
     
    4647        Add(block); 
    4748 
     49    } 
     50 
     51    void CreateCoyote(Vector position, double width, double height, Angle angle, Shape shape, string name, Dictionary<string, string> properties) 
     52    { 
     53        var enemy = new Creature(width, height, 1); 
     54        enemy.MoveAnimations = DirectionalAnimations(coyoteLeft, coyoteRight, coyoteUp, coyoteDown); 
     55        enemy.Position = position; 
     56        enemy.Tag = "enemy"; 
     57        enemy.Brain = new FollowerBrain(player) { Speed = 50 }; 
     58        Add(enemy, 1); 
     59        enemies.Add(enemy); 
     60 
     61        AddCollisionHandler(enemy, "playerattack", delegate(PhysicsObject e, PhysicsObject a) 
     62        { 
     63            enemy.Health.Value--; 
     64        }); 
     65 
     66        enemy.Health.LowerLimit += enemy.Destroy; 
     67 
     68        /* 
     69        Timer updateTimer = new Timer(); 
     70        updateTimer.Interval = 0.02; 
     71        updateTimer.Timeout += delegate 
     72        { 
     73            if (!(enemy.Brain is FollowerBrain)) 
     74            { 
     75                 
     76            } 
     77            enemy.UpdateCreature(Time); 
     78        }; 
     79        updateTimer.Start(); 
     80         */ 
    4881    } 
    4982 
     
    68101        player.Inventory.Add(new Grenade(player)); 
    69102 
     103        player.Health.Value = 3; // Alkuun vain kolme sydäntä. 
     104 
    70105        AddCollisionHandler(player, "exit", CollidesWithExit); 
     106        AddCollisionHandler(player, "enemy", delegate(PhysicsObject p, PhysicsObject e) 
     107        { 
     108            player.Health.Value--; 
     109        }); 
    71110    } 
    72111 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/Player.cs

    r6619 r6632  
    4343 
    4444    public Player() 
    45         : base(TheLegendOfGabriel.TILE_SIZE, TheLegendOfGabriel.TILE_SIZE) 
     45        : base(TheLegendOfGabriel.TILE_SIZE, TheLegendOfGabriel.TILE_SIZE, 10) 
    4646    { 
    4747        Inventory = new List<Item>(); 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.cs

    r6631 r6632  
    6161 
    6262    private Player player; 
     63    private List<Creature> enemies = new List<Creature>();  
    6364 
    6465    private bool transition; 
     
    99100    public static Image ActiveItemFrameImageZ = LoadImage("activeitemframez"); 
    100101 
     102    public static Image PlayerHealthImage = LoadImage("playerhealth"); 
     103    public static Image PlayerHealthEmptyImage = LoadImage("playerhealthempty"); 
     104 
    101105    [AssetName("walkright")] 
    102106    internal Animation playerWalkRight; 
     
    143147        LoadAnimations(); 
    144148        StartGame(); 
    145         //Intro(); 
     149        Intro(); 
    146150        BuildRightBar(); 
    147151        BuildInventoryCycle(); 
     152        BuildHealthBar(); 
    148153        UpdateItemCycleImages(); 
     154    } 
     155 
     156    private void BuildHealthBar() 
     157    { 
     158        var bar = new ProgressBar(32 * 10, 32); 
     159        bar.Right = Screen.Right - 50; 
     160        bar.Top = Screen.Top - 50; 
     161        bar.Image = PlayerHealthEmptyImage; 
     162        bar.BarImage = PlayerHealthImage; 
     163        bar.BindTo(player.Health); 
     164        Add(bar); 
    149165    } 
    150166 
     
    193209        for (int i = 0; i < STORYITEM_COUNT; i++) 
    194210        { 
    195             GameObject member = new GameObject(FrameImage); 
    196             member.Position = new Vector(Level.Right + FrameImage.Width, Level.Top - Level.Width * 0.25 - FrameImage.Height * i * 1.5); 
     211            Label member = new Label(FrameImage); 
     212            member.Size = new Vector(40, 40); 
     213            member.Position = new Vector(Screen.Right - FrameImage.Width, Screen.Top - Screen.Width * 0.25 - FrameImage.Height * i * 1.5); 
    197214            Add(member); 
    198215 
     
    205222            } 
    206223            member.Add(inner); 
    207         } 
    208     } 
     224 
     225            // Gameobjektit ei liiku mukana jos kamera liikkuu joten tein kehyksistä Labeleita. 
     226            /*   
     227            GameObject member = new GameObject(FrameImage); 
     228            member.Position = new Vector(Level.Right + FrameImage.Width, Level.Top - Level.Width * 0.25 - FrameImage.Height * i * 1.5); 
     229            Add(member); 
     230 
     231            GameObject inner = new GameObject(TILE_SIZE, TILE_SIZE); 
     232            inner.Color = Color.Black; 
     233            if (storyItem[i] != null) 
     234            { 
     235                inner.Image = storyItem[i].InventoryImage; 
     236                Mouse.ListenOn(inner, MouseButton.Left, ButtonState.Pressed, ShowTextItem, "View those precious memories", storyItem[i]); 
     237            } 
     238            member.Add(inner); 
     239            */ 
     240        } 
     241    } 
     242 
    209243    /// <summary> 
    210244    /// Lataa automaagisesti kaikki animaatiot. 
     
    250284        }), LetterImage); 
    251285 
    252         ShowTextItem(storyItem[0]); 
     286        //ShowTextItem(storyItem[0]); 
    253287    } 
    254288 
     
    282316    { 
    283317        ClearAll(); 
     318        CreatePlayer(new Vector(0, -300), TILE_SIZE, TILE_SIZE, Angle.Zero, Shape.Rectangle, "", null); 
    284319        CreateLevel("level1"); 
    285320        //CreatePlayer(new Vector(-Level.Width/3, Level.Bottom + TILE_SIZE * 2)); 
     
    378413        transition = true; 
    379414 
     415        enemies.Clear(); 
     416 
    380417        // Otetaan vanhat objektit talteen. 
    381418        oldObjects.Clear(); 
     
    395432        var targetExit = exits.FirstOrDefault(e => e.Name == oldExit.TargetExitName); 
    396433 
     434        if (targetExit == null) 
     435        { 
     436            throw new Exception("Tarkisita kenttien exittien nimet."); 
     437        } 
     438 
    397439        // Jompikumpi uloskäynti ei ole kentän laidalla, sulava siirtyminen ei ole mahdollista. 
    398440        if (GetExitDirection(targetExit) == Direction.None || GetExitDirection(oldExit) == Direction.None) 
     
    401443            oldObjects.ForEach(o => o.Destroy()); 
    402444            oldObjects.Clear(); 
     445 
     446            BuildRightBar(); 
     447            BuildInventoryCycle(); 
     448            UpdateItemCycleImages(); 
    403449 
    404450            // Yritetään päätellä pelaajalle joku järkevä paikka. 
     
    527573    { 
    528574        player.UpdateCreature(time); 
     575        enemies.ForEach(e => e.UpdateCreature(time)); 
    529576        base.Update(time); 
    530577    } 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/LegendOfGabrielTileset.tsx

    r6538 r6632  
    77  </properties> 
    88 </tile> 
     9 <tile id="16"> 
     10  <properties> 
     11   <property name="collide" value="true"/> 
     12  </properties> 
     13 </tile> 
    914</tileset> 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/TheLegendOfGabrielContent.contentproj

    r6631 r6632  
    257257    </Compile> 
    258258  </ItemGroup> 
     259  <ItemGroup> 
     260    <Compile Include="playerhealth.png"> 
     261      <Name>playerhealth</Name> 
     262      <Importer>TextureImporter</Importer> 
     263      <Processor>TextureProcessor</Processor> 
     264    </Compile> 
     265  </ItemGroup> 
     266  <ItemGroup> 
     267    <Compile Include="playerhealthempty.png"> 
     268      <Name>playerhealthempty</Name> 
     269      <Importer>TextureImporter</Importer> 
     270      <Processor>TextureProcessor</Processor> 
     271    </Compile> 
     272  </ItemGroup> 
     273  <ItemGroup> 
     274    <Compile Include="level2.tmx"> 
     275      <Name>level2</Name> 
     276      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     277      <Importer>TextFileImporter</Importer> 
     278      <Processor>TextFileContentProcessor</Processor> 
     279    </Compile> 
     280  </ItemGroup> 
     281  <ItemGroup> 
     282    <Compile Include="hobocave.tmx"> 
     283      <Name>hobocave</Name> 
     284      <Importer>TextFileImporter</Importer> 
     285      <Processor>TextFileContentProcessor</Processor> 
     286      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     287    </Compile> 
     288  </ItemGroup> 
    259289  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    260290  <!--  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

    r6624 r6632  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<map version="1.0" orientation="orthogonal" renderorder="right-down" width="25" height="40" tilewidth="20" tileheight="20" nextobjectid="41"> 
    3  <tileset firstgid="1" name="testlevel4" tilewidth="20" tileheight="20"> 
    4   <image source="tileset.png" width="200" height="200"/> 
    5  </tileset> 
    6  <tileset firstgid="101" name="tileset" tilewidth="20" tileheight="20"> 
    7   <image source="tileset.png" width="200" height="200"/> 
    8  </tileset> 
     3 <tileset firstgid="1" source="LegendOfGabrielTileset.tsx"/> 
    94 <layer name="base" width="25" height="40"> 
    105  <data encoding="base64" compression="zlib"> 
    11    eJztkbEOgDAIRDv1U7s4OfD/Lg6EGKqVOyNheFPhXgFprYliUwgI6+iKO/1Xdd2wK+yb5/NqVx1vYDiKosjDOEHnoxzo/GwzoPK/ugfjJui9ZXCw7/6H/DEB4WDMEb3zVcesPmL3Xl/Ubb3+qN1H/PNpNsvBmCHChXYchDljRg== 
     6   eJztk7sOgDAIRYlDnRz4/591cSAEaVO5mBCGMxU44VEmIhacAgahHUOwkm/FDcUl0G+e6y3WYsXxlQxH0zR1OB7Q9VEOdP1qPaDq/7WPjJ2g51bB0f9wfkOIm7JqZjgiZ77rmMVHzN7Li9qtlx81+8wbzHZk9BDhQjtuzvQXiQ== 
    127  </data> 
    138 </layer> 
    149 <layer name="decoration" width="25" height="40"> 
    1510  <data encoding="base64" compression="zlib"> 
    16    eJzt1zEKgDAMBdAsvbAeS1d1FDyZFAyEWOzyfyTQDy4V8mhrKhV5pzTG0PHG/DxsAx3WWtn1KG6ckT/2HBW7JpnnMYxhoLKQjVp/Jxpan2XY+ixjM/UPknEKfx7e0TDOXXWs0foPIhwbpHF13qPm8eVkOq9qL65kQ3sxu+H7A23oN+X7A2n0Em1MAQYr0Xeccf+INW4wjiDB 
     11   eJzt1zEKgDAMBdAsXfVYulpHwfsfQwoGQih2+T8Y6AcXhTxSmkpF/pH1fZApHQMdb6Bi16O494yw+ogw7Jpk7mMa00BlIxutfiUaWp9l2Pos4zD1T5JxCb8P72gY56461uj9BxGODdK4B99RfXw5mc6rNos72dBZzG74+UAbuqf8fCCNUaKNJcBgJfqOM+8fscYDiTINLw== 
    1712  </data> 
    1813 </layer> 
     
    2116   <property name="goto" value="level2@bottom"/> 
    2217  </properties> 
    23   <object id="19" x="100" y="0" width="20" height="20"> 
     18  <object id="19" name="tunnelblockade" x="100" y="0" width="20" height="20"> 
    2419   <properties> 
    2520    <property name="goto" value="level2@bottom"/> 
     
    3126   </properties> 
    3227  </object> 
    33   <object id="27" x="400" y="20" width="20" height="20"> 
     28  <object id="27" name="hobo" x="400" y="20" width="20" height="20"> 
    3429   <properties> 
    35     <property name="goto" value="hobocave@bottom"/> 
     30    <property name="goto" value="hobocave@enterance"/> 
    3631   </properties> 
    3732  </object> 
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/level2.tmx

    r6547 r6632  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<map version="1.0" orientation="orthogonal" renderorder="right-down" width="25" height="25" tilewidth="20" tileheight="20" nextobjectid="5"> 
    3  <tileset firstgid="1" name="tileset" tilewidth="20" tileheight="20"> 
    4   <image source="tileset.png" width="200" height="200"/> 
    5  </tileset> 
     3 <tileset firstgid="1" source="LegendOfGabrielTileset.tsx"/> 
    64 <layer name="base" width="25" height="25"> 
    75  <data encoding="base64" compression="zlib"> 
    8    eJzjZWBg4B3Fo3gUj+JRPIpH8aDDTDQylxVqNq3MR7aDluEDsoONhvYwodlBTXuYkDArGp9YewCcqh7j 
     6   eJwTZGBgEBzFo3gUj+JRPIpH8aDDTDQylw1qNq3MR7aDluHDRmN7mNDsoKY9TEiYDY1PrD0AH9ooVA== 
     7  </data> 
     8 </layer> 
     9 <layer name="decoration" width="25" height="25"> 
     10  <data encoding="base64" compression="zlib"> 
     11   eJxjYBgFo2AUjIJRMApGwUgCrKN2DAs7ACLEABo= 
    912  </data> 
    1013 </layer> 
     
    1316   <property name="goto" value="level1@top"/> 
    1417  </properties> 
    15   <object id="3" x="220" y="480" width="20" height="20"/> 
     18  <object id="3" name="bottom" x="220" y="480" width="20" height="20"> 
     19   <properties> 
     20    <property name="goto" value="level1@tunnelblockade"/> 
     21   </properties> 
     22  </object> 
    1623 </objectgroup> 
    1724</map> 
Note: See TracChangeset for help on using the changeset viewer.