Changeset 4420


Ignore:
Timestamp:
2013-07-03 23:39:21 (10 years ago)
Author:
jumakall
Message:
 
Location:
2013/27/TeemuM/Game
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • 2013/27/TeemuM/Game/Game/Game/Enemies.cs

    r4417 r4420  
    99using Jypeli.Widgets; 
    1010 
    11 public class Zombie1 : PhysicsObject 
     11public class Zombie : PhysicsObject 
    1212{ 
     13 
     14    private static Image[] Images = { Game.LoadImage("Zombie1"), Game.LoadImage("Zombie2"), Game.LoadImage("Zombie3"), Game.LoadImage("Zombie4") }; 
    1315 
    1416    private int health; 
    1517 
    16     private static Image[] Images = { Game.LoadImage("Zombie1"), Game.LoadImage("Zombie2"), Game.LoadImage("Zombie3"), Game.LoadImage("Zombie4") }; 
    17      
    18     public Zombie1(double widht, double height, double x, double y, int healt) : base(widht, height) 
     18    public Zombie(double widht, double height, double x, double y, int health) : base(widht, height) 
    1919    { 
    2020        this.X = x; 
    2121        this.Y = y; 
    2222        this.Shape = Shape.Circle; 
     23        this.health = health; 
    2324        RandomTexture();  
    2425        CreateBrain(); 
    25         createZHealth(healt); 
    2626 
    2727        this.IsUpdated = true; 
    2828    } 
    2929 
    30     public void createZHealth(int health) 
    31     { 
    32         this.health = health; 
    33     } 
    34  
    35     private void RandomTexture() 
     30    public void RandomTexture() 
    3631    { 
    3732        this.Image = Images[RandomGen.NextInt(Images.Length)]; 
    3833    } 
    3934 
    40     public void Healt(int healtChange) 
     35    public void Health(int healtChange) 
    4136    { 
    4237        health += healtChange; 
    4338        if (health <= 0) 
    44         { 
    4539            this.Destroy(); 
    46         } 
    4740    } 
    4841 
  • 2013/27/TeemuM/Game/Game/Game/Game.cs

    r4417 r4420  
    1010{ 
    1111    public static G game; 
    12     IntMeter scoreboard; 
     12    private IntMeter scoreboard; 
    1313    public Player player { get; private set; } 
     14    private List<Zombie> enemies = new List<Zombie>(); 
    1415 
    1516    public override void Begin() 
     
    4344                else if (commands[1] == "reduce") 
    4445                { 
    45                     MessageDisplay.Add("-$" + int.Parse(commands[2]) + "!"); 
     46                    MessageDisplay.Add("-$" + int.Parse(commands[2])); 
     47                } 
     48            } 
     49            else if (commands[0] == "score") 
     50            { 
     51                if (commands[1] == "add") 
     52                { 
     53                    MessageDisplay.Add("+" + int.Parse(commands[2])); 
     54                    Score(int.Parse(commands[2])); 
     55                } 
     56                else if (commands[1] == "reduce") 
     57                { 
     58                    MessageDisplay.Add("-" + int.Parse(commands[2])); 
     59                    Score(int.Parse(commands[2])); 
    4660                } 
    4761            } 
     
    7084            else if (commands[0] == "powerup") 
    7185            { 
    72                 if (player.PowerUp(commands[1], int.Parse(commands[2]))) 
     86                if (player.PowerUp(commands[1], double.Parse(commands[2]))) 
    7387                    MessageDisplay.Add("Activated " + commands[1] + " powerup"); 
    7488                else 
     
    8296                    { 
    8397                        for (int i = 0; i < int.Parse(commands[2]); i++) 
    84                             createZ(); 
    85                     } else { createZ(); } 
     98                            SpawnZombie(); 
     99                    } else { SpawnZombie(); } 
     100                } 
     101            } 
     102            else if (commands[0] == "kill") 
     103            { 
     104                if (commands[1] == "enemies") 
     105                { 
     106                    KillAllEnemies(); 
     107                    MessageDisplay.Add("All enemies killed"); 
    86108                } 
    87109            } 
     
    105127        player = new Player(50, 50, 1, true); 
    106128        Add(player); 
    107         createZ(); 
     129        SpawnZombie(); 
    108130    } 
    109131 
    110     void createZ() 
     132    public void Score(int changeValue) 
    111133    { 
    112         Zombie1 zed1 = new Zombie1(50, 50, RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top), 100); 
    113         Add(zed1); 
     134        scoreboard.Value += changeValue; 
    114135    } 
    115136 
    116     void createPlayer() 
     137    private void SpawnZombie() 
    117138    { 
    118         player = new Player(50, 50, 100, true); 
    119         Add(player); 
     139        Zombie zombie = new Zombie(50, 50, RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top), 100); 
     140        enemies.Add(zombie); 
     141        Add(zombie); 
     142    } 
     143 
     144    private void KillAllEnemies() 
     145    { 
     146        foreach (Zombie enemy in enemies) 
     147        { 
     148            enemy.Destroy(); 
     149        } 
    120150    } 
    121151 
     
    123153    { 
    124154        scoreboard = new IntMeter(0); 
    125         scoreboard.AddOverTime(100, 10); 
    126  
    127155        Label ScoreScreen = new Label(); 
    128156        ScoreScreen.X = 0; 
     
    134162    } 
    135163 
    136     private void SaveAndBackToMenu() 
     164    private void SaveAndBackToMenu() //ToDo: Save 
    137165    { 
    138166        ClearAll(); 
     
    148176        menu.AddItemHandler(1, SaveAndBackToMenu); 
    149177        menu.AddItemHandler(2, Exit); 
     178        Add(menu); 
    150179        IsPaused = true; 
    151         Add(menu); 
    152  
    153180    } 
    154181} 
  • 2013/27/TeemuM/Game/Game/Game/Player.cs

    r4417 r4420  
    1313    private static Image playerImage = Game.LoadImage("Player"); 
    1414 
    15     Weapon weapon; 
    16     double speed = defaultSpeed; 
    17     int power = defaultPower; 
    18     private int _health = 0; 
    19     public int health 
    20     { 
    21         get 
    22         { 
    23             return _health; 
    24         } 
    25         set 
    26         { 
    27             if (value == 0) 
    28                 Game.MessageDisplay.Add("GAME OVER!"); 
    29             _health = value; 
    30         } 
    31     } 
     15    private Weapon weapon; 
     16    private double speed = defaultSpeed; 
     17    private int health; 
     18    private double power = defaultPower; 
    3219 
    3320    public Player(double width, double height, int health, bool addDefaultControls) : base(width, height) 
    3421    { 
     22        this.health = health; 
    3523        this.Tag = "player"; 
    3624        this.Shape = Shape.Rectangle; 
    3725        this.Image = playerImage; 
    3826        this.LinearDamping = 0.9; 
    39  
    40         this.health = health; 
    4127 
    4228        if (addDefaultControls) 
     
    4632    } 
    4733 
    48     public bool PowerUp(String type, int value) 
     34    public void Health(int healthChange) //ToDo: Game over, if no more health. 
     35    { 
     36        health += healthChange; 
     37    } 
     38 
     39    public bool PowerUp(String type, double value) 
    4940    { 
    5041        if (type == "speed") 
    5142        { 
    52             speed = defaultSpeed + value; 
     43            speed = defaultSpeed * value; 
     44            return true; 
     45        } 
     46        else if (type == "power") 
     47        { 
     48            power = defaultPower * value; 
    5349            return true; 
    5450        } 
     
    6763        if (weapon != null) 
    6864        { 
     65            weapon.Power.Value = power; 
    6966            weapon.ProjectileCollision = ProjectileHanlder; 
    7067            weapon.Angle = Angle.FromDegrees(90); 
     
    7572    } 
    7673 
    77     private void ProjectileHanlder(PhysicsObject projectile, PhysicsObject target) 
     74    private void ProjectileHanlder(PhysicsObject projectile, PhysicsObject target) //ToDo: Set collisions 
    7875    { 
    79         if (target is Zombie1) 
     76        if (target is Zombie) 
    8077        { 
    8178            if (weapon is Cannon) 
    8279            { 
    83                 ((Zombie1)target).Healt(-100); 
     80                ((Zombie)target).Health(-100); 
    8481            } 
    8582            else if (weapon is PlasmaCannon) 
    8683            { 
    87                 ((Zombie1)target).Healt(-50); 
     84                ((Zombie)target).Health(-50); 
    8885            } 
    8986        } 
  • 2013/27/TeemuM/Game/Game/GameContent/obj/x86/Debug/ContentPipeline.xml

    r4381 r4420  
    88      <Processor>TextureProcessor</Processor> 
    99      <Options>None</Options> 
    10       <Output>C:\Users\Teemu\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Player.xnb</Output> 
    11       <Time>2013-07-03T09:02:56.8403928+03:00</Time> 
     10      <Output>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Player.xnb</Output> 
     11      <Time>2013-07-02T22:31:25.0744006+03:00</Time> 
    1212    </Item> 
    1313    <Item> 
     
    1717      <Processor>TextureProcessor</Processor> 
    1818      <Options>None</Options> 
    19       <Output>C:\Users\Teemu\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie1.xnb</Output> 
    20       <Time>2013-07-03T09:02:57.1104083+03:00</Time> 
     19      <Output>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie1.xnb</Output> 
     20      <Time>2013-07-02T22:59:50.6059514+03:00</Time> 
    2121    </Item> 
    2222    <Item> 
     
    2626      <Processor>TextureProcessor</Processor> 
    2727      <Options>None</Options> 
    28       <Output>C:\Users\Teemu\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie2.xnb</Output> 
    29       <Time>2013-07-03T09:02:57.14041+03:00</Time> 
     28      <Output>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie2.xnb</Output> 
     29      <Time>2013-07-02T22:59:50.5969509+03:00</Time> 
    3030    </Item> 
    3131    <Item> 
     
    3535      <Processor>TextureProcessor</Processor> 
    3636      <Options>None</Options> 
    37       <Output>C:\Users\Teemu\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie3.xnb</Output> 
    38       <Time>2013-07-03T09:02:57.3124198+03:00</Time> 
     37      <Output>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie3.xnb</Output> 
     38      <Time>2013-07-02T22:59:50.6009511+03:00</Time> 
    3939    </Item> 
    4040    <Item> 
     
    4444      <Processor>TextureProcessor</Processor> 
    4545      <Options>None</Options> 
    46       <Output>C:\Users\Teemu\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie4.xnb</Output> 
    47       <Time>2013-07-03T09:02:57.3194202+03:00</Time> 
     46      <Output>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie4.xnb</Output> 
     47      <Time>2013-07-02T22:59:50.6029512+03:00</Time> 
    4848    </Item> 
    4949    <BuildSuccessful>true</BuildSuccessful> 
     
    5353      <BuildConfiguration>Debug</BuildConfiguration> 
    5454      <CompressContent>false</CompressContent> 
    55       <RootDirectory>C:\Users\Teemu\Desktop\TeemuM\Game\Game\GameContent\</RootDirectory> 
    56       <LoggerRootDirectory>C:\Users\Teemu\Desktop\TeemuM\Game\Game\Game\</LoggerRootDirectory> 
    57       <IntermediateDirectory>C:\Users\Teemu\Desktop\TeemuM\Game\Game\GameContent\obj\x86\Debug\</IntermediateDirectory> 
    58       <OutputDirectory>C:\Users\Teemu\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\</OutputDirectory> 
     55      <RootDirectory>C:\Users\Juho\Desktop\TeemuM\Game\Game\GameContent\</RootDirectory> 
     56      <LoggerRootDirectory>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\</LoggerRootDirectory> 
     57      <IntermediateDirectory>C:\Users\Juho\Desktop\TeemuM\Game\Game\GameContent\obj\x86\Debug\</IntermediateDirectory> 
     58      <OutputDirectory>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\</OutputDirectory> 
    5959    </Settings> 
    6060    <Assemblies> 
    6161      <Assembly> 
    6262        <Key>C:\Program Files (x86)\Jypeli\lib\ContentExtensions\TextFileContentExtension.dll</Key> 
    63         <Value>2013-06-27T12:29:42+03:00</Value> 
     63        <Value>2013-01-29T09:47:36+02:00</Value> 
    6464      </Assembly> 
    6565      <Assembly> 
    6666        <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll</Key> 
    67         <Value>2010-08-23T13:41:18+03:00</Value> 
     67        <Value>2010-08-23T12:41:18+03:00</Value> 
    6868      </Assembly> 
    6969      <Assembly> 
    7070        <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.VideoImporters.dll</Key> 
    71         <Value>2010-08-23T13:41:18+03:00</Value> 
     71        <Value>2010-08-23T12:41:18+03:00</Value> 
    7272      </Assembly> 
    7373      <Assembly> 
    7474        <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll</Key> 
    75         <Value>2010-08-23T13:41:18+03:00</Value> 
     75        <Value>2010-08-23T12:41:18+03:00</Value> 
    7676      </Assembly> 
    7777      <Assembly> 
    7878        <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll</Key> 
    79         <Value>2010-08-23T13:41:18+03:00</Value> 
     79        <Value>2010-08-23T12:41:18+03:00</Value> 
    8080      </Assembly> 
    8181      <Assembly> 
    8282        <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll</Key> 
    83         <Value>2010-08-23T13:41:18+03:00</Value> 
     83        <Value>2010-08-23T12:41:18+03:00</Value> 
    8484      </Assembly> 
    8585      <Assembly> 
    8686        <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.AudioImporters.dll</Key> 
    87         <Value>2010-08-23T13:41:18+03:00</Value> 
     87        <Value>2010-08-23T12:41:18+03:00</Value> 
    8888      </Assembly> 
    8989      <Assembly> 
    9090        <Key>C:\Program Files (x86)\Jypeli\lib\ContentExtensions\AnimationExtension.dll</Key> 
    91         <Value>2013-06-27T12:29:42+03:00</Value> 
     91        <Value>2013-01-29T09:47:38+02:00</Value> 
    9292      </Assembly> 
    9393      <Assembly> 
    94         <Key>C:\windows\Microsoft.Net\assembly\GAC_32\Microsoft.Xna.Framework.Content.Pipeline\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Content.Pipeline.dll</Key> 
    95         <Value>2012-01-13T20:50:30.8026955+02:00</Value> 
     94        <Key>C:\Windows\Microsoft.Net\assembly\GAC_32\Microsoft.Xna.Framework.Content.Pipeline\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Content.Pipeline.dll</Key> 
     95        <Value>2011-06-27T18:29:19.4335733+03:00</Value> 
    9696      </Assembly> 
    9797    </Assemblies> 
Note: See TracChangeset for help on using the changeset viewer.