Changeset 4414


Ignore:
Timestamp:
2013-07-03 15:06:53 (10 years ago)
Author:
vilmikvi
Message:

Talletus.

Location:
2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • 2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAME.cs

    r4374 r4414  
    1414 
    1515    PlatformCharacter pelaaja1; 
    16  
     16    Image VihunKuva = LoadImage("Vihu"); 
    1717    Image[] seisomisanimaatio = LoadImages("Trollface"); 
    18     Image[] kävelykuvat = LoadImages("Trollface","Trollface2"); 
     18    Image[] kävelykuvat = LoadImages("Trollface", "Trollface2"); 
    1919    Image[] hyokkausanimaatio = LoadImages("Trollfaceampuu"); 
    2020 
     
    2424    DoubleMeter energia; 
    2525    DoubleMeter elamat; 
     26    IntMeter esLaskuri; 
    2627 
    2728    SoundEffect laaserAani = LoadSoundEffect("maali"); 
     29    int nykyinenKentta = 2; 
     30 
    2831 
    2932    public override void Begin() 
    3033    { 
     34        AloitaKentta(nykyinenKentta); 
     35    } 
     36     
     37 
     38    void AloitaKentta( int kentanNro ) 
     39    { 
    3140        Gravity = new Vector(0, -1000); 
    32          
    33  
    34         LuoKentta(); 
     41 
     42        LisaaLaskuri(); 
     43        LuoKentta("kentta" + kentanNro); 
    3544        LisaaNappaimet(); 
    3645 
     
    4554        Camera.ZoomFactor = 1.2; 
    4655        Camera.StayInLevel = true; 
     56 
     57        nykyinenKentta = kentanNro; 
     58    } 
     59 
     60    void SeuraavaKentta() 
     61    { 
     62        AloitaKentta(nykyinenKentta + 1); 
    4763    } 
    4864 
     
    5773        energiaPalkki.BindTo(energia); 
    5874        Add(energiaPalkki); 
    59      
     75 
    6076    } 
    6177    void LisaaElamaPalkki() 
    6278    { 
    6379        elamat = new DoubleMeter(10, 0, 10); 
     80        elamat.LowerLimit += delegate { ClearAll(); AloitaKentta(nykyinenKentta); }; 
    6481 
    6582        ProgressBar ElamaPalkki = new ProgressBar(200, 35); 
     
    7087        Add(ElamaPalkki); 
    7188    } 
    72     void LuoKentta() 
    73     { 
    74          
    75         TileMap kentta = TileMap.FromLevelAsset("kentta1"); 
     89    void LuoKentta(string kentanNimi) 
     90    { 
     91 
     92        TileMap kentta = TileMap.FromLevelAsset(kentanNimi); 
    7693        kentta.SetTileMethod('#', LisaaTaso); 
    7794        kentta.SetTileMethod('*', LisaaTahti); 
    7895        kentta.SetTileMethod('N', LisaaPelaaja); 
     96        kentta.SetTileMethod('V', LisaaVihu); 
    7997        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    8098        Level.CreateBorders(); 
    81         Level.Background.Image = LoadImage("Tausta2"); 
     99        Level.Background.Image = LoadImage("Tausta"); 
    82100        Level.Background.FitToLevel(); 
    83101    } 
     102     
     103        void LisaaVihu(Vector paikka, double leveys, double korkeus) 
     104        { 
     105 
     106        Vihu vihu = new Vihu(leveys * 1.5, korkeus * 1.5, 5); 
     107        vihu.Position = paikka; 
     108        //vihu.Color = Color.Red; 
     109        vihu.Image = VihunKuva; 
     110        vihu.MirrorImage(); 
     111        vihu.Tag = "Vihu"; 
     112        Add(vihu); 
     113 
     114        PlatformWandererBrain Aivot = new PlatformWandererBrain(); 
     115        Aivot.Speed = nopeus - 50; 
     116        vihu.Brain = Aivot; 
     117 
     118        GameObject palkinPaikka = new GameObject(50, 50); 
     119        palkinPaikka.Position = new Vector(0, 50); 
     120        palkinPaikka.IsVisible = false; 
     121        //Add(palkinPaikka); 
     122        vihu.Add(palkinPaikka); 
     123 
     124        ProgressBar vihunElamat = new ProgressBar(70, 30); 
     125        vihunElamat.IsVisible = true; 
     126        vihunElamat.BindTo(vihu.Elamat); 
     127        palkinPaikka.Add(vihunElamat); 
     128         
     129         
     130    } 
     131        void LisaaLaskuri() 
     132        { 
     133            esLaskuri = new IntMeter(0, 0, 6); 
     134            esLaskuri.UpperLimit += SeuraavaKentta; 
     135 
     136            Label pisteNaytto = new Label(); 
     137            pisteNaytto.Left = Screen.Left + 50; 
     138            pisteNaytto.Top = Screen.Top - 50; 
     139            pisteNaytto.TextColor = Color.White; 
     140            pisteNaytto.Color = Color.Black; 
     141 
     142            pisteNaytto.BindTo(esLaskuri); 
     143            Add(pisteNaytto); 
     144        } 
    84145 
    85146    void LisaaTaso(Vector paikka, double leveys, double korkeus) 
     
    109170        pelaaja1.AnimIdle = new Animation(seisomisanimaatio); 
    110171        AddCollisionHandler(pelaaja1, "es", TormaaTahteen); 
    111          
     172        AddCollisionHandler(pelaaja1, "Vihu", TormaaVihuun); 
    112173 
    113174        //pelaaja1 on PlatformCharacter-tyyppinen 
     
    124185    } 
    125186 
     187    void TormaaVihuun(PhysicsObject pelaaja, PhysicsObject vihu) 
     188    { 
     189        elamat.Value -= 3; 
     190    } 
     191 
    126192 
    127193    void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 
    128194    { 
    129195        ammus.Destroy(); 
     196 
     197        if (kohde is Vihu) 
     198        { 
     199            ((Vihu)kohde).Elamat.Value -= 0.2; 
     200        } 
    130201    } 
    131202 
     
    144215            //ammus.MaximumLifetime = TimeSpan.FromSeconds(5.0) 
    145216        } 
    146          
     217 
     218    } 
     219 
     220    void AloitaPeli() 
     221    { 
    147222    } 
    148223 
     
    158233        Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 
    159234        Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
    160  
     235        Keyboard.Listen(Key.R, ButtonState.Pressed, AloitaPeli, "Aloittaa pelin uudelleen"); 
    161236        ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 
    162237 
     
    181256    { 
    182257        MessageDisplay.Add("Keräsit es energia juoman!"); 
     258        esLaskuri.AddValue(1); 
    183259        tahti.Destroy(); 
    184260    } 
    185261 
    186  
    187  
    188  
    189  
    190  
    191  
     262     
    192263} 
     264 
     265public class Vihu : PlatformCharacter 
     266{ 
     267    DoubleMeter elamat; 
     268    public DoubleMeter Elamat { get{  return elamat;  }} 
     269    public Vihu(double leveys, double korkeus, int elamia) 
     270        : base(leveys, korkeus) 
     271    { 
     272        elamat = new DoubleMeter(elamia, 0, elamia); 
     273        elamat.LowerLimit += delegate { this.Destroy(); }; 
     274    } 
     275 
     276 
     277 
     278 
     279} 
  • 2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAMEContent/kentta1.txt

    r4374 r4414  
    1   N          ########################################### 
    2              #                                         # 
    3 #######      #                                         # 
    4 #            #   ###                                   # 
    5 #            #       ##########################        # 
    6 #       #######              #                         # 
    7 ####   #*                    #                         # 
    8 #      #       #             #         ##              # 
    9 #      #   #####             #         ##              #    
    10 # *                  #       #   ####################### 
    11 #               #####        #                         # 
    12 #####                        #####################  #### 
    13 *    ###      ####           #*                  #  # # 
    14 #    ####  ###               ##                 ##  ## # 
    15         #                    # ##                      # 
    16         #                    #     ########            # 
    17    #####  ########           #                         # 
    18                              #  ##   #         
    19                              #       #                 # 
     1  N          ################################################################################################# 
     2             #                                         #                                                     # 
     3#######      #                                         #     #################   #               V #         # 
     4#            #   ###     #           V    #            #                     ############################   ## 
     5#            #       ##########################        ##################     #*                           ### 
     6#       #######              #                         #                      ###          ###      ###      # 
     7####   #*             ###    #                         #   #            V     #   ###                  #     # 
     8#      #       #             #         ##              #   ####################        ###    ####       ### # 
     9#      #   #####             #         ##         V    #                    * #                              # 
     10# *                  #       #   ##############################################   # V      #          #####  # 
     11#               #####        #                         #       #              #   ##########                 # 
     12#####                   ##########################  ####       #       V      #                 ####         # 
     13#*   ###      ####           #*                  #  #  #      ##    #####     #                            V # 
     14##   ####  ###      #        ##                 ##  ## #     ##    ##   #     #                     ######## # 
     15#       #           #   ##   # ##       V              #   ###    ##    #     #       V    #                 # 
     16#       #     V    ##        #     ########            #  ##    ###     #     ##############     ############# 
     17#  ####################     ##                         ####    ##       #                        # 
     18#                            #  ##   #                        ##        #     #   V       #      # 
     19#           V   #        V   #       #         V       ########         ########################## 
    2020######################################################## 
  • 2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAMEContent/kill_everypody_GAMEContent.contentproj

    r4374 r4414  
    103103  </ItemGroup> 
    104104  <ItemGroup> 
    105     <Compile Include="Tausta1.jpg"> 
    106       <Name>Tausta1</Name> 
     105    <Compile Include="Tausta.jpg"> 
     106      <Name>Tausta</Name> 
    107107      <Importer>TextureImporter</Importer> 
    108108      <Processor>TextureProcessor</Processor> 
     
    110110  </ItemGroup> 
    111111  <ItemGroup> 
    112     <Compile Include="Tausta2.jpg"> 
    113       <Name>Tausta2</Name> 
     112    <Compile Include="Vihu.png"> 
     113      <Name>Vihu</Name> 
    114114      <Importer>TextureImporter</Importer> 
    115115      <Processor>TextureProcessor</Processor> 
     116    </Compile> 
     117  </ItemGroup> 
     118  <ItemGroup> 
     119    <Compile Include="kentta2.txt"> 
     120      <Name>kentta2</Name> 
     121      <Importer>TextFileImporter</Importer> 
     122      <Processor>TextFileContentProcessor</Processor> 
    116123    </Compile> 
    117124  </ItemGroup> 
Note: See TracChangeset for help on using the changeset viewer.