Changeset 3004 for 2012/24


Ignore:
Timestamp:
2012-06-13 15:04:53 (11 years ago)
Author:
tavekasa
Message:

Talletus.

Location:
2012/24/TatuS/Tasohyppelypeli1
Files:
8 added
12 edited

Legend:

Unmodified
Added
Removed
  • 2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Stickman Fight.cs

    r2961 r3004  
    2020    SoundEffect maaliAani = LoadSoundEffect("maali"); 
    2121 
     22    PlatformCharacter pelaaja2; 
     23    Image pojankuva = LoadImage("poika"); 
     24    List<Label> valikonKohdat; 
    2225    public override void Begin() 
    2326    { 
     27        Valikko(); 
     28 
     29 
    2430        Gravity = new Vector(0, -1000); 
    2531 
     
    2733        lisaaNappaimet(); 
    2834 
     35 
    2936        Camera.Follow(pelaaja1); 
    30         Camera.ZoomFactor = 7 
    31             ; 
     37        Camera.ZoomFactor = 2; 
     38 
    3239        Camera.StayInLevel = true; 
    33     } 
     40 
     41 
     42 
     43    } 
     44    void Valikko() 
     45    { 
     46        ClearAll(); 
     47 
     48        Level.BackgroundColor = Color.Blue; 
     49 
     50        valikonKohdat = new List<Label>(); 
     51 
     52        Label kohta1 = new Label("Aloita Uusi Peli"); 
     53        kohta1.Position = new Vector(0, 40); 
     54        valikonKohdat.Add(kohta1); 
     55 
     56        Label kohta2 = new Label("Lopeta Peli"); 
     57        kohta2.Position = new Vector(0, -40); 
     58        valikonKohdat.Add(kohta2); 
     59 
     60        foreach (Label valikonKohta in valikonKohdat) 
     61        { 
     62            Add(valikonKohta); 
     63        } 
     64 
     65        Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 
     66        Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Exit, null); 
     67 
     68        Mouse.IsCursorVisible = true; 
     69        Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); 
     70        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, ""); 
     71 
     72 
     73    } 
     74 
     75    void ValikossaLiikkuminen(AnalogState hiirenTila) 
     76    { 
     77        foreach (Label kohta in valikonKohdat) 
     78        { 
     79            if (Mouse.IsCursorOn(kohta)) 
     80            { 
     81                kohta.TextColor = Color.Red; 
     82            } 
     83            else 
     84            { 
     85                kohta.TextColor = Color.Black; 
     86            } 
     87 
     88        } 
     89    } 
     90 
     91    void AloitaPeli() 
     92    { 
     93        ClearAll(); 
     94        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, "Palaa Valikkoon"); 
     95    } 
     96 
     97 
     98 
     99 
     100 
     101 
     102 
    34103 
    35104    void luoKentta() 
    36105    { 
    37         TileMap kentta = TileMap.FromFile("kentta1.txt"); 
     106        TileMap kentta = TileMap.FromLevelAsset("kentta1"); 
    38107        kentta.SetTileMethod('#', lisaaTaso); 
    39108        kentta.SetTileMethod('*', lisaaTahti); 
    40109        kentta.SetTileMethod('N', lisaaPelaaja); 
     110        kentta.SetTileMethod('P', lisaapelaaja2); 
    41111        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    42112        Level.CreateBorders(); 
    43113        Level.Background.CreateGradient(Color.White, Color.SkyBlue); 
    44114    } 
     115 
     116 
    45117 
    46118    void lisaaTaso(Vector paikka, double leveys, double korkeus) 
     
    66138        pelaaja1 = new PlatformCharacter(leveys, korkeus); 
    67139        pelaaja1.Position = paikka; 
    68         pelaaja1.Mass = 4.0; 
     140        pelaaja1.Mass = 10.0; 
    69141        pelaaja1.Image = kuva; 
    70142        AddCollisionHandler(pelaaja1, kasittelePelaajanTormays); 
    71         pelaaja1.Weapon = new PlasmaCannon(20, 5); 
     143        pelaaja1.Weapon = new AssaultRifle(18, 5); 
    72144        Add(pelaaja1); 
    73     } ase.Angle += Angle FromDegrees(5); 
     145    } 
     146 
     147    void lisaapelaaja2(Vector Kohde, double leveys, double korkeus) 
     148    { 
     149        pelaaja2 = new PlatformCharacter(leveys, korkeus); 
     150        pelaaja2.Position = Kohde; 
     151        pelaaja2.Mass = 0.05; 
     152        pelaaja2.Image = pojankuva; 
     153        pelaaja2.Tag = "pelaaja2"; 
     154        pelaaja2.Weapon = new AssaultRifle(18, 5); 
     155        Add(pelaaja2); 
     156 
     157        FollowerBrain seuraajanAivot = new FollowerBrain(); 
     158        seuraajanAivot.Target = pelaaja1; 
     159        seuraajanAivot.Speed = 100; 
     160        seuraajanAivot.StopWhenTargetClose = false; 
     161        seuraajanAivot.TargetFollowDistance = 50; 
     162        seuraajanAivot.FollowAlways = true; 
     163        seuraajanAivot.Active = true; 
     164        pelaaja2.Brain = seuraajanAivot; 
     165 
     166 
     167    } 
     168 
     169    void AmmusOsui(PhysicsObject Ammus, PhysicsObject Kohde) 
     170    { 
     171 
     172        Explosion rajahdys = new Explosion(50); 
     173        rajahdys.Position = Ammus.Position; 
     174        Ammus.Destroy(); 
     175    } 
     176 
     177    void kentta() 
     178    { 
     179        Camera.Follow(pelaaja1, pelaaja2); 
     180        Camera.ZoomFactor = 2.0; 
     181        Camera.StayInLevel = true; 
     182    } 
     183 
     184 
    74185    void AmmuAseella() 
    75186    { 
     
    77188        if (ammus != null) 
    78189        { 
    79             ammus.Size *= 3; 
    80         } 
    81     } 
     190            ammus.Size *= 0.5; 
     191        } 
     192    } 
     193    void TahtaaYlos() 
     194    { 
     195        if (pelaaja1.FacingDirection == Direction.Right) 
     196        { 
     197            pelaaja1.Weapon.Angle += Angle.FromDegrees(6); 
     198        } 
     199        if (pelaaja1.FacingDirection == Direction.Left) 
     200        { 
     201            pelaaja1.Weapon.Angle += Angle.FromDegrees(-6); 
     202        } 
     203    } 
     204 
     205    void TahtaaAlas() 
     206    { 
     207        if (pelaaja1.FacingDirection == Direction.Right) 
     208        { 
     209            pelaaja1.Weapon.Angle += Angle.FromDegrees(-6); 
     210        } 
     211        if (pelaaja1.FacingDirection == Direction.Left) 
     212        { 
     213            pelaaja1.Weapon.Angle += Angle.FromDegrees(6); 
     214        } 
     215    } 
     216 
     217 
     218    void KasitteleVihollinenKuoli(PhysicsObject Ammus, PhysicsObject kohde) 
     219    { 
     220        if (kohde.Tag.ToString() == "pelaaja2") 
     221        { 
     222            kohde.Destroy(); 
     223        } 
     224 
     225    } 
     226 
     227    void JokuTormasi(PhysicsObject tormaaja, PhysicsObject kohde) 
     228    { 
     229    } 
     230 
     231 
     232 
    82233 
    83234    void lisaaNappaimet() 
     
    97248        ControllerOne.Listen(Button.A, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
    98249 
     250        Keyboard.Listen(Key.W, ButtonState.Down, TahtaaYlos, "Tähtää ylös rynnäkkökiväärillä"); 
     251        Keyboard.Listen(Key.S, ButtonState.Down, TahtaaAlas, "Tähtää alas rynnäkkökiväärillä"); 
     252 
     253 
    99254        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
    100255    } 
     
    112267    void kasittelePelaajanTormays(PhysicsObject hahmo, PhysicsObject kohde) 
    113268    { 
    114         if (kohde.Tag.ToString() == "tahti") 
    115         { 
    116             maaliAani.Play(); 
    117             MessageDisplay.Add("Keräsit tähden!"); 
    118             kohde.Destroy(); 
    119         } 
    120          
    121     } 
     269        if (kohde.Tag.ToString() == "pelaaja2") 
     270        { 
     271 
     272 
     273        } 
     274 
     275    } 
     276 
     277 
     278 
    122279} 
  • 2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.csproj.Debug.cachefile

    r2961 r3004  
    33Content\tahti.xnb 
    44Content\pelaaja1.xnb 
     5Content\kentta1.xnb 
     6Content\poika.xnb 
     7Content\kentta1.txt 
    58kentta1.txt 
  • 2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/ContentPipeline-{5AB5800E-57D2-49A9-AE03-8CB790FE286B}.xml

    r2961 r3004  
    3737      <Output>C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\pelaaja1.xnb</Output> 
    3838      <Time>2012-06-12T14:03:07.1052195+03:00</Time> 
     39    </Item> 
     40    <Item> 
     41      <Source>kentta1.txt</Source> 
     42      <Name>kentta1</Name> 
     43      <Importer>TextFileImporter</Importer> 
     44      <Processor>TextFileContentProcessor</Processor> 
     45      <Options>None</Options> 
     46      <Output>C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta1.xnb</Output> 
     47      <Time>2012-06-13T13:50:40.9804236+03:00</Time> 
     48    </Item> 
     49    <Item> 
     50      <Source>poika.png</Source> 
     51      <Name>poika</Name> 
     52      <Importer>TextureImporter</Importer> 
     53      <Processor>TextureProcessor</Processor> 
     54      <Options>None</Options> 
     55      <Output>C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\poika.xnb</Output> 
     56      <Time>2012-06-13T12:24:05.6658537+03:00</Time> 
    3957    </Item> 
    4058    <BuildSuccessful>true</BuildSuccessful> 
  • 2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/Tasohyppelypeli1.csproj.FileListAbsolute.txt

    r2961 r3004  
    1212C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\obj\x86\Debug\Tasohyppelypeli1.pdb 
    1313C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\pelaaja1.xnb 
     14C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta1.xnb 
     15C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta1.txt 
     16C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\poika.xnb 
  • 2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/cachefile-{5AB5800E-57D2-49A9-AE03-8CB790FE286B}-targetpath.txt

    r2961 r3004  
    33Content\tahti.xnb 
    44Content\pelaaja1.xnb 
     5Content\kentta1.xnb 
     6Content\poika.xnb 
     7Content\kentta1.txt 
  • 2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1Content/Tasohyppelypeli1Content.contentproj

    r2961 r3004  
    6868    </Compile> 
    6969  </ItemGroup> 
     70  <ItemGroup> 
     71    <Compile Include="kentta1.txt"> 
     72      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     73      <Name>kentta1</Name> 
     74      <Importer>TextFileImporter</Importer> 
     75      <Processor>TextFileContentProcessor</Processor> 
     76    </Compile> 
     77  </ItemGroup> 
     78  <ItemGroup> 
     79    <Compile Include="poika.png"> 
     80      <Name>poika</Name> 
     81      <Importer>TextureImporter</Importer> 
     82      <Processor>TextureProcessor</Processor> 
     83    </Compile> 
     84  </ItemGroup> 
    7085  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    7186  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
Note: See TracChangeset for help on using the changeset viewer.