Changeset 5138


Ignore:
Timestamp:
2014-06-27 10:52:16 (9 years ago)
Author:
otoskinn
Message:
 
Location:
2014/26/OttoK
Files:
3 added
15 edited

Legend:

Unmodified
Added
Removed
  • 2014/26/OttoK/Jump/Jump/Jump/Jump.cs

    r5118 r5138  
    1515    public IntMeter KranaattiLaskuri { get { return kranaattiLaskuri; } } 
    1616 
     17    private IntMeter nopeus = new IntMeter(200); 
     18    public IntMeter Nopeus { get { return nopeus; } } 
     19 
     20    public bool onkoautossa = false; 
     21 
    1722    public Norsu(double leveys, double korkeus) 
    1823        : base(leveys, korkeus) 
     
    2126        Weapon.Ammo.Value = 10000; 
    2227        Weapon.InfiniteAmmo = true; 
     28        Tag = "norsu"; 
    2329    } 
    2430} 
     
    3945    Image pelaajanKuva = LoadImage("norsu"); 
    4046    Image tahtiKuva = LoadImage("tahti"); 
     47    Image autonKuva = LoadImage("auto"); 
    4148 
    4249    SoundEffect maaliAani = LoadSoundEffect("maali"); 
     
    5057        LuoPistelaskuri(pelaaja1); 
    5158        LuoPistelaskuri(pelaaja2); 
     59 
    5260 
    5361        Camera.Follow(pelaaja1, pelaaja2); 
     
    6977        kentta.SetTileMethod('N', LisaaPelaaja); 
    7078        kentta.SetTileMethod('C', LisaaPelaaja2); 
     79        kentta.SetTileMethod('F', LuoAuto); 
    7180        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    7281        Level.CreateBorders(); 
     
    121130        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    122131 
    123         Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 
    124         Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 
     132        Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -1.0); 
     133        Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, 1.0); 
    125134        Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
    126135        Keyboard.Listen(Key.NumPad2, ButtonState.Pressed , HeitaKranaatti, "Heitä Kranaatti", pelaaja1); 
    127136        Keyboard.Listen(Key.NumPad1, ButtonState.Down, AmmuAseella, "Ammu", pelaaja1); 
    128  
    129         Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja2, -nopeus); 
    130         Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja2, nopeus); 
     137        Keyboard.Listen(Key.NumPad3, ButtonState.Pressed, OtaAuto, "Nouse auton kyytiin", pelaaja1); 
     138 
     139        Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja2, -1.0); 
     140        Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja2, 1.0); 
    131141        Keyboard.Listen(Key.W,ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja2, hyppyNopeus); 
    132142        Keyboard.Listen(Key.F, ButtonState.Pressed, HeitaKranaatti, "Heitä Kranaatti", pelaaja2); 
    133143        Keyboard.Listen(Key.G, ButtonState.Down, AmmuAseella, "Ammu", pelaaja2); 
     144        Keyboard.Listen(Key.H, ButtonState.Pressed, OtaAuto, "Nouse auton kyytiin", pelaaja2); 
    134145 
    135146        ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 
     
    143154    } 
    144155 
    145  
     156    void UlosAuto(Norsu pelaaja) 
     157    { 
     158        pelaaja.Image = pelaajanKuva; 
     159        pelaaja.Width = RUUDUN_KOKO; 
     160        pelaaja.Height = RUUDUN_KOKO; 
     161        pelaaja.Mass = 4.0; 
     162        pelaaja.Nopeus.Value = 200; 
     163        pelaaja.onkoautossa = false; 
     164    } 
     165 
     166    void OtaAuto(Norsu pelaaja) 
     167    { 
     168        if (pelaaja.onkoautossa) 
     169        { 
     170            UlosAuto(pelaaja); 
     171            LuoAuto(pelaaja.Position, RUUDUN_KOKO, RUUDUN_KOKO); 
     172        } 
     173        else 
     174        { 
     175            foreach (PhysicsObject auto in GetObjectsWithTag("Auto")) 
     176            { 
     177                if (Vector.Distance(auto.Position, pelaaja.Position) < 100) 
     178                { 
     179                    pelaaja.Image = auto.Image; 
     180                    pelaaja.Width = auto.Width; 
     181                    pelaaja.Height = auto.Height; 
     182                    pelaaja.Position = auto.Position; 
     183                    //pelaaja.Mass = auto.Mass; 
     184                    pelaaja.Nopeus.Value = 300; 
     185                    pelaaja.onkoautossa = true; 
     186                    auto.Destroy(); 
     187                    return; 
     188                } 
     189            } 
     190        } 
     191    } 
    146192 
    147193    void HeitaKranaatti(Norsu pelaaja) 
     
    153199            pelaaja.KranaattiLaskuri.Value--; 
    154200           // kranu.Mass = 1000.0; 
    155         } 
     201            kranu.Explosion.AddShockwaveHandler("Auto", KranaattiOsui); 
     202            kranu.Explosion.AddShockwaveHandler("norsu", KranaattiOsui); 
     203 
     204        } 
     205    } 
     206 
     207    void KranaattiOsui(IPhysicsObject rajahdyksenKohde, Vector v) 
     208    { 
     209        if (rajahdyksenKohde.Tag == "norsu") 
     210        { 
     211            UlosAuto(rajahdyksenKohde as Norsu); 
     212        } 
     213        else 
     214        { 
     215            rajahdyksenKohde.Destroy(); 
     216        } 
     217 
     218        Explosion rajahdys = new Explosion(500); 
     219        rajahdys.Position = rajahdyksenKohde.Position; 
     220        Add(rajahdys); 
    156221    } 
    157222 
     
    163228     
    164229        { 
    165             ammus.Mass = 99999999999; 
     230            ammus.Mass = 10; 
    166231            //ammus.Size *=  
    167232            //ammus.Image = ... 
     
    177242 
    178243 
    179     void Liikuta(PlatformCharacter hahmo, double nopeus) 
    180     { 
    181         hahmo.Walk(nopeus); 
    182     } 
    183  
    184     void Hyppaa(PlatformCharacter hahmo, double nopeus) 
    185     { 
    186         hahmo.Jump(nopeus); 
     244    void Liikuta(Norsu hahmo, double suunta) 
     245    { 
     246        hahmo.Walk(hahmo.Nopeus.Value * suunta); 
     247    } 
     248 
     249    void Hyppaa(Norsu hahmo, double nopeus) 
     250    { 
     251        if (!hahmo.onkoautossa) 
     252        { 
     253            hahmo.Jump(nopeus); 
     254        } 
    187255    } 
    188256 
     
    221289        ajastin.Timeout += delegate 
    222290        { 
    223             pisteNaytto.Position = Camera.WorldToScreen(pelaaja.Position + new Vector(0, 30)); 
    224             kranaattiNaytto.Position = Camera.WorldToScreen(pelaaja.Position + new Vector(0, 50)); 
     291            pisteNaytto.Position = Camera.WorldToScreen(pelaaja.Position) + new Vector(0, 40); 
     292            kranaattiNaytto.Position = Camera.WorldToScreen(pelaaja.Position) + new Vector(0, 65); 
    225293        }; 
    226294        ajastin.Start();  
     
    228296    } 
    229297 
     298    void LuoAuto(Vector paikka, double leveys, double korkeus) 
     299    { 
     300        PhysicsObject Auto = new PhysicsObject(leveys*4, korkeus*2); 
     301        //PhysicsObject Auto = PhysicsObject.CreateStaticObject(leveys * 4, korkeus * 2); 
     302        //Auto.Shape = Shape.FromImage(autonKuva); 
     303        Auto.Position = paikka; 
     304        Auto.Color = Color.Green; 
     305        Auto.Tag = "Auto"; 
     306        Auto.Mass = 1000; 
     307        Auto.LinearDamping = 0.7; 
     308        Auto.AngularDamping = 0.5; 
     309        Auto.Image = autonKuva; 
     310        Add(Auto); 
     311    } 
     312 
    230313 
    231314} 
  • 2014/26/OttoK/Jump/Jump/Jump/Jump.csproj.Debug.cachefile

    r5107 r5138  
    33Content\tahti.xnb 
    44Content\kentta1.xnb 
     5Content\auto.xnb 
  • 2014/26/OttoK/Jump/Jump/Jump/obj/x86/Debug/ContentPipeline-{63B38ACA-3B70-45B9-9BE0-E245FDD44385}.xml

    r5118 r5138  
    3636      <Options>None</Options> 
    3737      <Output>C:\MyTemp\OttoK\Jump\Jump\Jump\bin\x86\Debug\Content\kentta1.xnb</Output> 
    38       <Time>2014-06-26T13:37:45.3701107+03:00</Time> 
     38      <Time>2014-06-27T10:43:26.7849264+03:00</Time> 
     39    </Item> 
     40    <Item> 
     41      <Source>auto.png</Source> 
     42      <Name>auto</Name> 
     43      <Importer>TextureImporter</Importer> 
     44      <Processor>TextureProcessor</Processor> 
     45      <Options>None</Options> 
     46      <Output>C:\MyTemp\OttoK\Jump\Jump\Jump\bin\x86\Debug\Content\auto.xnb</Output> 
     47      <Time>2014-06-27T09:48:36.0008809+03:00</Time> 
    3948    </Item> 
    4049    <BuildSuccessful>true</BuildSuccessful> 
  • 2014/26/OttoK/Jump/Jump/Jump/obj/x86/Debug/Jump.csproj.FileListAbsolute.txt

    r5107 r5138  
    1111C:\MyTemp\OttoK\Jump\Jump\Jump\obj\x86\Debug\Jump.exe 
    1212C:\MyTemp\OttoK\Jump\Jump\Jump\obj\x86\Debug\Jump.pdb 
     13C:\MyTemp\OttoK\Jump\Jump\Jump\bin\x86\Debug\Content\auto.xnb 
  • 2014/26/OttoK/Jump/Jump/Jump/obj/x86/Debug/cachefile-{63B38ACA-3B70-45B9-9BE0-E245FDD44385}-targetpath.txt

    r5107 r5138  
    33Content\tahti.xnb 
    44Content\kentta1.xnb 
     5Content\auto.xnb 
  • 2014/26/OttoK/Jump/Jump/JumpContent/JumpContent.contentproj

    r5107 r5138  
    6767    </Compile> 
    6868  </ItemGroup> 
     69  <ItemGroup> 
     70    <Compile Include="auto.png"> 
     71      <Name>auto</Name> 
     72      <Importer>TextureImporter</Importer> 
     73      <Processor>TextureProcessor</Processor> 
     74    </Compile> 
     75  </ItemGroup> 
    6976  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    7077  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2014/26/OttoK/Jump/Jump/JumpContent/kentta1.txt

    r5118 r5138  
    1111 
    1212 
    13    
    14                                                                         * 
     13                                                                F 
     14                                                                          * 
    1515                                                         ####################### 
    1616                            *      *    *    *   *   * # 
     
    3030  #          *               #  #  #  ########                                                *   ## 
    3131  #    ####################                     #                                        *   ### 
    32   #                                                                                    ## 
     32  #                                           F                                        ## 
    3333  ####                                                                              * 
    3434                                          ##################3                       # 
    35   ########    ###                                    #                *        ## 
    36              * #                     ##                ###################### 
    37   ####    #####                                      ##                        # 
    38        C N      *                                     # 
     35  ########    ###                                                     *        ## 
     36             * #                     ##                  ##################### 
     37  ####    #####             F                           #                     # 
     38       C N      *                                    
    3939###################################################### 
    40  ****************************************************# 
    41  ****************************************************# 
    42  ****************************************************# 
    43  ##################################################### 
     40 *************************************************** ## 
     41 ****************************************************#      F                         F                     F                            F                                                                                      
     42 ****************************************************#        
     43 ################################################################################################################################################### 
Note: See TracChangeset for help on using the changeset viewer.