Changeset 3801


Ignore:
Timestamp:
2012-07-27 12:14:13 (11 years ago)
Author:
eeolmart
Message:

Talletus.

Location:
2012/30/EetuM/Urban Assassin/Urban Assassin
Files:
10 added
4 edited

Legend:

Unmodified
Added
Removed
  • 2012/30/EetuM/Urban Assassin/Urban Assassin/Urban Assassin/Urban_Assassin.cs

    r3732 r3801  
    99public class Urban_Assassin : PhysicsGame 
    1010{ 
    11     const double nopeus = 200; 
    12     const double hyppyNopeus = 1000; 
     11    const double nopeus = 300; 
     12    const double hyppyNopeus = 500; 
    1313    const int RUUDUN_KOKO = 40; 
    1414 
    1515    PlatformCharacter pelaaja1; 
     16    Image taustaKuva = LoadImage("untitled2"); 
     17    int kenttaNro = 1; 
    1618 
     19    DoubleMeter alaspainLaskuri; 
     20    Timer aikaLaskuri; 
    1721    Image pelaajanKuva = LoadImage("norsu"); 
    1822    Image tahtiKuva = LoadImage("tahti"); 
    19  
     23    Image ase =LoadImage ("m40a3"); 
    2024    SoundEffect maaliAani = LoadSoundEffect("maali"); 
    21  
     25    Image ammuskuva = LoadImage("untitled"); 
    2226    public override void Begin() 
    2327    { 
     28        LuoKentta(); 
     29    } 
     30 
     31    void LuoKentta() 
     32    { 
     33        ClearAll(); 
     34 
     35 
     36        ColorTileMap kentta = ColorTileMap.FromLevelAsset("kenttä"); 
     37        kentta.SetTileMethod(Color.Black, LisaaTaso); 
     38       // kentta.SetTileMethod('*', LisaaTahti); 
     39        kentta.SetTileMethod(Color.Red, LisaaPelaaja); 
     40        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
     41        Level.CreateLeftBorder(); 
     42        Level.CreateTopBorder(); 
     43        Level.CreateRightBorder(); 
     44       PhysicsObject alareuna= Level.CreateBottomBorder(); 
     45       alareuna.IgnoresCollisionResponse = true; 
     46       AddCollisionHandler(pelaaja1, alareuna, pelaajatörmäsialareunaan); 
     47 
     48        Level.Background.CreateGradient(Color.White, Color.SkyBlue); 
     49        LuoAikaLaskuri(); 
     50        Level.Background.Image = taustaKuva; 
     51 
     52 
    2453        Gravity = new Vector(0, -1000); 
    2554 
    26         LuoKentta(); 
     55         
    2756        LisaaNappaimet(); 
    2857 
     
    3261    } 
    3362 
    34     void LuoKentta() 
    35     { 
    36         TileMap kentta = TileMap.FromLevelAsset("kentta1"); 
    37         kentta.SetTileMethod('#', LisaaTaso); 
    38         kentta.SetTileMethod('*', LisaaTahti); 
    39         kentta.SetTileMethod('N', LisaaPelaaja); 
    40         kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    41         Level.CreateBorders(); 
    42         Level.Background.CreateGradient(Color.White, Color.SkyBlue); 
    43     } 
    44  
    4563    void LisaaTaso(Vector paikka, double leveys, double korkeus) 
    4664    { 
    4765        PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    4866        taso.Position = paikka; 
    49         taso.Color = Color.Brown; 
     67        taso.Color = Color.Gray; 
    5068        Add(taso); 
    5169    } 
     
    6987        AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 
    7088        Add(pelaaja1); 
     89        pelaaja1.Weapon = new AssaultRifle(30, 10); 
     90        pelaaja1.Weapon.Image = ase; 
     91        pelaaja1.Weapon.FireRate = 2.0; 
     92        pelaaja1.Weapon.AmmoIgnoresGravity = false; 
     93        pelaaja1.Weapon.Power.DefaultValue = 1000;  
     94 
    7195    } 
    7296 
     
    80104        Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 
    81105        Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
    82  
     106        Keyboard.Listen(Key.Space, ButtonState.Down, AmmuAseella, "Ammu", pelaaja1); 
    83107        ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 
    84108 
     
    106130        tahti.Destroy(); 
    107131    } 
     132    void AmmuAseella(PlatformCharacter pelaaja) 
     133    { 
     134        PhysicsObject ammus = pelaaja.Weapon.Shoot(); 
     135 
     136        if (ammus != null) 
     137        { 
     138            //ammus.Size *= 3; 
     139            ammus.Image = ammuskuva; 
     140            //ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 
     141        } 
     142    } 
     143    void LuoAikaLaskuri() 
     144    { 
     145        alaspainLaskuri = new DoubleMeter(25); 
     146 
     147        aikaLaskuri = new Timer(); 
     148        aikaLaskuri.Interval = 0.1; 
     149        aikaLaskuri.Timeout += LaskeAlaspain; 
     150        aikaLaskuri.Start(); 
     151 
     152        Label aikaNaytto = new Label(); 
     153        aikaNaytto.TextColor = Color.White; 
     154        aikaNaytto.DecimalPlaces = 1; 
     155        aikaNaytto.BindTo(alaspainLaskuri); 
     156        Add(aikaNaytto); 
     157    } 
     158 
     159    void LaskeAlaspain() 
     160    { 
     161        alaspainLaskuri.Value -= 0.1; 
     162 
     163        if (alaspainLaskuri.Value <= 0) 
     164        { 
     165            MessageDisplay.Add("Aika loppui..."); 
     166            aikaLaskuri.Stop(); 
     167 
     168            // täydennä mitä tapahtuu, kun aika loppuu 
     169        } 
     170    } 
     171    void pelaajatörmäsialareunaan(PhysicsObject pelaaja1, PhysicsObject alareuna) 
     172    { 
     173        alareuna.Destroy(); 
     174        Timer.SingleShot(2.0, LuoKentta ); 
     175    } 
     176    void TormasiMaaliin(PhysicsObject pelaaja, PhysicsObject maali) 
     177    { 
     178        //Kasvatetaan kenttänumeroa yhdellä ja siirrytään seuraavaan kenttään: 
     179        kenttaNro++; 
     180        SeuraavaKentta(); 
     181    } 
     182 
    108183} 
  • 2012/30/EetuM/Urban Assassin/Urban Assassin/Urban AssassinContent/Urban AssassinContent.contentproj

    r3732 r3801  
    5050      <Processor>SoundEffectProcessor</Processor> 
    5151    </Compile> 
    52     <Compile Include="norsu.png"> 
    53       <Name>norsu</Name> 
     52    <None Include="Jericho"> 
     53      <Name>Jericho</Name> 
    5454      <Importer>TextureImporter</Importer> 
    5555      <Processor>TextureProcessor</Processor> 
    56     </Compile> 
     56    </None> 
    5757    <Compile Include="tahti.png"> 
    5858      <Name>tahti</Name> 
     
    6666    </Compile> 
    6767  </ItemGroup> 
     68  <ItemGroup> 
     69    <Compile Include="norsu.png"> 
     70      <Name>norsu</Name> 
     71      <Importer>TextureImporter</Importer> 
     72      <Processor>TextureProcessor</Processor> 
     73    </Compile> 
     74  </ItemGroup> 
     75  <ItemGroup> 
     76    <Compile Include="G36c.png"> 
     77      <Name>G36c</Name> 
     78      <Importer>TextureImporter</Importer> 
     79      <Processor>TextureProcessor</Processor> 
     80    </Compile> 
     81  </ItemGroup> 
     82  <ItemGroup> 
     83    <Compile Include="m40a3.png"> 
     84      <Name>m40a3</Name> 
     85      <Importer>TextureImporter</Importer> 
     86      <Processor>TextureProcessor</Processor> 
     87    </Compile> 
     88  </ItemGroup> 
     89  <ItemGroup> 
     90    <Compile Include="untitled.png"> 
     91      <Name>untitled</Name> 
     92      <Importer>TextureImporter</Importer> 
     93      <Processor>TextureProcessor</Processor> 
     94    </Compile> 
     95  </ItemGroup> 
     96  <ItemGroup> 
     97    <Compile Include="400px-FN_P90_Triple_Rail_%28TR%29.png"> 
     98      <Name>400px-FN_P90_Triple_Rail_%28TR%29</Name> 
     99      <Importer>TextureImporter</Importer> 
     100      <Processor>TextureProcessor</Processor> 
     101    </Compile> 
     102  </ItemGroup> 
     103  <ItemGroup> 
     104    <Compile Include="400px-Rpg-7-1-.png"> 
     105      <Name>400px-Rpg-7-1-</Name> 
     106      <Importer>TextureImporter</Importer> 
     107      <Processor>TextureProcessor</Processor> 
     108    </Compile> 
     109  </ItemGroup> 
     110  <ItemGroup> 
     111    <Compile Include="imagesCAEA00R52.jpg"> 
     112      <Name>imagesCAEA00R52</Name> 
     113      <Importer>TextureImporter</Importer> 
     114      <Processor>TextureProcessor</Processor> 
     115    </Compile> 
     116  </ItemGroup> 
     117  <ItemGroup> 
     118    <Compile Include="kenttä.png"> 
     119      <Name>kenttä</Name> 
     120      <Importer>TextureImporter</Importer> 
     121      <Processor>TextureProcessor</Processor> 
     122    </Compile> 
     123  </ItemGroup> 
     124  <ItemGroup> 
     125    <Compile Include="untitled2.png"> 
     126      <Name>untitled2</Name> 
     127      <Importer>TextureImporter</Importer> 
     128      <Processor>TextureProcessor</Processor> 
     129    </Compile> 
     130  </ItemGroup> 
     131  <ItemGroup> 
     132    <Compile Include="kenttä2.png"> 
     133      <Name>kenttä2</Name> 
     134      <Importer>TextureImporter</Importer> 
     135      <Processor>TextureProcessor</Processor> 
     136    </Compile> 
     137  </ItemGroup> 
    68138  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    69139  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2012/30/EetuM/Urban Assassin/Urban Assassin/Urban AssassinContent/kentta1.txt

    r3732 r3801  
    1212                            ###########          
    1313            #     ##        ###########          
    14 N     #     #               ########### 
     14N     #     #              ############ 
    1515################################################################################################################################### 
Note: See TracChangeset for help on using the changeset viewer.