Changeset 3819 for 2012/30


Ignore:
Timestamp:
2012-07-27 12:51:21 (11 years ago)
Author:
otelretu
Message:

Talletus.

Location:
2012/30/OtsoR/Projekti
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • 2012/30/OtsoR/Projekti/Projekti/Projekti/Projekti.cs

    r3783 r3819  
    1414 
    1515    String[] weaponnames = { "projectile","laser","plasma" }; 
     16 
     17    PhysicsObject topedge; 
     18    PhysicsObject bottomedge; 
     19    PhysicsObject leftedge; 
     20    PhysicsObject rightedge; 
    1621     
    1722    PhysicsObject ship; 
     
    1924    PhysicsObject ship2; 
    2025    Weapon weapon2; 
    21  
    2226    PhysicsObject hostile; 
    2327    Weapon hostilew; 
     
    3539    IntMeter shipcolor2; 
    3640    IntMeter shipwpn2; 
     41    int shipcounter; 
    3742    public override void Begin() 
    3843    { 
     
    4146            shipimages[i-1] = LoadImage("s"+i); 
    4247        } 
    43  
    4448        IsMouseVisible = true; 
    4549        MultiSelectWindow numberofplayersmenu = new MultiSelectWindow("Select number of players", "1 Player", "2 Players", "Quit"); 
     
    5458                ClearAll(); 
    5559                singleplayer(); 
    56                  
    5760                break; 
    5861            case 1: 
     
    144147        choice(shipwpn.Value); 
    145148        ship.Add(weapon); 
     149        ship.CollisionIgnoreGroup = 1; 
    146150    } 
    147151    void Createship2() 
     
    157161        choice2(shipwpn2.Value); 
    158162        ship2.Add(weapon2); 
    159     } 
    160     void Createhostile() 
    161     { 
    162         hostile = new PhysicsObject(16, 16, Shape.FromImage(Aluskuva.Image)); 
    163         hostile.Image = Aluskuva.Image; 
    164         hostile.Y = 100; 
     163        ship2.CollisionIgnoreGroup = 1; 
     164    } 
     165    void Spawnhostiles() 
     166    { 
     167        int shipcounter = 0; 
     168 
     169        while (shipcounter < 5) 
     170        { 
     171        int hostileship = RandomGen.NextInt(0, 100); 
     172        double hostiley = 0.0; 
     173        double hostilex = 0.0; 
     174        if (RandomGen.NextBool()) 
     175        { 
     176            hostiley = Level.Bottom + 2 * Level.Top * RandomGen.NextInt(0, 2); 
     177            hostilex = RandomGen.NextDouble(Level.Left, Level.Right); 
     178        } 
     179        else 
     180        { 
     181            hostiley = RandomGen.NextDouble(Level.Bottom, Level.Top); 
     182            hostilex = Level.Left + 2 * Level.Right * RandomGen.NextInt(0, 2); 
     183 
     184        } 
     185        Createhostile(hostileship, hostiley, hostilex); 
     186        shipcounter++; 
     187        } 
     188    } 
     189    void Createhostile(int randomship, double randomy, double randomx) 
     190    { 
     191        hostile = new PhysicsObject(16, 16, Shape.FromImage(shipimages[randomship])); 
     192        hostile.Image = shipimages[randomship]; 
     193        hostile.Y = randomy; 
     194        hostile.X = randomx; 
    165195        hostile.Restitution = 1.0; 
    166196        hostile.KineticFriction = 0.0; 
     
    168198        hostile.LinearDamping = 0.95; 
    169199        hostile.AngularDamping = 1; 
     200        hostile.Tag = "hostile"; 
    170201        Add(hostile); 
    171         hostilew = new AssaultRifle(0, 0); 
     202        hostile.CollisionIgnoreGroup = 2; 
     203        hostile.Image.ReplaceColor(Color.White, Color.Ultramarine); 
     204        hostile.Image.ReplaceColor(Color.Black, Color.Emerald); 
     205 
     206        AssaultRifle hostilew = new AssaultRifle(0, 0); 
    172207        hostilew.ProjectileCollision = weaponhit; 
     208        hostilew.FireRate = 0.5; 
    173209        hostile.Add(hostilew); 
    174210 
    175         RandomMoverBrain RandomAivot = new RandomMoverBrain(10); 
    176         RandomAivot.ChangeMovementSeconds = 3; 
    177         RandomAivot.TurnWhileMoving = true; 
    178  
    179         FollowerBrain SeuraavatAivot = new FollowerBrain(ship, ship2); 
    180         SeuraavatAivot.Speed = 10; 
    181         SeuraavatAivot.DistanceFar = 10000; 
    182         SeuraavatAivot.DistanceClose = 300; 
    183         SeuraavatAivot.StopWhenTargetClose = false; 
    184         SeuraavatAivot.FarBrain = RandomAivot; 
    185         SeuraavatAivot.TargetClose += delegate { firehostile(hostilew); }; 
    186         SeuraavatAivot.TurnWhileMoving = true; 
    187         hostile.Brain = SeuraavatAivot; 
    188     } 
    189     void firehostile(Weapon weapon) 
    190     { 
    191         fire(weapon); 
     211        FollowerBrain brain = new FollowerBrain(ship, ship2); 
     212        brain.Speed = 20; 
     213        brain.DistanceFar = 10000; 
     214        brain.DistanceClose = 200; 
     215        brain.StopWhenTargetClose = false; 
     216        brain.TargetClose += delegate { fire(hostilew); }; 
     217        brain.TurnWhileMoving = true; 
     218        hostile.Brain = brain; 
     219    } 
     220    void createedges() 
     221    { 
     222        PhysicsObject leftedge = Level.CreateLeftBorder(); 
     223        leftedge.Restitution = 1.0; 
     224        leftedge.KineticFriction = 0.0; 
     225        leftedge.IsVisible = false; 
     226        leftedge.CollisionIgnoreGroup = 2; 
     227        PhysicsObject rightedge = Level.CreateRightBorder(); 
     228        rightedge.Restitution = 1.0; 
     229        rightedge.KineticFriction = 0.0; 
     230        rightedge.IsVisible = false; 
     231        rightedge.CollisionIgnoreGroup = 2; 
     232        PhysicsObject topedge = Level.CreateTopBorder(); 
     233        topedge.Restitution = 1.0; 
     234        topedge.KineticFriction = 0.0; 
     235        topedge.IsVisible = false; 
     236        topedge.CollisionIgnoreGroup = 2; 
     237        PhysicsObject bottomedge = Level.CreateBottomBorder(); 
     238        bottomedge.Restitution = 1.0; 
     239        bottomedge.IsVisible = false; 
     240        bottomedge.KineticFriction = 0.0; 
     241        topedge.CollisionIgnoreGroup = 2; 
    192242    } 
    193243    void coop() 
     
    291341                weapon = new AssaultRifle(0, 0); 
    292342                weapon.ProjectileCollision = weaponhit; 
     343                weapon.FireRate = 4; 
    293344                break; 
    294345            case 2: 
    295346                weapon = new LaserGun(0, 0); 
    296347                weapon.ProjectileCollision = weaponhit; 
    297                 weapon.Power.Value = 5000; 
    298                 weapon.FireRate = 1.0; 
     348                weapon.FireRate = 0.5; 
    299349                break; 
    300350            case 3: 
    301351                weapon = new PlasmaCannon(0, 0); 
    302352                weapon.ProjectileCollision = weaponhit; 
     353                weapon.FireRate = 2; 
    303354                break; 
    304355        } 
     
    311362                weapon2 = new AssaultRifle(0, 0); 
    312363                weapon2.ProjectileCollision = weaponhit; 
     364                weapon2.FireRate = 4; 
    313365                break; 
    314366            case 2: 
    315367                weapon2 = new LaserGun(0, 0); 
    316368                weapon2.ProjectileCollision = weaponhit; 
    317                 weapon2.Power.Value = 5000; 
    318                 weapon2.FireRate = 1.0; 
     369                weapon2.FireRate = 0.5; 
    319370                break; 
    320371            case 3: 
    321372                weapon2 = new PlasmaCannon(0, 0); 
    322373                weapon2.ProjectileCollision = weaponhit; 
     374                weapon2.FireRate = 2; 
    323375                break; 
    324376        } 
     
    327379    { 
    328380        PhysicsObject ammus = ase.Shoot(); 
    329          
     381 
     382 
    330383        if (ammus != null) 
    331384        { 
     385             //Add(ammus, 2); 
    332386            //ammus.Size *= 3; 
    333387            //ammus.Image =  
     
    335389        } 
    336390    } 
     391 
    337392    void weaponhit(PhysicsObject ammus, PhysicsObject kohde) 
    338393    { 
     394        if (kohde.Tag == "hostile") kohde.Destroy(); 
    339395        ammus.Destroy(); 
    340396    } 
    341     void AsetaOhjaimet() 
     397 
     398    void Controlsship1() 
    342399    { 
    343400        Keyboard.Listen(Key.W, ButtonState.Down, thrust, "", 1.0, ship); 
     
    345402        Keyboard.Listen(Key.A, ButtonState.Down, tilt, "", 1.0, ship); 
    346403        Keyboard.Listen(Key.D, ButtonState.Down, tilt, "", -1.0, ship); 
    347         Keyboard.Listen(Key.Space, ButtonState.Down, fire, "", weapon); 
    348  
     404        Keyboard.Listen(Key.F, ButtonState.Down, fire, "", weapon); 
    349405        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    350  
     406    } 
     407    void Controlsship2() 
     408    { 
    351409        Keyboard.Listen(Key.NumPad8, ButtonState.Down, thrust, "", 1.0, ship2); 
    352410        Keyboard.Listen(Key.NumPad5, ButtonState.Down, thrust, "", -1.0, ship2); 
    353411        Keyboard.Listen(Key.NumPad4, ButtonState.Down, tilt, "", 1.0, ship2); 
    354412        Keyboard.Listen(Key.NumPad6, ButtonState.Down, tilt, "", -1.0, ship2); 
    355         Keyboard.Listen(Key.Space, ButtonState.Down, fire, "", weapon2); 
     413        Keyboard.Listen(Key.Add, ButtonState.Down, fire, "", weapon2); 
    356414    } 
    357415    void thrust(double direction, PhysicsObject ship) 
     
    371429        Camera.ZoomToLevel(); 
    372430        Createship(); 
    373         AsetaOhjaimet(); 
     431        Controlsship1(); 
    374432    } 
    375433    void coopbase() 
     
    381439        Createship(); 
    382440        Createship2(); 
    383         Createhostile(); 
    384         AsetaOhjaimet(); 
     441        Spawnhostiles(); 
     442        Controlsship1(); 
     443        Controlsship2(); 
     444 
     445        Timer a = new Timer(); 
     446        a.Interval = 5; 
     447        a.Timeout += Spawnhostiles; 
     448        a.Start(); 
    385449    } 
    386450} 
  • 2012/30/OtsoR/Projekti/Projekti/Projekti/Projekti.csproj.Debug.cachefile

    r3779 r3819  
    9999Content\s98.xnb 
    100100Content\s99.xnb 
     101Content\s101.xnb 
     102Content\bullet.xnb 
  • 2012/30/OtsoR/Projekti/Projekti/Projekti/obj/x86/Debug/Projekti.csproj.FileListAbsolute.txt

    r3783 r3819  
    107107C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\s98.xnb 
    108108C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\s99.xnb 
     109C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\bullet.xnb 
  • 2012/30/OtsoR/Projekti/Projekti/Projekti/obj/x86/Debug/cachefile-{97999162-0C3B-480A-AB91-BD553A4EB51F}-targetpath.txt

    r3779 r3819  
    9999Content\s98.xnb 
    100100Content\s99.xnb 
     101Content\bullet.xnb 
  • 2012/30/OtsoR/Projekti/Projekti/ProjektiContent/ProjektiContent.contentproj

    r3764 r3819  
    546546    </Compile> 
    547547  </ItemGroup> 
     548  <ItemGroup> 
     549    <Compile Include="bullet.png"> 
     550      <Name>bullet</Name> 
     551      <Importer>TextureImporter</Importer> 
     552      <Processor>TextureProcessor</Processor> 
     553    </Compile> 
     554  </ItemGroup> 
    548555  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    549556  <!--  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.