Changeset 6780 for 2015/27


Ignore:
Timestamp:
2015-07-03 11:29:58 (8 years ago)
Author:
miausilj
Message:

Kenttiä

Location:
2015/27/MiroS/Raiskintapeli
Files:
15 added
11 edited

Legend:

Unmodified
Added
Removed
  • 2015/27/MiroS/Raiskintapeli/Raiskintapeli/Raiskintapeli/TankkiPeli.cs

    r6757 r6780  
    1111    Image tankkikuva = LoadImage("Tankki"); 
    1212    Image Vihulainen = LoadImage("Vihulainen"); 
    13     Image rajahdys = LoadImage("Rajahdys"); 
    14     Image pommi1 = LoadImage("Pommi"); 
    1513 
    1614    PhysicsObject tankki; 
    1715    IntMeter healthit; 
     16    public IntMeter tuhotutTankit; 
     17    int vaikeusaste = 1; 
     18    int tankkienLkm = 4; 
     19    String kentanNimi = "kentta1"; 
    1820 
    1921    public override void Begin() 
     
    2123     
    2224        //IsFullScreen = true; 
    23  
    24         
     25        ClearAll();      
    2526         
    2627        Level.Width = Screen.Width; 
     
    2829 
    2930        //Level.CreateBorders(); 
    30         LuoKentta();   
     31        LuoKentta(kentanNimi);   
    3132        LisaaOhjaimet(); 
    3233 
    3334        Camera.Follow(tankki); 
    34  
    35         LuoMappi(1); 
     35        LuoMappi(vaikeusaste); 
    3636    } 
    3737    void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 
     
    4242        tankki.LinearDamping = 0.1; 
    4343        tankki.AngularDamping = 0.1; 
    44         healthit = new IntMeter(400, 0, 400); 
     44        tankki.Tag = "tankki"; 
     45        healthit = new IntMeter(500, 0, 500); 
    4546        healthit.LowerLimit += delegate {  
    4647            tankki.Destroy(); 
     48            Explosion raj = new Explosion(100.0); 
     49            raj.Position = tankki.Position; 
     50            Add(raj); 
    4751            ClearControls(); 
    4852            Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     
    5054        Add(tankki); 
    5155    } 
    52        
     56 
    5357    void LuoVihulainen() 
    5458    { 
    55         PhysicsObject vihu = new PhysicsObject(Vihulainen); 
     59        Vihu vihu = new Vihu(Vihulainen.Width,Vihulainen.Height); 
    5660        vihu.Size = vihu.Size * 0.1; 
    5761        vihu.Position = new Vector(RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top)); 
    5862        vihu.CanRotate = false; 
    59         Add(vihu); 
     63        vihu.Image = Vihulainen; 
     64        vihu.Tag = "vihu"; 
     65        Add(vihu,1); 
    6066 
    6167        RandomMoverBrain aivot = new RandomMoverBrain(); 
    6268        aivot.WanderRadius = 200.0; 
    63         aivot.ChangeMovementSeconds = 40.0; 
     69        aivot.ChangeMovementSeconds = 10.0; 
    6470        vihu.Brain = aivot; 
     71      
    6572 
    6673        AssaultRifle vihunAse = new AssaultRifle(20.0, 20.0); 
     
    6875        vihunAse.IsVisible = false; 
    6976        vihu.Add(vihunAse); 
    70  
     77         
    7178        Timer vihunAjastin = new Timer(); 
    7279        vihunAjastin.Interval = 1.0; 
    7380        vihunAjastin.Timeout += delegate { VihuAmpuu(vihunAse); }; 
    7481        vihunAjastin.Start(); 
    75  
    76          healthit = new IntMeter(40, 0, 40); 
    77         healthit.LowerLimit += delegate {  
    78             vihu.Destroy(); 
    79             ClearControls(); 
    80  
    81     } 
     82        vihu.Ajastin = vihunAjastin; 
     83 
     84        
     85 
     86 
     87 
     88    } 
     89   public void LuoRajahdys(Vector paikka) 
     90    { 
     91        Explosion rajahdys = new Explosion(100); 
     92        rajahdys.Position = paikka; 
     93        Add(rajahdys); 
     94 
     95 
     96    } 
     97 
    8298    void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 
    8399    { 
     
    87103            healthit.Value -= 50; 
    88104        } 
     105        else if (kohde.Tag.ToString() == "vihu") 
     106        { 
     107            ((Vihu)kohde).ElamaLaskuri.Value--; 
     108             
     109        } 
    89110         
    90111    } 
     
    92113    void JättääPommin(PhysicsObject tankki) 
    93114    { 
    94         PhysicsObject pommi = new PhysicsObject(30.0, 30.0); 
     115        PhysicsObject pommi = new PhysicsObject(10.0, 10.0); 
    95116        pommi.Position = tankki.Position; 
    96117        Add(pommi); 
    97118        pommi.Color = Color.Blue; 
    98119        pommi.CanRotate = false; 
    99         pommi.Image = pommi1; 
    100120        Timer.SingleShot(2.0, delegate 
    101         { 
    102             pommi.Destroy(); 
     121        {          
    103122            Explosion raj = new Explosion(300.0); 
    104123            raj.Speed = 900.0; 
     124            raj.Tag = "pommi"; 
    105125            raj.Position = pommi.Position; 
    106             raj.Image = rajahdys; 
     126           
     127            raj.AddShockwaveHandler("tankki", delegate(IPhysicsObject olio, Vector shokki) 
     128            { 
     129                healthit.Value -= 1; 
     130            }); 
     131 
     132            raj.AddShockwaveHandler("vihu", delegate(IPhysicsObject olio, Vector shokki) 
     133            { 
     134                ((Vihu)olio).ElamaLaskuri.Value-=3; 
     135            }); 
     136            pommi.Destroy(); 
    107137            Add(raj); 
    108138        }); 
     
    121151             
    122152        }); 
    123              
    124              
     153 
     154        AddCollisionHandler(ammus, AmmusOsui);  
    125155 
    126156    } 
    127157    void LuoMappi(int vaikeusaste) 
    128158    { 
    129         for (int i = 0; i < 3*vaikeusaste; i++) 
     159        for (int i = 0; i < tankkienLkm * vaikeusaste; i++) 
    130160        { 
    131161            LuoVihulainen(); 
     162        } 
     163 
     164        this.tuhotutTankit = new IntMeter(0, 0, vaikeusaste * 1); 
     165 
     166        //this.tuhotutTankit.UpperLimit += delegate { 
     167        //    SeuraavaKentta(); 
     168        //    vaikeusaste++; 
     169        //    Begin(); 
     170        //}; 
     171 
     172        tuhotutTankit.AddTrigger(vaikeusaste * (tankkienLkm - 1), TriggerDirection.Up, delegate (int arvo) { 
     173            SeuraavaKentta(); 
     174            vaikeusaste++; 
     175            Begin(); 
     176        }); 
     177    } 
     178    void SeuraavaKentta() 
     179    { 
     180        if (kentanNimi == "kentta1") 
     181        { 
     182            kentanNimi = "kentta2"; 
     183        } 
     184        else if (kentanNimi == "kentta2") 
     185        { 
     186            kentanNimi = "kentta3"; 
     187        } 
     188        else 
     189        { 
     190            Exit(); 
    132191        } 
    133192    } 
     
    163222 
    164223    } 
    165     void LuoKentta() 
    166     { 
    167         ColorTileMap kentta = ColorTileMap.FromLevelAsset("kentta1"); 
     224    void LuoKentta(String kentanNimi) 
     225    { 
     226        ColorTileMap kentta = ColorTileMap.FromLevelAsset(kentanNimi); 
    168227 
    169228        kentta.SetTileMethod(Color.Black, LuoSeina); 
     
    174233         
    175234         
    176         Level.Background.Color = Color.Black; 
     235        Level.Background.Color = Color.Orange; 
    177236 
    178237 
     
    182241        PhysicsObject seina = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    183242        seina.Position = paikka; 
     243        seina.Color = Color.Blue; 
    184244        Add(seina); 
    185245    } 
    186246} 
     247class Vihu : PhysicsObject 
     248{ 
     249    private IntMeter elamaLaskuri = new IntMeter(3, 0, 3); 
     250    public  IntMeter ElamaLaskuri { get { return elamaLaskuri; } } 
     251 
     252    public Timer Ajastin { get; set; } 
     253    public Vihu(double leveys, double korkeus) 
     254        : base(leveys, korkeus) 
     255    { 
     256        elamaLaskuri.LowerLimit += delegate {  
     257            this.Ajastin.Stop(); 
     258            ((TankkiPeli)Game.Instance).LuoRajahdys(this.Position); 
     259            this.Destroy(); 
     260            ((TankkiPeli)Game.Instance).tuhotutTankit.Value++; 
     261        }; 
     262 
     263    } 
     264} 
  • 2015/27/MiroS/Raiskintapeli/Raiskintapeli/Raiskintapeli/TankkiPeli.csproj.Debug.cachefile

    r6757 r6780  
    44Content\Pommi.xnb 
    55Content\kentta1.xnb 
     6Content\Kentta2.xnb 
  • 2015/27/MiroS/Raiskintapeli/Raiskintapeli/Raiskintapeli/obj/x86/Debug/ContentPipeline-{81739508-248F-43AA-A768-73E659A05863}.xml

    r6757 r6780  
    4646      <Output>C:\MyTemp\MiroS\Raiskintapeli\Raiskintapeli\Raiskintapeli\bin\x86\Debug\Content\kentta1.xnb</Output> 
    4747      <Time>2015-07-02T14:34:55.6913156+03:00</Time> 
     48    </Item> 
     49    <Item> 
     50      <Source>Kentta2.png</Source> 
     51      <Name>Kentta2</Name> 
     52      <Importer>TextureImporter</Importer> 
     53      <Processor>TextureProcessor</Processor> 
     54      <Options>None</Options> 
     55      <Output>C:\MyTemp\MiroS\Raiskintapeli\Raiskintapeli\Raiskintapeli\bin\x86\Debug\Content\Kentta2.xnb</Output> 
     56      <Time>2015-07-03T10:50:40.6513553+03:00</Time> 
    4857    </Item> 
    4958    <BuildSuccessful>true</BuildSuccessful> 
  • 2015/27/MiroS/Raiskintapeli/Raiskintapeli/Raiskintapeli/obj/x86/Debug/TankkiPeli.csproj.FileListAbsolute.txt

    r6757 r6780  
    1212C:\MyTemp\MiroS\Raiskintapeli\Raiskintapeli\Raiskintapeli\bin\x86\Debug\Content\Pommi.xnb 
    1313C:\MyTemp\MiroS\Raiskintapeli\Raiskintapeli\Raiskintapeli\bin\x86\Debug\Content\kentta1.xnb 
     14C:\MyTemp\MiroS\Raiskintapeli\Raiskintapeli\Raiskintapeli\bin\x86\Debug\Content\Kentta2.xnb 
  • 2015/27/MiroS/Raiskintapeli/Raiskintapeli/Raiskintapeli/obj/x86/Debug/cachefile-{81739508-248F-43AA-A768-73E659A05863}-targetpath.txt

    r6757 r6780  
    44Content\Pommi.xnb 
    55Content\kentta1.xnb 
     6Content\Kentta2.xnb 
  • 2015/27/MiroS/Raiskintapeli/Raiskintapeli/RaiskintapeliContent/TankkiPeliContent.contentproj

    r6757 r6780  
    8080    </Compile> 
    8181  </ItemGroup> 
     82  <ItemGroup> 
     83    <Compile Include="Kentta2.png"> 
     84      <Name>Kentta2</Name> 
     85      <Importer>TextureImporter</Importer> 
     86      <Processor>TextureProcessor</Processor> 
     87    </Compile> 
     88  </ItemGroup> 
    8289  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    8390  <!--  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.