Changeset 4976 for 2014/24


Ignore:
Timestamp:
2014-06-12 14:51:34 (9 years ago)
Author:
juonoljo
Message:

laatikot laatikoi laatikkoja

Location:
2014/24/JuhoJ/ShotgunJoe/ShotgunJoe
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • 2014/24/JuhoJ/ShotgunJoe/ShotgunJoe/ShotgunJoe/ShotgunJoe.cs

    r4972 r4976  
    99public class ShotgunJoe : PhysicsGame 
    1010{ 
    11     // TODO laatikot putoaa näkymättömien seinien läpi 
    12     // TODO tynnyrit ei saa räjäyttää lattiaa 
    13     // TODO  
     11     
     12    // TODO laatikot pitää pystyä tuhoamaan 
     13    // TODO panoslaskuri näkyviin 
     14    // TODO elämät täyteen kenttien välissä 
     15    // TODO voittamattomuus 
    1416    const double nopeus = 200; 
    1517    const double hyppyNopeus = 550; 
    1618    const int RUUDUN_KOKO = 40; 
    17      
    18      
     19 
     20    bool onKuolematon = false; 
     21 
     22 
    1923    PlatformCharacter pelaaja1; 
    2024    PlasmaCannon pelaajan1Ase; 
     
    3640    Image tynnyrikuva = LoadImage("tynnyri"); 
    3741    Image laatikkokuva = LoadImage("laatikko"); 
     42    SoundEffect haulikkoaani = LoadSoundEffect("haulikkoaani"); 
    3843    public override void Begin() 
    3944    { 
     45        SmoothTextures = false; 
    4046        Gravity = new Vector(0, -1000); 
    4147 
     
    4753         
    4854        Timer ajastin = new Timer(); 
    49         ajastin.Interval = 1.5; 
     55        ajastin.Interval = 2.0; 
    5056        ajastin.Timeout += RandomUusiLaatikko; 
    5157        ajastin.Start(); 
     
    5864        pelaaja1.Weapon.Image = asekuva; 
    5965        pelaaja1.Weapon.Ammo.Value = 100; 
    60         pelaaja1.Weapon.ProjectileCollision = AmmusOsui;  
     66        pelaaja1.Weapon.ProjectileCollision = AmmusOsui; 
     67         
    6168        pelaaja1.Weapon.FireRate = 1.0; 
    6269         
     
    6673    { 
    6774        TileMap kentta = TileMap.FromLevelAsset("kentta1"); 
    68         kentta.SetTileMethod('#', LisaaTaso); 
     75        kentta.SetTileMethod('#', LisaaMulta); 
    6976        kentta.SetTileMethod('*', LisaaTahti); 
    7077        kentta.SetTileMethod('J', LisaaPelaaja); 
     
    7279        kentta.SetTileMethod('R', LisaaRuoho); 
    7380        kentta.SetTileMethod('V', LisaaVihu); 
    74         kentta.SetTileMethod('N', LisaaNäkymätön); 
     81        kentta.SetTileMethod('N', LisaaNakymaton); 
    7582        kentta.SetTileMethod('T', LisaaTynnyri); 
    7683        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
     
    7986    } 
    8087 
    81     void LisaaTaso(Vector paikka, double leveys, double korkeus) 
     88    void LisaaMulta(Vector paikka, double leveys, double korkeus) 
     89    { 
     90        LisaaPalikka(paikka, leveys, korkeus, "maa", multakuva,0); 
     91    } 
     92    void LisaaRuoho(Vector paikka, Double leveys, Double korkeus) 
     93    { 
     94        LisaaPalikka(paikka, leveys, korkeus, "ruoho", ruohokuva,0); 
     95    } 
     96 
     97    void LisaaPalikka(Vector paikka, Double leveys, Double korkeus,string tagi,Image kuva, int ignoregroup) 
    8298    { 
    8399        PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    84100        taso.Position = paikka; 
    85         taso.Image = multakuva; 
     101        taso.Image = kuva; 
    86102        taso.IgnoresExplosions = true; 
     103        if (ignoregroup > 0) 
     104        { 
     105            taso.CollisionIgnoreGroup = ignoregroup; 
     106        } 
    87107        Add(taso); 
    88108    } 
     
    157177    } 
    158178 
    159     void LisaaRuoho(Vector paikka, Double leveys, Double korkeus) 
    160     { 
    161         PhysicsObject ruoho = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    162         ruoho.Tag = "ruoho"; 
    163         ruoho.Position = paikka; 
    164         ruoho.Image = ruohokuva; 
    165         ruoho.IgnoresExplosions = true; 
    166         Add(ruoho); 
    167  
    168     } 
     179     
    169180 
    170181    void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 
     
    201212        if (ammus != null) 
    202213        { 
     214            haulikkoaani.Play(); 
    203215            //ammus.Size *= 3; 
    204216            ammus.Image = panoskuva; 
     
    217229        Add(vihu); 
    218230        FollowerBrain seuraajanAivot = new FollowerBrain(pelaaja1); 
     231        vihu.CollisionIgnoreGroup = 2; 
    219232        vihu.Brain = seuraajanAivot; 
    220233        
    221234    } 
    222235 
    223     void LisaaNäkymätön(Vector paikka, Double leveys, Double korkeus) 
    224     { 
    225         PhysicsObject näkymätön = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    226         näkymätön.Tag = "näkymätön"; 
    227         näkymätön.Position = paikka; 
    228         näkymätön.Image = näkymätönkuva; 
    229         Add(näkymätön); 
     236    void LisaaNakymaton(Vector paikka, Double leveys, Double korkeus) 
     237    { 
     238        LisaaPalikka(paikka, leveys, korkeus, "näkymätön", näkymätönkuva,2); 
    230239    } 
    231240 
     
    259268    void TormaaVihuun(PhysicsObject hahmo, PhysicsObject vihu) 
    260269    { 
    261         elamalaskuri.Value -= 1; 
     270        if (!onKuolematon) 
     271        { 
     272            elamalaskuri.Value -= 1; 
     273            onKuolematon = true; 
     274            Timer.SingleShot(0.5, delegate { onKuolematon = false; }); 
     275        } 
     276         
     277 
    262278    } 
    263279 
     
    274290        tynnyri.Position = paikka; 
    275291        tynnyri.Image = tynnyrikuva; 
     292        tynnyri.CollisionIgnoreGroup = 2; 
    276293        Add(tynnyri); 
    277294    } 
     
    280297        Double Y = Level.Top - 25; 
    281298        Double X = RandomGen.NextDouble(Level.Left, Level.Right); 
    282         PhysicsObject laatikko = new PhysicsObject(50, 50); 
     299        Laatikko laatikko = new Laatikko(50, 50); 
    283300        laatikko.Position = new Vector(X, Y); 
    284301        laatikko.Tag = "laatikko"; 
    285302        laatikko.Image = laatikkokuva; 
     303        laatikko.CollisionIgnoreGroup = 2; 
     304        laatikko.spawnausajstin.Timeout += delegate {  
     305            LisaaVihu((laatikko.Position + new Vector(0, laatikko.Height/2.0 + RUUDUN_KOKO/2.0)), RUUDUN_KOKO, RUUDUN_KOKO);  
     306        }; 
     307         
    286308        Add(laatikko); 
    287309    } 
  • 2014/24/JuhoJ/ShotgunJoe/ShotgunJoe/ShotgunJoe/ShotgunJoe.csproj

    r4939 r4976  
    111111  </ItemGroup> 
    112112  <ItemGroup> 
     113    <Compile Include="Laatikko.cs" /> 
    113114    <Compile Include="Ohjelma.cs" /> 
    114115    <Compile Include="ShotgunJoe.cs" /> 
  • 2014/24/JuhoJ/ShotgunJoe/ShotgunJoe/ShotgunJoe/ShotgunJoe.csproj.Debug.cachefile

    r4972 r4976  
    77Content\Ruoho.xnb 
    88Content\multa.xnb 
    9 Content\haulikko.xnb 
    109Content\ammus.xnb 
    1110Content\Vihu.xnb 
     
    1312Content\tynnyri.xnb 
    1413Content\laatikko.xnb 
     14Content\haulikkoaani.xnb 
     15Content\haulikko.xnb 
  • 2014/24/JuhoJ/ShotgunJoe/ShotgunJoe/ShotgunJoe/obj/x86/Debug/ContentPipeline-{CF60888C-4746-4871-9D32-E8426663FBA0}.xml

    r4972 r4976  
    7575    </Item> 
    7676    <Item> 
    77       <Source>haulikko.png</Source> 
    78       <Name>haulikko</Name> 
    79       <Importer>TextureImporter</Importer> 
    80       <Processor>TextureProcessor</Processor> 
    81       <Options>None</Options> 
    82       <Output>C:\MyTemp\JuhoJ\ShotgunJoe\ShotgunJoe\ShotgunJoe\bin\x86\Debug\Content\haulikko.xnb</Output> 
    83       <Time>2014-06-11T12:21:36.8419572+03:00</Time> 
    84     </Item> 
    85     <Item> 
    8677      <Source>ammus.png</Source> 
    8778      <Name>ammus</Name> 
     
    127118      <Output>C:\MyTemp\JuhoJ\ShotgunJoe\ShotgunJoe\ShotgunJoe\bin\x86\Debug\Content\laatikko.xnb</Output> 
    128119      <Time>2014-06-12T12:42:49.6609945+03:00</Time> 
     120    </Item> 
     121    <Item> 
     122      <Source>haulikkoaani.wav</Source> 
     123      <Name>haulikkoaani</Name> 
     124      <Importer>WavImporter</Importer> 
     125      <Processor>SoundEffectProcessor</Processor> 
     126      <Options>None</Options> 
     127      <Output>C:\MyTemp\JuhoJ\ShotgunJoe\ShotgunJoe\ShotgunJoe\bin\x86\Debug\Content\haulikkoaani.xnb</Output> 
     128      <Time>2014-06-12T13:54:15.2691796+03:00</Time> 
     129    </Item> 
     130    <Item> 
     131      <Source>haulikko.png</Source> 
     132      <Name>haulikko</Name> 
     133      <Importer>TextureImporter</Importer> 
     134      <Processor>TextureProcessor</Processor> 
     135      <Options>None</Options> 
     136      <Output>C:\MyTemp\JuhoJ\ShotgunJoe\ShotgunJoe\ShotgunJoe\bin\x86\Debug\Content\haulikko.xnb</Output> 
     137      <Time>2014-06-11T12:21:36.8419572+03:00</Time> 
    129138    </Item> 
    130139    <BuildSuccessful>true</BuildSuccessful> 
  • 2014/24/JuhoJ/ShotgunJoe/ShotgunJoe/ShotgunJoe/obj/x86/Debug/ShotgunJoe.csproj.FileListAbsolute.txt

    r4972 r4976  
    2121C:\MyTemp\JuhoJ\ShotgunJoe\ShotgunJoe\ShotgunJoe\bin\x86\Debug\Content\tynnyri.xnb 
    2222C:\MyTemp\JuhoJ\ShotgunJoe\ShotgunJoe\ShotgunJoe\bin\x86\Debug\Content\laatikko.xnb 
     23C:\MyTemp\JuhoJ\ShotgunJoe\ShotgunJoe\ShotgunJoe\bin\x86\Debug\Content\haulikkoaani.xnb 
  • 2014/24/JuhoJ/ShotgunJoe/ShotgunJoe/ShotgunJoe/obj/x86/Debug/cachefile-{CF60888C-4746-4871-9D32-E8426663FBA0}-targetpath.txt

    r4972 r4976  
    77Content\Ruoho.xnb 
    88Content\multa.xnb 
    9 Content\haulikko.xnb 
    109Content\ammus.xnb 
    1110Content\Vihu.xnb 
     
    1312Content\tynnyri.xnb 
    1413Content\laatikko.xnb 
     14Content\haulikkoaani.xnb 
     15Content\haulikko.xnb 
  • 2014/24/JuhoJ/ShotgunJoe/ShotgunJoe/ShotgunJoeContent/ShotgunJoeContent.contentproj

    r4972 r4976  
    137137    </Compile> 
    138138  </ItemGroup> 
     139  <ItemGroup> 
     140    <Compile Include="haulikkoaani.wav"> 
     141      <Name>haulikkoaani</Name> 
     142      <Importer>WavImporter</Importer> 
     143      <Processor>SoundEffectProcessor</Processor> 
     144    </Compile> 
     145  </ItemGroup> 
    139146  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    140147  <!--  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.