Changeset 7029 for 2015/30


Ignore:
Timestamp:
2015-07-24 12:21:39 (8 years ago)
Author:
misakana
Message:
 
Location:
2015/30/SamuelL
Files:
8 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • 2015/30/SamuelL/jotain/jotain/jotain/jotain.cs

    r6995 r7029  
    1616    AssaultRifle ase1; 
    1717    bool ase1Flipattu = false; 
     18    bool otettuOsumaa = false; 
     19    IntMeter helat; 
    1820 
    1921    Image pelaajanKuva = LoadImage("pelaajakuva"); 
     
    3335    Image Asekuva = LoadImage("GUN"); 
    3436    Image Tähtäin = LoadImage("tähtäin"); 
     37    Image[] Hirviökuvat = LoadImages("hirviö1", "hirviö2"); 
     38    Image alienpesä = LoadImage("pesä"); 
    3539 
    3640    int kenttänumero = 1; 
     
    4145    SoundEffect TuliPalo = LoadSoundEffect("tuli"); 
    4246    SoundEffect pistolshot = LoadSoundEffect("PistolShot"); 
     47    SoundEffect spooky = LoadSoundEffect("spooky"); 
     48    SoundEffect alien = LoadSoundEffect("aline"); 
    4349 
    4450    public override void Begin() 
     
    5056    void LuoKentta() 
    5157    { 
     58        ase1Flipattu = false; 
    5259        TileMap kentta = TileMap.FromLevelAsset("kentta" + kenttänumero); 
    5360        kentta.SetTileMethod('#', LisaaTaso); 
     
    6269        kentta.SetTileMethod('o', Lisaakivi, pienikivi, -1); 
    6370        kentta.SetTileMethod('p', Lisaapuu, puu, 1); 
     71        kentta.SetTileMethod('L', Lisaapesä); 
    6472        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    6573        kentta.Optimize('#'); 
     
    118126        Add(tahti); 
    119127    } 
     128    void OtaOsumaa(PhysicsObject a, PhysicsObject b) 
     129    { 
     130        if (!otettuOsumaa) 
     131        { 
     132            helat.Value--; 
     133            otettuOsumaa = true; 
     134        } 
     135        Timer.SingleShot(3, delegate { otettuOsumaa = false; }); 
     136    } 
    120137 
    121138    void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 
     
    126143        pelaaja1.Image = pelaajanKuva; 
    127144        pelaaja1.Tag = "pelaaja1"; 
     145        pelaaja1.CollisionIgnoreGroup = 3; 
    128146        pelaaja1.AnimWalk = kävely; 
    129147        pelaaja1.AnimIdle = new Animation(pelaajanKuva); 
     
    132150        Add(pelaaja1); 
    133151        AddCollisionHandler(pelaaja1, "vaihto", tormaavaihtoon); 
     152        AddCollisionHandler(pelaaja1, "hirviö", OtaOsumaa); 
     153 
     154        helat = new IntMeter(5, 0, 5); 
     155        helat.LowerLimit += delegate  
     156        { 
     157            kenttänumero = 1; 
     158            AloitaKentta();  
     159        }; 
     160 
     161        ProgressBar elamaPalkki = new ProgressBar(50, 10); 
     162        elamaPalkki.Y = 50; 
     163        elamaPalkki.BindTo(helat); 
     164        pelaaja1.Add(elamaPalkki); 
     165 
    134166 
    135167        GameObject pimeys = new GameObject(2700, 2700); 
     
    148180        ase1.Image = Asekuva; 
    149181        ase1.Size *= 0.1; 
    150         ase1.Power.Value = 2000; 
    151         ase1.FireRate = 2.0; 
     182        ase1.FireRate = 2.5; 
    152183        ase1.Tag = "ase"; 
    153184        ase1.AttackSound = pistolshot; 
    154  
    155  
    156  
    157185 
    158186        Add(ase1); 
     
    275303    void AloitaKentta() 
    276304    { 
    277         ClearAll(); 
     305        ClearAll();        
    278306        kävely = LoadAnimation("pelaaja"); 
    279307        Gravity = new Vector(0, -1000); 
     
    294322        { 
    295323            MediaPlayer.Stop(); 
     324            MediaPlayer.Play("spooky"); 
     325            MediaPlayer.IsRepeating = true; 
    296326        } 
    297327    } 
     
    324354    { 
    325355        PhysicsObject ammus = ase1.Shoot(); 
     356        Vector ampumispaikka = ase1.AbsolutePosition; 
    326357 
    327358        if (ammus != null) 
    328359        { 
     360            ammus.Size *= 1.0; 
     361            ammus.Image = null; 
     362            ammus.Color = Color.Black; 
     363            ammus.Shape = Shape.Rectangle; 
     364            ammus.Position += ase1.AbsoluteAngle.GetVector() * 20; 
    329365            ammus.MaximumLifetime = TimeSpan.FromSeconds(5); 
     366            ammus.Tag = "ammus"; 
    330367             
    331             AddCollisionHandler(ammus, "taso", delegate(PhysicsObject a, PhysicsObject b)  
     368            Timer ajastin = new Timer(); 
     369            ajastin.Interval = 0.01; 
     370            ajastin.Timeout += delegate 
    332371            { 
    333                 ammus.Destroy();  
     372                GameObject vana = new GameObject(ammus.Width * 1.7, ammus.Height * 0.4); 
     373                vana.Angle = (ammus.Position - ampumispaikka).Angle; 
     374                vana.Color = Color.Black; //new Color(0, 0, 0, 128); 
     375                vana.Position = ammus.Position; 
     376                vana.FadeColorTo(Color.Transparent, 0.5); 
     377                vana.LifetimeLeft = TimeSpan.FromSeconds(0.5); 
     378                Add(vana); 
     379            }; 
     380            ajastin.Start(); 
     381 
     382            AddCollisionHandler(ammus, delegate(PhysicsObject a, PhysicsObject b) 
     383            { 
     384                ammus.Destroy(); 
     385                ajastin.Stop(); 
    334386            }); 
    335387        } 
    336388    } 
     389    void Lisaapesä(Vector paikka, double leveys, double korkeus) 
     390    { 
     391        PhysicsObject pesä = PhysicsObject.CreateStaticObject(leveys*2, korkeus*1.5); 
     392        pesä.Position = paikka; 
     393        pesä.IsVisible = true; 
     394        pesä.Y -= korkeus*0.2; 
     395        pesä.Tag = "pesä"; 
     396        pesä.IgnoresCollisionResponse = true; 
     397        Add(pesä); 
     398        pesä.Color = Color.Emerald; 
     399        pesä.Image = alienpesä; 
     400 
     401        Timer ajastin = new Timer(); 
     402        ajastin.Interval = 8; 
     403        ajastin.Timeout += delegate 
     404        { 
     405            Lisäähirviö(paikka,leveys,korkeus); 
     406        }; 
     407        ajastin.Start(); 
     408 
     409        IntMeter elämät = new IntMeter(12); 
     410        AddCollisionHandler(pesä, "ammus", delegate(PhysicsObject a, PhysicsObject b) 
     411        { 
     412            elämät.Value--; 
     413        }); 
     414        elämät.LowerLimit += delegate 
     415        { 
     416            pesä.Destroy(); 
     417            ajastin.Stop(); 
     418            LisaaEfekti(pesä.Position); 
     419        }; 
     420    } 
     421 
     422    void Lisäähirviö(Vector paikka, double leveys, double korkeus) 
     423    { 
     424        PhysicsObject hirviö = new PhysicsObject(leveys, korkeus); 
     425        hirviö.Animation = new Animation(Hirviökuvat); 
     426        hirviö.Animation.Start(); 
     427        hirviö.Position = paikka; 
     428        hirviö.CanRotate = false; 
     429        hirviö.Tag = "hirviö"; 
     430        Add(hirviö); 
     431 
     432        RandomMoverBrain satunnaisAivot = new RandomMoverBrain(100); 
     433        satunnaisAivot.WanderRadius = 200; 
     434        FollowerBrain seuraajanAivot = new FollowerBrain("pelaaja1"); 
     435        seuraajanAivot.Speed = 80;                 // Millä nopeudella kohdetta seurataan 
     436        seuraajanAivot.DistanceFar = 270;           // Etäisyys jolla aletaan seurata kohdetta 
     437        seuraajanAivot.FarBrain = satunnaisAivot; 
     438        hirviö.Brain = seuraajanAivot; 
     439 
     440        IntMeter elämät = new IntMeter(3); 
     441        AddCollisionHandler(hirviö, "ammus", delegate(PhysicsObject a, PhysicsObject b) 
     442        { 
     443            elämät.Value--; 
     444        }); 
     445        elämät.LowerLimit += delegate 
     446        { 
     447            hirviö.Destroy(); 
     448            LisaaEfekti(hirviö.Position); 
     449            MediaPlayer.Play("alien"); 
     450            MediaPlayer.IsRepeating = false; 
     451        }; 
     452    } 
     453 
     454    void LisaaEfekti(Vector paikka) 
     455    { 
     456        for (int i = 0; i < 10; i++) 
     457        { 
     458            PhysicsObject pala = new PhysicsObject(10, 10); 
     459            //pala.Image = ... 
     460            pala.Color = Color.DarkGreen; 
     461            pala.FadeColorTo(Color.Transparent, 1.0); 
     462            pala.LifetimeLeft = TimeSpan.FromSeconds(1.0); 
     463            pala.CollisionIgnoreGroup = 3; 
     464            pala.Position = paikka; 
     465            pala.Hit(RandomGen.NextVector(50, 200)); 
     466            Add(pala); 
     467        } 
     468    } 
    337469 
    338470} 
  • 2015/30/SamuelL/jotain/jotain/jotain/jotain.csproj.Debug.cachefile

    r6995 r7029  
    99Content\kÀvely loulassa.xnb 
    1010Content\kÀvely ruohossa.xnb 
    11 Content\spooky.xnb 
    1211Content\tulikuva.xnb 
    1312Content\kentta2.xnb 
     
    3635Content\tÀhtÀin.xnb 
    3736Content\PistolShot.xnb 
     37Content\hirviö1.xnb 
     38Content\hirviö2.xnb 
     39Content\spooky.xnb 
     40Content\alien.xnb 
     41Content\pesÀ.xnb 
    3842Content\tuli.wma 
     43Content\spooky.wma 
     44Content\alien.wma 
  • 2015/30/SamuelL/jotain/jotain/jotainContent/jotainContent.contentproj

    r6995 r7029  
    110110  </ItemGroup> 
    111111  <ItemGroup> 
    112     <Compile Include="spooky.wav"> 
    113       <Name>spooky</Name> 
    114       <Importer>WavImporter</Importer> 
    115       <Processor>SoundEffectProcessor</Processor> 
    116     </Compile> 
    117   </ItemGroup> 
    118   <ItemGroup> 
    119112    <Compile Include="tulikuva.png"> 
    120113      <Name>tulikuva</Name> 
     
    219212      <Importer>WavImporter</Importer> 
    220213      <Processor>SoundEffectProcessor</Processor> 
     214    </Compile> 
     215  </ItemGroup> 
     216  <ItemGroup> 
     217    <Compile Include="hirviö1.png"> 
     218      <Name>hirviö1</Name> 
     219      <Importer>TextureImporter</Importer> 
     220      <Processor>TextureProcessor</Processor> 
     221    </Compile> 
     222  </ItemGroup> 
     223  <ItemGroup> 
     224    <Compile Include="hirviö2.png"> 
     225      <Name>hirviö2</Name> 
     226      <Importer>TextureImporter</Importer> 
     227      <Processor>TextureProcessor</Processor> 
     228    </Compile> 
     229  </ItemGroup> 
     230  <ItemGroup> 
     231    <Compile Include="spooky.mp3"> 
     232      <Name>spooky</Name> 
     233      <Importer>Mp3Importer</Importer> 
     234      <Processor>SongProcessor</Processor> 
     235    </Compile> 
     236  </ItemGroup> 
     237  <ItemGroup> 
     238    <Compile Include="alien.mp3"> 
     239      <Name>alien</Name> 
     240      <Importer>Mp3Importer</Importer> 
     241      <Processor>SongProcessor</Processor> 
     242    </Compile> 
     243  </ItemGroup> 
     244  <ItemGroup> 
     245    <Compile Include="pesä.png"> 
     246      <Name>pesä</Name> 
     247      <Importer>TextureImporter</Importer> 
     248      <Processor>TextureProcessor</Processor> 
    221249    </Compile> 
    222250  </ItemGroup> 
  • 2015/30/SamuelL/jotain/jotain/jotainContent/kentta2.txt

    r6995 r7029  
    33                  ##              ####                        
    44                ###                  ###### 
    5 #     ##### #####                        #### ###### 
    6  ###########                                 ## #   ######### 
    7                                                          #### 
    8  
    9  
    10  
    11  
    12  
    13         K         p        k                  K                
    14                                   O 
     5#     ##### #####                       ########### 
     6 ###########    L                         L   ################# 
     7#######  L                                           L    ##### 
     8#                                                            # 
     9#                                                            # 
     10#                                                            # 
     11#                                                            # 
     12#                                                            # 
     13#        K         p        k                  K             # 
     14#                                   O                        # 
    1515############################################################## 
Note: See TracChangeset for help on using the changeset viewer.