Ignore:
Timestamp:
2015-06-09 20:27:58 (8 years ago)
Author:
empaheik
Message:
 
Location:
2015/24/ohjaajat/Dungeon/Dungeon
Files:
3 added
3 edited

Legend:

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

    r5965 r5966  
    2020    public Dictionary<Direction, GameObject> Walls { get; set; } 
    2121 
     22    public String Type { get; set; } 
     23 
     24    public int Damage { get; set; } 
     25 
     26    public int Culture { get; set; } 
     27 
    2228    private bool dug; // Onko huone kaivettu? 
    2329    public bool Dug 
     
    3743        Location = paikka; 
    3844    } 
     45 
     46    public int Hinta { get; set; } 
     47 
    3948} 
    4049 
     
    4352    public const int RUUDUN_KOKO = 64; 
    4453 
     54    #region Kuvat 
    4555    Image lattiaKuva = LoadImage("floor"); 
    4656    Image seinaKuva = LoadImage("wall"); 
    4757    Image reikaSeinaKuva = LoadImage("wallhole"); 
    4858    Image kiviKuva = LoadImage("rock"); 
     59    static Image kulttuuriKuva1 = LoadImage("es"); 
     60    static Image kulttuuriKuva2 = LoadImage("nyan"); 
     61    static Image kulttuuriKuva3 = LoadImage("spurdo"); 
     62    Image[] huoneKuvat = new Image[] { kulttuuriKuva1, kulttuuriKuva2, kulttuuriKuva3 }; 
     63    #endregion  
     64 
     65    int[] hinnat = new int[] { 100, 200, 300 }; 
     66    private int barbaariMaara = 3; 
    4967 
    5068    Room[,] huoneet; 
     69    Room spawn; 
     70    Timer barbaariAjastin = new Timer(); 
     71    Room ostettu; 
    5172    Point digStart; // Huoneen sijainti, josta kaivuu aloitetaan. 
    5273    bool digging = false; 
    5374 
     75    IntMeter kulttuuri = new IntMeter(300, 0, 2000); 
     76 
     77    int vaakaHuoneet = 12; 
     78    int pystyHuoneet = 8; 
     79 
    5480    public override void Begin() 
    5581    { 
    5682        ClearAll(); 
    57         IsMouseVisible = true; 
     83        Kontrollit(); 
     84        UlkoAsuRoskaa(); 
     85        Kauppa(); 
    5886 
    5987        // Luodaan huoneet ruutuihin. 
    60         huoneet = new Room[12, 8]; 
     88        huoneet = new Room[vaakaHuoneet, pystyHuoneet]; 
    6189        foreach (var paikka in RuutujenPaikat()) 
    6290        { 
     
    6997        LuoSpawn(); 
    7098 
     99        barbaariAjastin.Timeout += delegate { LuoBarbaareja(); }; 
     100        barbaariAjastin.Interval = 3; 
     101    } 
     102 
     103    void UlkoAsuRoskaa() 
     104    { 
     105        //Luodaan taustaolio  
     106        //GameObject tausta = new GameObject(vaakaHuoneet * RUUDUN_KOKO, pystyHuoneet * RUUDUN_KOKO); 
     107        //tausta.Color = Color.DarkBrown; 
     108        //tausta.Position -= new Vector(RUUDUN_KOKO * 0.5, RUUDUN_KOKO * 0.5); 
     109        //Add(tausta); 
     110 
     111        Level.Background.Color = Color.Black; 
     112 
     113        Label rahat = new Label(); 
     114        rahat.BindTo(kulttuuri); 
     115        rahat.Position = new Vector(Level.Right + Level.Width * 0.2, Level.Bottom + Level.Height * 0.1); 
     116        rahat.TextColor = Color.White; 
     117        rahat.IntFormatString = "Käytettävää kulttuuria: {0:D3}"; 
     118        Add(rahat); 
     119    } 
     120 
     121    void Kauppa() 
     122    { 
     123        for (int i = 0; i < huoneKuvat.Length; i++) 
     124        { 
     125            Point lokaatio = new Point(0, 0); 
     126 
     127            Room kuva = new Room(lokaatio); 
     128            kuva.Position = new Vector((Level.Right + Level.Width * 0.05), (Level.Top - Level.Height * 0.25 - (i * RUUDUN_KOKO))); 
     129            kuva.Image = huoneKuvat[i]; 
     130            kuva.Hinta = hinnat[i]; 
     131            Add(kuva); 
     132 
     133            Mouse.ListenOn(kuva, MouseButton.Left, ButtonState.Pressed, delegate(Room a) { ostettu = a; }, "Asetetaan ostettu huone paikoilleen", kuva); 
     134 
     135            Label teksti = new Label(); 
     136            teksti.Position = kuva.Position + new Vector((RUUDUN_KOKO * 1.2), 0); 
     137            teksti.TextColor = Color.White; 
     138            teksti.Text = hinnat[i].ToString(); 
     139            Add(teksti); 
     140        } 
     141    } 
     142 
     143    void LuoBarbaareja() 
     144    { 
     145        PhysicsObject barbaari = new PhysicsObject(RUUDUN_KOKO * 0.3, RUUDUN_KOKO * 0.3); 
     146        barbaari.Color = Color.Red; 
     147        //barbaari.Position = RandomGen.NextVector(Level.Right, Level.Bottom, Level.Left, Level.Top); 
     148        barbaari.Position = spawn.Position; 
     149        Add(barbaari); 
     150    } 
     151 
     152    void Kontrollit() 
     153    { 
     154        IsMouseVisible = true; 
    71155        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    72156        Keyboard.Listen(Key.F1, ButtonState.Pressed, Begin, null); 
     157 
     158        Keyboard.Listen(Key.Space, ButtonState.Pressed, SeuraavaAalto, "Anna kivan barbaariaallon tulla"); 
     159    } 
     160 
     161    void SeuraavaAalto() 
     162    { 
     163        barbaariMaara += 2; 
     164        barbaariAjastin.Start(barbaariMaara); 
    73165    } 
    74166 
    75167    void LuoSpawn() 
    76168    { 
    77         Room spawnHuone = huoneet[(int)(huoneet.GetLength(0) * 0.5), 0]; 
    78         spawnHuone.Image = null; 
    79         spawnHuone.Dug = true; 
    80  
    81         Direction oviSuunta = ((spawnHuone.Position - new Vector(0, RUUDUN_KOKO * 0.5)).Angle.MainDirection); 
    82         spawnHuone.Walls[oviSuunta].Image = reikaSeinaKuva; 
     169        spawn = huoneet[(int)(huoneet.GetLength(0) * 0.5), 0]; 
     170        spawn.Dug = true; 
     171 
     172        Direction oviSuunta = ((spawn.Position - new Vector(0, RUUDUN_KOKO * 0.5)).Angle.MainDirection); 
     173        spawn.Walls[oviSuunta].Image = reikaSeinaKuva; 
     174 
     175        Light valo = new Light(); 
     176        valo.Position = spawn.Position; 
     177        valo.Intensity = 1; 
     178        valo.Distance = 40; 
     179        Add(valo); 
     180         
    83181    } 
    84182 
     
    118216        huone.Roof.Position = huone.Position; 
    119217        Add(huone.Roof, 2); 
     218 
     219        Mouse.ListenOn(huone, MouseButton.Left, ButtonState.Pressed, AsetaHuone, "Asetetaan ostettu huone paikoilleen", huone); 
     220 
    120221        return huone; 
     222    } 
     223 
     224    void AsetaHuone(Room huone) 
     225    { 
     226        if(ostettu != null && huone.Dug && (kulttuuri.Value > huone.Hinta)) 
     227        { 
     228            huone.Damage = ostettu.Damage; 
     229            huone.Culture = ostettu.Culture; 
     230            huone.Image = ostettu.Image; 
     231            kulttuuri.Value -= ostettu.Hinta; 
     232            ostettu = null; 
     233        } 
    121234    } 
    122235 
  • 2015/24/ohjaajat/Dungeon/Dungeon/Dungeon/Dungeon.csproj.Debug.cachefile

    r5927 r5966  
    33Content\rock.xnb 
    44Content\wallhole.xnb 
     5Content\es.xnb 
     6Content\nyan.xnb 
     7Content\spurdo.xnb 
  • 2015/24/ohjaajat/Dungeon/Dungeon/DungeonContent/DungeonContent.contentproj

    r5927 r5966  
    7373    </Compile> 
    7474  </ItemGroup> 
     75  <ItemGroup> 
     76    <Compile Include="es.jpg"> 
     77      <Name>es</Name> 
     78      <Importer>TextureImporter</Importer> 
     79      <Processor>TextureProcessor</Processor> 
     80    </Compile> 
     81    <Compile Include="nyan.png"> 
     82      <Name>nyan</Name> 
     83      <Importer>TextureImporter</Importer> 
     84      <Processor>TextureProcessor</Processor> 
     85    </Compile> 
     86    <Compile Include="spurdo.jpg"> 
     87      <Name>spurdo</Name> 
     88      <Importer>TextureImporter</Importer> 
     89      <Processor>TextureProcessor</Processor> 
     90    </Compile> 
     91  </ItemGroup> 
    7592  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    7693  <!--  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.