Changeset 6035 for 2015/24


Ignore:
Timestamp:
2015-06-11 18:30:23 (8 years ago)
Author:
empaheik
Message:
 
Location:
2015/24/ohjaajat/Dungeon/Dungeon
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 2015/24/ohjaajat/Dungeon/Dungeon/Dungeon/Dungeon.cs

    r6034 r6035  
    3636    /// </summary> 
    3737    public virtual void Built(Dungeon peli) { } 
     38 
     39    /// <summary> 
     40    /// Tätä kutsutaan kun barbaari tulee kylään 
     41    /// </summary> 
     42    public virtual void Invasion(Dungeon peli, Barbaari barbaari, Room huone) { } 
    3843} 
    3944 
     
    4146{ 
    4247    public int Damage { get; set; } 
     48 
     49    public override void Invasion(Dungeon peli, Barbaari barbaari, Room huone) 
     50    { 
     51        barbaari.Destroy(); //TODO: Mitä nyt oikeasti tapahtuu, kun barbaari astuu ansaan. Meidän tapauksessa kai tapetaan saman tien. 
     52    } 
    4353} 
    4454 
     
    7484        }; 
    7585    } 
     86 
     87    public override void Invasion(Dungeon peli, Barbaari barbaari, Room huone) 
     88    { 
     89        this.Destroy(); 
     90        peli.kohteet.Remove(huone); 
     91        if (peli.kohteet.Count < 1) 
     92        { 
     93            peli.LopetaPeli(); 
     94        } 
     95    } 
    7696} 
    7797 
     
    112132{ 
    113133    public List<Point> Reitti { get; set; } 
    114      
     134 
    115135    public Barbaari(double width, double height) 
    116         :base(width, height) 
     136        : base(width, height) 
    117137    { 
    118138        Reitti = new List<Point>(); 
     
    148168    //static Image kulttuuriKuva3 = LoadImage("spurdo"); 
    149169    Image[] kultuuriKuvat = LoadImages("nyan", "es", "spurdo"); 
     170    Image[] ansaKuvat = LoadImages((from i in Enumerable.Range(1, 7) select String.Format("piikit{0:0000}", i)).ToArray()); 
    150171    Image[] vihuKuvat = LoadImages((from i in Enumerable.Range(1, 10) select String.Format("v{0:0000}", i)).ToArray()); 
    151172    Image partikkeli = LoadImage("partikkeli"); 
     
    156177 
    157178    Room[,] huoneet; 
    158     List<Room> kohteet = new List<Room>(); 
     179    public List<Room> kohteet = new List<Room>(); 
    159180    List<Barbaari> barbaarit = new List<Barbaari>(); 
    160181    Room spawn; 
     
    226247    } 
    227248 
     249    public void LopetaPeli() 
     250    { 
     251        ClearAll(); 
     252        GameObject spurdo = new GameObject(Screen.Width, Screen.Height); 
     253        spurdo.Image = kultuuriKuvat[2]; 
     254        Add(spurdo); 
     255 
     256        Label havisit = new Label("Hävisit muuten belin"); 
     257        havisit.Color = Color.HotPink; 
     258        havisit.Size = new Vector(300, 300); 
     259        havisit.Position = new Vector(Level.Right - havisit.Width * 0.5, Level.Top - havisit.Height * 0.5); 
     260        Add(havisit); 
     261    } 
     262 
    228263    void Kauppa() 
    229264    { 
     
    244279            }; 
    245280 
    246             Mouse.Listen(MouseButton.Right, ButtonState.Pressed, delegate() { ostamassa = null; }, "Perutaan ostos"); 
    247  
    248281            Label teksti = new Label(); 
    249282            teksti.Position = kuva.Position + new Vector((RUUDUN_KOKO * 1.2), 0); 
     
    251284            teksti.Text = hinnat[i].ToString(); 
    252285            Add(teksti); 
    253  
    254             /*for(int i = 0; i<ansaKuvat.Length; i++) 
    255             { 
    256  
    257             }*/ 
     286  
     287        } 
     288 
     289        for(int i = 0; i<1; i++) 
     290        { 
     291            PushButton kuva = new PushButton(ansaKuvat[ansaKuvat.Length - 1]); 
     292            kuva.Size = new Vector(1, 1) * RUUDUN_KOKO; 
     293            kuva.Position = new Vector((Level.Right + Level.Width * 0.05), (Level.Top - Level.Height * 0.25 - ((kultuuriKuvat.Count() + i) * RUUDUN_KOKO))); 
     294            Add(kuva); 
    258295        } 
    259296    } 
     
    288325        barbaari.Kohde = kohteet[RandomGen.NextInt(kohteet.Count)]; 
    289326        barbaari.Reitti = FindPath(barbaari.Kohde.Location, (barbaari.Location.Equals(spawn.Location)) ? spawn.Location : barbaari.Location); 
    290          
     327 
    291328 
    292329    } 
     
    294331    void Sykli() 
    295332    { 
    296         List<Barbaari> poistettavat = new List<Barbaari>(); 
     333        //List<Barbaari> poistettavat = new List<Barbaari>();   //TODO: Ansahuoneet poistamaan barbaareja, ei me. 
    297334        foreach (var barbaari in barbaarit) 
    298335        { 
    299336            if (barbaari.Reitti.Count == 0) 
    300337            { 
    301                 kohteet.Remove(barbaari.Kohde); 
    302  
    303                 if (kohteet.Count > 0) 
    304                 { 
    305                     EtsiBarbaarinReitti(barbaari);  //Etsitään uusi reitti poiston sijaan 
    306                     continue; 
    307                 } 
    308                  
    309                 poistettavat.Add(barbaari); 
    310                 barbaari.Destroy();  
    311                 continue; 
     338 
     339                EtsiBarbaarinReitti(barbaari);  //Etsitään uusi reitti poiston sijaan 
     340 
     341                /*poistettavat.Add(barbaari); 
     342                barbaari.Destroy(); 
     343                continue;*/ 
    312344            } 
    313345 
     
    317349        } 
    318350 
    319         foreach (var poista in poistettavat) 
    320             barbaarit.Remove(poista); 
     351        /*foreach (var poista in poistettavat) 
     352            barbaarit.Remove(poista);*/ 
    321353    } 
    322354 
     
    329361        Room huone = huoneet[uusiPaikka.X, uusiPaikka.Y]; 
    330362 
    331         if (huone != null && huone.Upgrade != null && huone.Upgrade is CultureUpgrade)  //Barbaari tuhoaa kultuurihuoneen. 
    332         { 
    333             var upg = huone.Upgrade as CultureUpgrade; 
    334             upg.Destroy(); 
     363        if (huone.Upgrade != null) 
     364        { 
     365            huone.Upgrade.Invasion(this, barbaari, huone); 
    335366        } 
    336367    } 
     
    348379    void SeuraavaAalto() 
    349380    { 
    350         
     381 
    351382        barbaariAjastin.Start(barbaariMaara); 
    352383        barbaariMaara += 2; 
     
    389420                Dig(GetRoom(kaivettavatPaikat[i]), GetRoom(kaivettavatPaikat[i + 1])); 
    390421            } 
    391              
     422 
    392423            //var alkuHuone = huoneet[digStart.X, digStart.Y]; 
    393424 
     
    430461 
    431462        Mouse.ListenOn(huone, MouseButton.Left, ButtonState.Pressed, AsetaPaivitys, "Asetetaan ostettu päivitys paikoilleen", huone); 
     463        Mouse.Listen(MouseButton.Right, ButtonState.Pressed, delegate() { ostamassa = null; }, "Perutaan ostos"); 
     464        Mouse.ListenOn(huone, MouseButton.Right, ButtonState.Pressed, PoistaPaivitys, "Poistetaan asetettu päivitys", huone); 
    432465 
    433466        return huone; 
     467    } 
     468 
     469    private void PoistaPaivitys(Room huone) 
     470    { 
     471        if (huone.Upgrade != null) 
     472        { 
     473            huone.Upgrade.Destroy(); 
     474        } 
    434475    } 
    435476 
     
    453494    void PaivitaHuoneidenKultuurit() 
    454495    { 
    455         RuutujenPaikat().Select(GetRoom).ToList().ForEach(PaivitaHuoneenKultuuri); // :D 
     496        RuutujenPaikat().Select(GetRoom).ToList().ForEach(PaivitaHuoneenKultuuri); // :D ;___;; MIKSI 
    456497    } 
    457498 
  • 2015/24/ohjaajat/Dungeon/Dungeon/Dungeon/Dungeon.csproj.Debug.cachefile

    r5972 r6035  
    1717Content\v0010.xnb 
    1818Content\partikkeli.xnb 
     19Content\piikit0001.xnb 
     20Content\piikit0002.xnb 
     21Content\piikit0003.xnb 
     22Content\piikit0004.xnb 
     23Content\piikit0005.xnb 
     24Content\piikit0006.xnb 
     25Content\piikit0007.xnb 
  • 2015/24/ohjaajat/Dungeon/Dungeon/DungeonContent/DungeonContent.contentproj

    r5971 r6035  
    149149    </Compile> 
    150150  </ItemGroup> 
     151  <ItemGroup> 
     152    <Compile Include="piikit0001.png"> 
     153      <Name>piikit0001</Name> 
     154      <Importer>TextureImporter</Importer> 
     155      <Processor>TextureProcessor</Processor> 
     156    </Compile> 
     157    <Compile Include="piikit0002.png"> 
     158      <Name>piikit0002</Name> 
     159      <Importer>TextureImporter</Importer> 
     160      <Processor>TextureProcessor</Processor> 
     161    </Compile> 
     162    <Compile Include="piikit0003.png"> 
     163      <Name>piikit0003</Name> 
     164      <Importer>TextureImporter</Importer> 
     165      <Processor>TextureProcessor</Processor> 
     166    </Compile> 
     167    <Compile Include="piikit0004.png"> 
     168      <Name>piikit0004</Name> 
     169      <Importer>TextureImporter</Importer> 
     170      <Processor>TextureProcessor</Processor> 
     171    </Compile> 
     172    <Compile Include="piikit0005.png"> 
     173      <Name>piikit0005</Name> 
     174      <Importer>TextureImporter</Importer> 
     175      <Processor>TextureProcessor</Processor> 
     176    </Compile> 
     177    <Compile Include="piikit0006.png"> 
     178      <Name>piikit0006</Name> 
     179      <Importer>TextureImporter</Importer> 
     180      <Processor>TextureProcessor</Processor> 
     181    </Compile> 
     182    <Compile Include="piikit0007.png"> 
     183      <Name>piikit0007</Name> 
     184      <Importer>TextureImporter</Importer> 
     185      <Processor>TextureProcessor</Processor> 
     186    </Compile> 
     187  </ItemGroup> 
    151188  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    152189  <!--  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.