Changeset 3379 for 2012/26


Ignore:
Timestamp:
2012-06-29 10:58:12 (11 years ago)
Author:
mitokalu
Message:

Talletus.

Location:
2012/26/MikaL
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • 2012/26/MikaL/Zombie Survival/Zombie Survival/Zombie Survival/Zombie_Survival.cs

    r3322 r3379  
    1010class Zombi : PhysicsObject 
    1111{ 
    12     public IntMeter zhp = new IntMeter(3,0,3); 
     12    public DoubleMeter zhp = new DoubleMeter(15,0,15); 
    1313 
    1414    public Zombi(double leveys, double korkeus) 
    1515        : base(leveys, korkeus) 
    1616    { 
    17         zhp.LowerLimit += delegate { this.Destroy();}; 
     17        zhp.LowerLimit += delegate { Tuhoa(); }; 
     18    } 
     19 
     20    public void Tuhoa() 
     21    { 
     22        Zombie_Survival peli = (Zombie_Survival)PhysicsGame.Instance; 
     23        peli.killLaskuri.Value++; 
     24        peli.rahaLaskuri.Value += 50; 
     25        this.Destroy(); 
     26        peli.SpawnaaZombi(); 
    1827    } 
    1928} 
     
    2736    IntMeter p1_ammo; 
    2837    IntMeter p1_lipas; 
     38    IntMeter p2_ammo; 
     39    IntMeter p2_lipas; 
    2940 
    3041    Label lataa; 
    31  
    32         IntMeter killLaskuri; 
    33         IntMeter rahaLaskuri; 
     42    Label lataa2; 
     43 
     44        public IntMeter killLaskuri; 
     45        public IntMeter rahaLaskuri; 
    3446    IntMeter multiplayer; 
    3547 
     
    3749    AssaultRifle ak1; 
    3850    AssaultRifle ak2; 
     51 
     52    DoubleMeter p1_hp; 
    3953 
    4054 
     
    5771    Image zombie_skin = LoadImage("zombie_skin"); 
    5872 
     73    List<Vector> zombipaikat; 
     74 
    5975    public override void Begin() 
    6076    { 
    61         SetWindowSize(1280, 1024, false); 
    62         if (DataStorage.Exists("pisteet.xml")) topLista = DataStorage.Load<ScoreList>(topLista, "scores.xml"); 
     77        zombipaikat = new List<Vector>(); 
     78 
     79        SetWindowSize(1024, 768, true); 
     80        if (DataStorage.Exists("scores.xml")) topLista = DataStorage.Load<ScoreList>(topLista, "scores.xml"); 
    6381 
    6482        multiplayer = new IntMeter(0); 
     
    7391    void StartGame() 
    7492    { 
     93        zombipaikat.Clear(); 
    7594        ui(); 
    7695        LuoMap(); 
     
    116135    void LuoMap() 
    117136    { 
    118         SetWindowSize(1280, 1024, false); 
     137        SetWindowSize(1024, 768, false); 
    119138        ColorTileMap ruudut = ColorTileMap.FromLevelAsset("map"); 
    120139        ruudut.SetTileMethod(Color.Black, TeeSeina); 
     
    122141        ruudut.SetTileMethod(Color.Blue, TeeP1); 
    123142        if(multiplayer == 1) ruudut.SetTileMethod(Color.Yellow, TeeP2); 
    124         ruudut.SetTileMethod(Color.Green, ZombieSpawn); 
     143        ruudut.SetTileMethod(Color.Green, TeeZombiPaikka); 
    125144        ruudut.Execute(20, 20); 
    126145        Level.CreateBorders(false); 
     
    179198        ak2.Image = null; 
    180199        ak2.Color = Color.Transparent; 
     200        ak1.ProjectileCollision = AmmusOsui; 
     201        ak1.Ammo.Value = p1_lipas.Value; 
    181202        p2.Add(ak2); 
    182203    } 
    183     void ZombieSpawn(Vector paikka, double leveys, double korkeus) 
     204    public void SpawnaaZombi() 
     205    { 
     206        //Tee ajastin  
     207    } 
     208    void TeeZombiPaikka(Vector paikka, double leveys, double korkeus) 
     209    { 
     210        zombipaikat.Add(paikka); 
     211    } 
     212 
     213    void LuoZombi() 
    184214    { 
    185215        Zombi z1 = new Zombi(45, 38); 
    186         z1.Position = paikka; 
     216        z1.Position = RandomGen.SelectOne<Vector>(zombipaikat); 
    187217        FollowerBrain zombinAivot = new FollowerBrain("living"); 
    188218        z1.Shape = Shape.Circle; 
     
    240270        Keyboard.Listen(Key.D, ButtonState.Released, AsetaNopeus, null, p1, Vector.Zero); 
    241271 
    242         Keyboard.Listen(Key.Space, ButtonState.Pressed, AvaaOvi, null, p1); 
     272        Keyboard.Listen(Key.Space, ButtonState.Pressed, Use, null, p1); 
    243273        Mouse.Listen(MouseButton.Left, ButtonState.Down, Shoot, null, p1); 
    244274         
     
    260290        ControllerOne.Listen(Button.DPadRight, ButtonState.Released, AsetaNopeus, null, p2, Vector.Zero); 
    261291 
    262         ControllerOne.Listen(Button.Y, ButtonState.Pressed, AvaaOvi, null, p2); 
     292        ControllerOne.Listen(Button.Y, ButtonState.Pressed, Use, null, p2); 
    263293 
    264294    } 
     
    267297 
    268298        //p1_hp 
    269         DoubleMeter p1_hp = new DoubleMeter(100); 
     299        p1_hp = new DoubleMeter(5); 
    270300        Label player1 = new Label("Player 1"); 
    271301        player1.X = Screen.Left + 40; 
    272302        player1.Y = Screen.Top - 15; 
    273         p1_hp.MaxValue = 100; 
     303        p1_hp.MaxValue = 5; 
    274304        ProgressBar p1_hpPalkki = new ProgressBar(170, 20); 
    275305        p1_hpPalkki.BindTo(p1_hp); 
     
    288318        p1_ammo_lipas.BindTo(p1_lipas); 
    289319        p1_ammo_label.BindTo(p1_ammo); 
    290         p1_ammo_lipas.Y = Screen.Top - 60; 
    291         p1_ammo_lipas.X = - 35; 
    292         vali.Y = Screen.Top - 60; 
    293         vali.X = -20; 
    294         p1_ammo_label.Y = Screen.Top - 60; 
    295         p1_ammo_label.X = 5; 
     320        p1_ammo_lipas.Y = Screen.Top - 50; 
     321        p1_ammo_lipas.X = - 100; 
     322        vali.Y = Screen.Top - 50; 
     323        vali.X = -85; 
     324        p1_ammo_label.Y = Screen.Top - 50; 
     325        p1_ammo_label.X = -60; 
    296326        Add(p1_ammo_lipas); 
    297327        Add(vali); 
    298328        Add(p1_ammo_label); 
    299329 
     330 
    300331        //Ase 
    301         GameObject aseenkuva = new GameObject(90,27); 
    302         aseenkuva.Image = miniak; 
    303         aseenkuva.Y = Screen.Top - 15; 
    304         aseenkuva.X = -17; 
    305         Add(aseenkuva); 
     332        LuoAse(-100, Level.Top + 70); 
     333        LuoAse(Level.Left + 20, Level.Bottom + 100); 
     334        if(multiplayer == 1) LuoAse(+100, Level.Top + 70); 
     335         
     336        //GameObject aseenkuva = new GameObject(90,27); 
     337        //aseenkuva.Image = miniak; 
     338        //aseenkuva.Y = Level.Top +50; 
     339        //aseenkuva.X = -17; 
     340        //Add(aseenkuva); 
     341 
     342 
    306343        if (multiplayer == 0) return; 
    307344 
     
    317354        p2_hpPalkki.Y = Screen.Top - 40; 
    318355        p2_hpPalkki.BarImage = LoadImage("fullbar"); 
     356        p2_hpPalkki.Image = LoadImage("emptybar"); 
    319357        Add(p2_hpPalkki); 
    320358        Add(player2);    
     359 
     360        //p2_ammo 
     361        p2_ammo = new IntMeter(280); 
     362        p2_lipas = new IntMeter(30); 
     363        Label p2_ammo_label = new Label(); 
     364        vali = new Label("/"); 
     365        Label p2_ammo_lipas = new Label(); 
     366        p2_ammo_lipas.BindTo(p2_lipas); 
     367        p2_ammo_label.BindTo(p2_ammo); 
     368        p2_ammo_lipas.Y = Screen.Top - 50; 
     369        p2_ammo_lipas.X = +100; 
     370        vali.Y = Screen.Top - 50; 
     371        vali.X = +85; 
     372        p2_ammo_label.Y = Screen.Top - 50; 
     373        p2_ammo_label.X = +60; 
     374        Add(p2_ammo_lipas); 
     375        Add(vali); 
     376        Add(p2_ammo_label); 
     377 
     378    } 
     379    void LuoAse(double X, double Y) 
     380    { 
     381        GameObject aseenkuva = new GameObject(90, 27); 
     382        aseenkuva.Image = miniak; 
     383        aseenkuva.Y = Y; 
     384        aseenkuva.X = X; 
     385        aseenkuva.Tag = "ase"; 
     386        Add(aseenkuva, -3); 
    321387    } 
    322388         
     
    359425        player.Angle = nopeus.Angle; 
    360426        OvenLahella(player); 
     427        AseenLahella(player); 
    361428    } 
    362429    void Shoot(PhysicsObject pelaaja) 
     
    367434            if(ammus != null) p1_lipas.Value--; 
    368435        } 
     436        if (pelaaja == p2) 
     437        { 
     438            PhysicsObject ammus = ak2.Shoot(); 
     439            if (ammus != null) p1_lipas.Value--; 
     440        } 
     441        if (p1_lipas == 0) 
     442        { 
     443            lataa = new Label("Reload"); 
     444            lataa.MaximumLifetime = TimeSpan.FromSeconds(1); 
     445            Add(lataa); 
     446        } 
     447        if (multiplayer == 1 && p2_lipas == 0) 
     448        { 
     449            lataa2 = new Label("Reload"); 
     450            lataa2.X = -50; 
     451            lataa.MaximumLifetime = TimeSpan.FromSeconds(1); 
     452            Add(lataa); 
     453        } 
    369454    } 
    370455    void ZombieHit(PhysicsObject zombi, PhysicsObject kohde) 
    371456    { 
    372          
     457        if (kohde.Tag == "living") p1_hp.Value--; 
     458        if (p1_hp == 0) GameOver(); 
    373459    } 
    374460    void LuoAikaLaskuri() 
     
    411497        else 
    412498        { 
    413             hinta = new Label("Press Space or Y to open one block of the door."); 
     499            hinta = new Label("Press Space or (Y) to open one block of the door."); 
    414500            hinta2 = new Label("$150 per block"); 
    415501            hinta.X = -20; 
     
    420506        hinta.MaximumLifetime = TimeSpan.FromSeconds(1); 
    421507        hinta2.MaximumLifetime = TimeSpan.FromSeconds(1); 
    422          
    423508    } 
    424509    void HighScores() 
     
    441526            ak1.Ammo.Value = p1_lipas.Value; 
    442527        } 
    443         if (p1_lipas == 0) 
    444         { 
    445             lataa = new Label("Reload"); 
    446             lataa.MaximumLifetime = TimeSpan.FromSeconds(1); 
    447             Add(lataa); 
    448  
    449         } 
     528        //if (p1_lipas == 0) 
     529        //{ 
     530        //    lataa = new Label("Reload"); 
     531        //    lataa.MaximumLifetime = TimeSpan.FromSeconds(1); 
     532        //    Add(lataa); 
     533        // 
     534        //} 
    450535    } 
    451536    void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 
     
    458543        { 
    459544            Zombi z1 = kohde as Zombi; 
    460             z1.zhp.Value--; 
    461         } 
    462          
    463     } 
     545            z1.zhp.Value -= 7.5; 
     546        } 
     547    } 
     548    void OstaAmmo(PhysicsObject pelaaja) 
     549    { 
     550        GameObject ase = GetObjectAt(pelaaja.Position, "ase", 35); 
     551        if (ase == null) return; 
     552        else if (rahaLaskuri > 499) 
     553        { 
     554            p1_lipas.SetValue(30); 
     555            p1_ammo.SetValue(280); 
     556            rahaLaskuri.SetValue(rahaLaskuri.Value - 500); 
     557        } 
     558        else return; 
     559    } 
     560    void GameOver() 
     561    { 
     562        ClearAll(); 
     563        Mouse.IsCursorVisible = true; 
     564        HighScoreWindow topIkkuna = new HighScoreWindow("Parhaat pisteet","Onneksi olkoon, pääsit listalle lahtaamalla %p zombia! Syötä nimesi:", 
     565                             topLista, killLaskuri); 
     566        topIkkuna.Closed += TallennaPisteet; 
     567        Add(topIkkuna); 
     568    } 
     569    void TallennaPisteet(Window sender) 
     570    { 
     571        DataStorage.Save<ScoreList>(topLista, "pisteet.xml"); 
     572        Valikko(); 
     573    } 
     574    void Use(PhysicsObject pelaaja) 
     575    { 
     576        OstaAmmo(pelaaja); 
     577        AvaaOvi(pelaaja); 
     578    } 
     579    void AseenLahella(PhysicsObject pelaaja) 
     580    { 
     581        GameObject ase = GetObjectAt(pelaaja.Position, "ase", 35); 
     582        Label hinta; 
     583        Label hinta2; 
     584        if (ase == null) return; 
     585        if (multiplayer == 0) 
     586        { 
     587            hinta = new Label("Press Space to buy AK-47 ammo."); 
     588            hinta2 = new Label("$500"); 
     589            hinta.X = -20; 
     590            hinta2.Y = -20; 
     591            Add(hinta); 
     592            Add(hinta2); 
     593        } 
     594        else 
     595        { 
     596            hinta = new Label("Press Space or (Y) to buy AK-47 ammo."); 
     597            hinta2 = new Label("$500"); 
     598            hinta.X = -20; 
     599            hinta2.Y = -20; 
     600            Add(hinta); 
     601            Add(hinta2); 
     602        } 
     603        hinta.MaximumLifetime = TimeSpan.FromSeconds(1); 
     604        hinta2.MaximumLifetime = TimeSpan.FromSeconds(1); 
     605    } 
     606 
    464607} 
  • 2012/26/MikaL/Zombie Survival/Zombie Survival/Zombie SurvivalContent/Zombie SurvivalContent.contentproj

    r3322 r3379  
    9191    </Compile> 
    9292  </ItemGroup> 
     93  <ItemGroup> 
     94    <Compile Include="emptybar.png"> 
     95      <Name>emptybar</Name> 
     96      <Importer>TextureImporter</Importer> 
     97      <Processor>TextureProcessor</Processor> 
     98    </Compile> 
     99  </ItemGroup> 
    93100  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    94101  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2012/26/MikaL/asd/asd/asd/asd.cs

    r3322 r3379  
    1717        { 
    1818            MessageDisplay.Add("LOL"); 
    19             ControllerOne.Vibrate(1, 1, 1, 1, 1000000); 
     19            ControllerOne.Vibrate(1, 1, 2, 2, 1000000); 
    2020            lol.AddValue(1); 
    2121        } 
Note: See TracChangeset for help on using the changeset viewer.