Changeset 4278 for 2013/26


Ignore:
Timestamp:
2013-06-27 15:00:58 (10 years ago)
Author:
juiitamm
Message:
 
Location:
2013/26/OtsoR/Projekti/Projekti
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 2013/26/OtsoR/Projekti/Projekti/Projekti/Projekti.cs

    r4250 r4278  
    66using Jypeli.Effects; 
    77using Jypeli.Widgets; 
    8 class Player : PhysicsObject 
     8 
     9public class Player : PhysicsObject 
    910{ 
    1011    private IntMeter health = new IntMeter(100, 0, 100); 
    1112    public IntMeter Health { get { return health; } } 
     13    public Color Color1; 
     14    public Color Color2; 
     15 
     16    public Image cannonImage; 
    1217 
    1318    public Player(double width, double height, Shape shape) 
     
    3136    private IntMeter health = new IntMeter(5, 0, 5); 
    3237    public IntMeter Health { get { return health; } } 
    33      
     38 
    3439    public Enemy(double leveys, double korkeus, Shape muoto) 
    3540        : base(leveys, korkeus, muoto) 
     
    4045        enemyhealth.Angle = Angle.RightAngle; 
    4146        Add(enemyhealth); 
    42         health.LowerLimit += delegate { 
     47        health.LowerLimit += delegate 
     48        { 
    4349            this.Destroy(); 
    4450        }; 
    4551    } 
    4652} 
    47 class Boss : PhysicsObject 
     53class BigEnemy : PhysicsObject 
    4854{ 
    4955    private IntMeter health = new IntMeter(100, 0, 100); 
    5056    public IntMeter Health { get { return health; } } 
    5157 
    52     public Boss(double leveys, double korkeus, Shape muoto) 
     58    public BigEnemy(double leveys, double korkeus, Shape muoto) 
    5359        : base(leveys, korkeus, muoto) 
    5460    { 
     
    5864        enemyhealth.Angle = Angle.RightAngle; 
    5965        Add(enemyhealth); 
    60         health.LowerLimit += delegate { 
     66        health.LowerLimit += delegate 
     67        { 
    6168            this.Destroy(); 
    6269        }; 
     
    6673{ 
    6774    Image[] shipimages = new Image[100]; 
    68     Color[] shipcolors = { Color.DarkGray, Color.Silver, Color.DarkOrange, Color.Ultramarine }; 
    69     Color[] shipcolors2 = { Color.Ruby, Color.Azure, Color.Emerald, Color.Emerald }; 
    70     Image miniboss = LoadImage("miniboss"); 
     75    Color[] shipcolors = { Color.DarkGray, Color.Silver, Color.DarkOrange, Color.Blue }; 
     76    Color[] shipcolors2 = { Color.Ruby, Color.Azure, Color.Emerald, Color.Orange }; 
     77    Image bigenemy = LoadImage("bigenemy"); 
    7178    Image shell = LoadImage("bullet"); 
    7279    Image pointer = LoadImage("pointer"); 
    7380    Image rdamage = LoadImage("rdamage"); 
    7481    Image rrepair = LoadImage("rrepair"); 
    75  
    76     String[] weaponnames = { "projectile","laser","plasma" }; 
     82    Image homing = LoadImage("missile"); 
     83 
     84    String[] weaponnames = { "projectile", "laser", "plasma", "missile" }; 
    7785 
    7886    PhysicsObject topedge; 
     
    8088    PhysicsObject leftedge; 
    8189    PhysicsObject rightedge; 
    82      
    83     Player ship; 
     90 
     91    Player ship1; 
    8492    Weapon weapon; 
    8593    Player ship2; 
     
    8896    Weapon hostilew; 
    8997    GameObject line; 
     98    PhysicsObject ammus; 
    9099 
    91100    Label number; 
     
    94103    Label weaponlabel; 
    95104    Label weaponlabel2; 
    96     Widget Aluskuva; 
    97     Widget Aluskuva2; 
     105    Widget aluskuva; 
     106    Widget aluskuva2; 
    98107    IntMeter shipimg; 
    99     IntMeter shipcolor; 
     108    IntMeter shipcolor1; 
    100109    IntMeter shipwpn; 
    101110    IntMeter shipimg2; 
    102111    IntMeter shipcolor2; 
    103     IntMeter shipwpn2; 
     112    IntMeter shipWeapon2; 
    104113    int shipcounter; 
    105114    int bigshipcounter; 
     
    110119        for (int i = 1; i <= 100; i++) 
    111120        { 
    112             shipimages[i-1] = LoadImage("s"+i); 
     121            shipimages[i - 1] = LoadImage("s" + i); 
    113122        } 
    114123        IsMouseVisible = true; 
     
    134143        } 
    135144    } 
     145 
    136146    void singleplayer() 
    137147    { 
    138         Aluskuva = new Widget(50, 50); 
    139         Aluskuva.X = 0; 
    140         Aluskuva.Y = 250; 
    141         Aluskuva.Image = shipimages[0]; 
    142         Add(Aluskuva); 
     148        aluskuva = new Widget(50, 50); 
     149        aluskuva.X = 0; 
     150        aluskuva.Y = 250; 
     151        aluskuva.Image = shipimages[0]; 
     152        Add(aluskuva); 
    143153 
    144154        shipimg = new IntMeter(1, 1, 100); 
    145         shipimg.Changed += Changeship; 
    146         shipwpn = new IntMeter(1, 1, 3); 
     155        shipimg.Changed += Changeship1; 
     156        shipwpn = new IntMeter(1, 1, 4); 
    147157        shipwpn.Changed += delegate { weaponlabel.Text = weaponnames[shipwpn.Value - 1]; }; 
    148         shipcolor = new IntMeter(1, 1, 4); 
    149         shipcolor.Changed += Changeship; 
     158        shipcolor1 = new IntMeter(0, 0, 3); 
     159        shipcolor1.Changed += Changeship1; 
    150160 
    151161        number = new Label(); 
     
    172182        shipcolour.X = -125; 
    173183        shipcolour.Y = 150; 
    174         shipcolour.BindTo(shipcolor); 
     184        shipcolour.BindTo(shipcolor1); 
    175185        Slider shipweapon = new Slider(125, 15); 
    176186        shipweapon.X = 125; 
     
    194204        Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, singleplayerbase, null); 
    195205    } 
    196     void Changeship(int vanha, int uusi) 
    197     { 
    198         Aluskuva.Image = shipimages[shipimg.Value-1].Clone(); 
    199         Aluskuva.Image.ReplaceColor(Color.White, shipcolors[shipcolor.Value - 1]); 
    200         Aluskuva.Image.ReplaceColor(Color.Black, shipcolors2[shipcolor.Value - 1]); 
     206 
     207    void Changeship1(int vanha, int uusi) 
     208    { 
     209        aluskuva.Image = shipimages[shipimg.Value - 1].Clone(); 
     210        aluskuva.Image.ReplaceColor(Color.White, shipcolors[shipcolor1.Value]); 
     211        aluskuva.Image.ReplaceColor(Color.Black, shipcolors2[shipcolor1.Value]); 
    201212    } 
    202213    void Changeship2(int vanha, int uusi) 
    203214    { 
    204         Aluskuva2.Image = shipimages[shipimg2.Value - 1].Clone(); 
    205         Aluskuva2.Image.ReplaceColor(Color.White, shipcolors[shipcolor2.Value - 1]); 
    206         Aluskuva2.Image.ReplaceColor(Color.Black, shipcolors2[shipcolor2.Value - 1]); 
    207     } 
     215        aluskuva2.Image = shipimages[shipimg2.Value - 1].Clone(); 
     216        aluskuva2.Image.ReplaceColor(Color.White, shipcolors[shipcolor2.Value]); 
     217        aluskuva2.Image.ReplaceColor(Color.Black, shipcolors2[shipcolor2.Value]); 
     218    } 
     219 
    208220    void Createship(double x, double y) 
    209221    { 
    210         ship = new Player(16, 16, Shape.FromImage(Aluskuva.Image)); 
    211         ship.Image = Aluskuva.Image; 
    212         ship.Restitution = 1.0; 
    213         ship.X = x; 
    214         ship.Y = y; 
    215         ship.KineticFriction = 0.0; 
    216         ship.MomentOfInertia = Double.PositiveInfinity; 
    217         ship.LinearDamping = 0.95; 
    218         ship.AngularDamping = 0.95; 
    219         Add(ship); 
     222        ship1 = new Player(14, 14, Shape.FromImage(aluskuva.Image)); 
     223        ship1.Image = aluskuva.Image; 
     224 
     225        ship1.Restitution = 1.0; 
     226        ship1.Color1 = shipcolors[shipcolor1.Value]; 
     227        ship1.Color2 = shipcolors2[shipcolor1.Value]; 
     228        ship1.cannonImage = LoadImage("missile"); 
     229        ship1.cannonImage.ReplaceColor(Color.White, ship1.Color1); 
     230        ship1.cannonImage.ReplaceColor(Color.Black, ship1.Color2); 
     231 
     232        ship1.X = x; 
     233        ship1.Y = y; 
     234        ship1.KineticFriction = 0.0; 
     235        ship1.MomentOfInertia = Double.PositiveInfinity; 
     236        ship1.LinearDamping = 0.95; 
     237        ship1.AngularDamping = 0.95; 
     238        Add(ship1); 
    220239        choice(shipwpn.Value); 
    221         ship.Add(weapon); 
    222         ship.CollisionIgnoreGroup = 1; 
    223         ship.Tag = "player"; 
    224         ship.Destroyed += playerdeath; 
     240        ship1.Add(weapon); 
     241        ship1.CollisionIgnoreGroup = 1; 
     242        ship1.Tag = "player"; 
     243        ship1.Destroyed += playerdeath; 
    225244        if (weapon is LaserGun) 
    226245        { 
     
    228247            line.Image = pointer; 
    229248            line.X = 2500; 
    230             ship.Add(line); 
     249            ship1.Add(line); 
    231250        } 
    232251    } 
    233252    void Createship2(double x, double y) 
    234253    { 
    235         ship2 = new Player(16, 16, Shape.FromImage(Aluskuva2.Image)); 
    236         ship2.Image = Aluskuva2.Image; 
     254        ship2 = new Player(14, 14, Shape.FromImage(aluskuva2.Image)); 
     255        ship2.Image = aluskuva2.Image; 
    237256        ship2.X = x; 
    238257        ship2.Y = y; 
     258        ship2.Color1 = shipcolors[shipcolor2.Value]; 
     259        ship2.Color2 = shipcolors2[shipcolor2.Value]; 
     260        ship2.cannonImage = LoadImage("missile"); 
     261        ship2.cannonImage.ReplaceColor(Color.White, ship2.Color1); 
     262        ship2.cannonImage.ReplaceColor(Color.Black, ship2.Color2); 
     263 
    239264        ship2.Restitution = 1.0; 
    240265        ship2.KineticFriction = 0.0; 
     
    243268        ship2.AngularDamping = 0.95; 
    244269        Add(ship2); 
    245         choice2(shipwpn2.Value); 
     270        choice2(shipWeapon2.Value); 
    246271        ship2.Add(weapon2); 
    247272        ship2.CollisionIgnoreGroup = 1; 
     
    253278            line.Image = pointer; 
    254279            line.X = 2500; 
    255             ship.Add(line); 
     280            ship1.Add(line); 
    256281        } 
    257282    } 
    258283    void Spawnhostiles() 
    259284    { 
    260         while (shipcounter < 36) 
     285        while (shipcounter < 39) 
    261286        { 
    262287        int hostileship = RandomGen.NextInt(0, 100); 
     
    296321    void Createhostile(int randomship, double randomy, double randomx) 
    297322    { 
    298         Enemy hostile = new Enemy(16, 16, Shape.FromImage(shipimages[randomship])); 
     323        Enemy hostile = new Enemy(14, 14, Shape.FromImage(shipimages[randomship])); 
    299324        hostile.Image = shipimages[randomship]; 
    300325        hostile.Y = randomy; 
     
    318343        hostilew.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 10, 0); }; 
    319344        hostilew.FireRate = 0.5; 
    320         hostilew.Power.DefaultValue = 20; 
    321         hostilew.Power.Value = 20; 
     345        hostilew.Power.DefaultValue = 15; 
     346        hostilew.Power.Value = 15; 
    322347        hostile.Add(hostilew); 
    323348 
     
    327352        brain.DistanceClose = 125; 
    328353        brain.StopWhenTargetClose = false; 
    329         brain.TargetClose += delegate { fire(hostilew); }; 
     354        brain.TargetClose += delegate { fire(hostilew, null); }; 
    330355        brain.TurnWhileMoving = true; 
    331356        hostile.Brain = brain; 
     
    333358    void Createbighostile(double y, double x) 
    334359    { 
    335         Enemy Big1 = new Enemy(25, 29, Shape.FromImage(miniboss)); 
    336         Big1.Image = miniboss; 
     360        Enemy Big1 = new Enemy(50, 28, Shape.FromImage(bigenemy)); 
     361        Big1.Image = bigenemy; 
    337362        Big1.X = x; 
    338363        Big1.Y = y; 
     
    351376        Big1.Destroyed += bigenemydeath; 
    352377 
    353         PlasmaCannon Big1w = new PlasmaCannon(0, 0); 
     378        Cannon Big1w = new Cannon(0, 0); 
    354379        Big1w.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 3, 0); }; 
    355         Big1w.FireRate = 1.5; 
    356         Big1w.Power.DefaultValue = 300; 
    357         Big1w.Power.Value = 300; 
     380        Big1w.FireRate = 0.3; 
     381        Big1w.CanHitOwner = false; 
     382        Big1w.Power.DefaultValue = 1500; 
     383        Big1w.Power.Value = 1500; 
    358384        Big1.Add(Big1w); 
    359385 
    360         FollowerBrain bigbrain1 = new FollowerBrain("player"); 
    361         bigbrain1.Speed = 15; 
    362         bigbrain1.DistanceFar = 10000; 
    363         bigbrain1.DistanceClose = 200; 
    364         bigbrain1.TurnSpeed = UnlimitedAngle.FromDegrees(10); 
    365         bigbrain1.StopWhenTargetClose = false; 
    366         bigbrain1.TargetClose += delegate { fire(Big1w); }; 
    367         bigbrain1.TurnWhileMoving = true; 
    368         Big1.Brain = bigbrain1; 
     386        FollowerBrain bigbrain = new FollowerBrain("player"); 
     387        bigbrain.Speed = 15; 
     388        bigbrain.DistanceFar = 10000; 
     389        bigbrain.DistanceClose = 325; 
     390        bigbrain.TurnSpeed = UnlimitedAngle.FromDegrees(25); 
     391        bigbrain.StopWhenTargetClose = false; 
     392        bigbrain.TargetClose += delegate { firehoming(Big1w); }; 
     393        bigbrain.TurnWhileMoving = true; 
     394        Big1.Brain = bigbrain; 
    369395    } 
    370396    void playerdeath() 
    371397    { 
    372         MessageDisplay.Add("A player's ship has been destroyed"); 
     398        MessageDisplay.Add("Ship lost"); 
    373399        //MediaPlayer.Play("playerdeath"); 
    374400    } 
     
    412438    void coop() 
    413439    { 
    414         Aluskuva = new Widget(50, 50); 
    415         Aluskuva.X = -300; 
    416         Aluskuva.Y = 250; 
    417         Aluskuva.Image = shipimages[0]; 
    418         Add(Aluskuva); 
    419  
    420         Aluskuva2 = new Widget(50, 50); 
    421         Aluskuva2.X = 300; 
    422         Aluskuva2.Y = 250; 
    423         Aluskuva2.Image = shipimages[0]; 
    424         Add(Aluskuva2); 
     440        aluskuva = new Widget(50, 50); 
     441        aluskuva.X = -300; 
     442        aluskuva.Y = 250; 
     443        aluskuva.Image = shipimages[0]; 
     444        Add(aluskuva); 
     445 
     446        aluskuva2 = new Widget(50, 50); 
     447        aluskuva2.X = 300; 
     448        aluskuva2.Y = 250; 
     449        aluskuva2.Image = shipimages[0]; 
     450        Add(aluskuva2); 
    425451 
    426452        shipimg = new IntMeter(1, 1, 100); 
    427         shipimg.Changed += Changeship; 
    428         shipwpn = new IntMeter(1, 1, 3); 
     453        shipimg.Changed += Changeship1; 
     454        shipwpn = new IntMeter(1, 1, 4); 
    429455        shipwpn.Changed += delegate { weaponlabel.Text = weaponnames[shipwpn.Value - 1]; }; 
    430         shipcolor = new IntMeter(1, 1, 4); 
    431         shipcolor.Changed += Changeship; 
     456 
     457        Slider shipColorP1 = new Slider(125, 15); 
     458        shipColorP1.X = -425; 
     459        shipColorP1.Y = 150; 
     460        shipcolor1 = new IntMeter(0, 0, 3); 
     461        shipcolor1.Changed += Changeship1; 
     462        shipColorP1.BindTo(shipcolor1); 
     463 
     464        Slider shipcolour2 = new Slider(125, 15); 
     465        shipcolour2.X = 225; 
     466        shipcolour2.Y = 150; 
     467        shipcolor2 = new IntMeter(0, 0, 3); 
     468        shipcolor2.Changed += Changeship2; 
     469        shipcolour2.BindTo(shipcolor2);  
     470                 
    432471        shipimg2 = new IntMeter(1, 1, 100); 
    433472        shipimg2.Changed += Changeship2; 
    434         shipwpn2 = new IntMeter(1, 1, 3); 
    435         shipwpn2.Changed += delegate { weaponlabel2.Text = weaponnames[shipwpn2.Value - 1]; }; 
    436         shipcolor2 = new IntMeter(1, 1, 4); 
    437         shipcolor2.Changed += Changeship2; 
    438  
     473        shipWeapon2 = new IntMeter(1, 1, 4); 
     474        shipWeapon2.Changed += delegate 
     475        { 
     476            weaponlabel2.Text = weaponnames[shipWeapon2.Value - 1]; 
     477        }; 
    439478        number = new Label(); 
    440479        number.BindTo(shipimg); 
     
    462501        shiptype.Y = 200; 
    463502        shiptype.BindTo(shipimg); 
    464         Slider shipcolour = new Slider(125, 15); 
    465         shipcolour.X = -425; 
    466         shipcolour.Y = 150; 
    467         shipcolour.BindTo(shipcolor); 
     503         
    468504        Slider shipweapon = new Slider(125, 15); 
    469505        shipweapon.X = -225; 
     
    475511        shiptype2.Y = 200; 
    476512        shiptype2.BindTo(shipimg2); 
    477         Slider shipcolour2 = new Slider(125, 15); 
    478         shipcolour2.X = 225; 
    479         shipcolour2.Y = 150; 
    480         shipcolour2.BindTo(shipcolor2); 
     513         
    481514        Slider shipweapon2 = new Slider(125, 15); 
    482515        shipweapon2.X = 425; 
    483516        shipweapon2.Y = 150; 
    484         shipweapon2.BindTo(shipwpn2); 
     517        shipweapon2.BindTo(shipWeapon2); 
    485518        Add(shiptype); 
    486         Add(shipcolour); 
     519        Add(shipColorP1); 
    487520        Add(shipweapon); 
    488521        Add(shiptype2); 
     
    497530        foreach (Label valikonKohta2 in valikonKohdat2) 
    498531        { 
    499            Add(valikonKohta2); 
     532            Add(valikonKohta2); 
    500533        } 
    501534        Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, coopbase, null); 
     
    509542                weapon.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 1); }; 
    510543                weapon.FireRate = 4.5; 
    511                 weapon.Power.Value = 100; 
    512                 weapon.Power.DefaultValue = 100; 
     544                weapon.Power.Value = 25; 
     545                weapon.Power.DefaultValue = 25; 
    513546                break; 
    514547            case 2: 
     
    516549                weapon.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 5); }; 
    517550                weapon.FireRate = 0.8; 
    518                 weapon.Power.DefaultValue = 1000; 
    519                 weapon.Power.Value = 1000; 
     551                weapon.Power.DefaultValue = 100; 
     552                weapon.Power.Value = 100; 
    520553                break; 
    521554            case 3: 
     
    523556                weapon.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 3); }; 
    524557                weapon.FireRate = 1.5; 
    525                 weapon.Power.Value = 750; 
    526                 weapon.Power.DefaultValue = 750; 
     558                weapon.Power.Value = 400; 
     559                weapon.Power.DefaultValue = 400; 
     560                break; 
     561            case 4: 
     562                weapon = new Cannon(0, 0); 
     563                weapon.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 5); }; 
     564                weapon.FireRate = 0.8; 
     565                weapon.Power.DefaultValue = 1500; 
     566                weapon.Power.Value = 1500; 
    527567                break; 
    528568        } 
     
    536576                weapon2.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 1); }; 
    537577                weapon2.FireRate = 4.5; 
    538                 weapon2.Power.Value = 100; 
    539                 weapon2.Power.DefaultValue = 100; 
     578                weapon2.Power.Value = 25; 
     579                weapon2.Power.DefaultValue = 25; 
    540580                break; 
    541581            case 2: 
     
    550590                weapon2.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 3); }; 
    551591                weapon2.FireRate = 1.5; 
    552                 weapon2.Power.Value = 750; 
    553                 weapon2.Power.DefaultValue = 750; 
    554                 break; 
    555         } 
    556     } 
    557     void fire(Weapon ase) 
     592                weapon2.Power.Value = 400; 
     593                weapon2.Power.DefaultValue = 400; 
     594                break; 
     595            case 4: 
     596                weapon2 = new Cannon(0, 0); 
     597                weapon2.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 5); }; 
     598                weapon2.FireRate = 0.8; 
     599                weapon2.Power.DefaultValue = 1500; 
     600                weapon2.Power.Value = 1500; 
     601                break; 
     602        } 
     603    } 
     604    void fire(Weapon ase, Player ship) 
    558605    { 
    559606        PhysicsObject ammus = ase.Shoot(); 
     
    564611            //ammus.Image = ...; 
    565612            //ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 
    566             ammus.MaximumLifetime = TimeSpan.FromMinutes(1.0); 
     613            ammus.MaximumLifetime = TimeSpan.FromSeconds(10.0); 
    567614            if (ase is AssaultRifle) 
    568615            { 
     
    577624                ammus.Size *= 2; 
    578625                ammus.IgnoresCollisionResponse = true; 
     626                ammus.Tag = "laser"; 
    579627            } 
    580628            if (ase is PlasmaCannon) 
    581629            { 
    582                 ammus.Size *= 1.2; 
     630                ammus.Size *= 0.9; 
    583631                AddCollisionHandler(ammus, CollisionHandler.DestroyObject); 
    584632                ammus.IgnoresCollisionResponse = true; 
    585633                ammus.CollisionIgnoreGroup = 3; 
    586634            } 
     635            if (ase is Cannon) 
     636            { 
     637                ammus.Size *= 0.8; 
     638                // ammus.Image = homing; 
     639                ammus.Image = ship.cannonImage; 
     640                AddCollisionHandler(ammus, missilehit); 
     641                ammus.AngularDamping = 1.0; 
     642                ammus.IgnoresCollisionResponse = true; 
     643 
     644                FollowerBrain ammusbrain = new FollowerBrain("hostile", "laser"); 
     645                //ammusbrain.DistanceFar = 125; 
     646                ammusbrain.DistanceFar = 50; 
     647                ammusbrain.Speed = 80; 
     648                ammusbrain.TurnSpeed = UnlimitedAngle.FromDegrees(360); 
     649                ammusbrain.StopWhenTargetClose = false; 
     650                ammusbrain.TurnWhileMoving = true; 
     651                ammus.Brain = ammusbrain; 
     652            } 
     653        } 
     654    } 
     655    void missilehit(PhysicsObject tormaaja, PhysicsObject kohde) 
     656    { 
     657        tormaaja.Destroy(); 
     658        Explosion missilecrash = new Explosion(8); 
     659        missilecrash.Position = tormaaja.Position; 
     660        missilecrash.UseShockWave = false; 
     661        Add(missilecrash); 
     662    } 
     663    void firehoming(Weapon ase) 
     664    { 
     665        PhysicsObject ammus = ase.Shoot(); 
     666        if (ammus != null) 
     667        { 
     668            //Add(ammus, 2); 
     669            //ammus.Size *= ; 
     670            //ammus.Image = ...; 
     671            //ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 
     672            ammus.MaximumLifetime = TimeSpan.FromSeconds(5.0); 
     673            ammus.Image = homing; 
     674            AddCollisionHandler(ammus, missilehit); 
     675            ammus.IgnoresCollisionResponse = true; 
     676            ammus.Size *= 0.8; 
     677            ammus.AngularDamping = 1.0; 
     678            ammus.Image.ReplaceColor(Color.White, Color.Ultramarine); 
     679            ammus.Image.ReplaceColor(Color.Black, Color.Green); 
     680            AddCollisionHandler(ammus, "player1", CollisionHandler.DestroyObject); 
     681            FollowerBrain ammusbrain = new FollowerBrain("player", "laser"); 
     682            //ammusbrain.DistanceFar = 125; 
     683            ammusbrain.DistanceFar = 50; 
     684            ammusbrain.Speed = 80; 
     685            ammusbrain.TurnSpeed = UnlimitedAngle.FromDegrees(360); 
     686            ammusbrain.StopWhenTargetClose = false; 
     687            ammusbrain.TurnWhileMoving = true; 
     688            ammus.Brain = ammusbrain; 
    587689        } 
    588690    } 
     
    604706    void Controlsship() 
    605707    { 
    606         Keyboard.Listen(Key.W, ButtonState.Down, movement, null, 0, 100, ship); 
    607         Keyboard.Listen(Key.S, ButtonState.Down, movement, null, 0, -100, ship); 
    608         Keyboard.Listen(Key.A, ButtonState.Down, movement, null, -100, 0, ship); 
    609         Keyboard.Listen(Key.D, ButtonState.Down, movement, null, 100, 0, ship); 
    610         Keyboard.Listen(Key.Space, ButtonState.Down, fire, "", weapon); 
    611         Mouse.ListenMovement(0, Aim, null, ship); 
    612         Mouse.Listen(MouseButton.Left, ButtonState.Down, fire, null, weapon); 
     708        Keyboard.Listen(Key.W, ButtonState.Down, movement, null, 0, 100, ship1); 
     709        Keyboard.Listen(Key.S, ButtonState.Down, movement, null, 0, -100, ship1); 
     710        Keyboard.Listen(Key.A, ButtonState.Down, movement, null, -100, 0, ship1); 
     711        Keyboard.Listen(Key.D, ButtonState.Down, movement, null, 100, 0, ship1); 
     712        Keyboard.Listen(Key.Space, ButtonState.Down, fire, "", weapon, ship1); 
     713        Mouse.ListenMovement(0, Aim, null, ship1); 
     714        Mouse.Listen(MouseButton.Left, ButtonState.Down, fire, null, weapon, ship1); 
    613715        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, null); 
    614716    } 
     
    624726    void Controlsship1() 
    625727    { 
    626         Keyboard.Listen(Key.W, ButtonState.Down, thrust, "", 1.0, ship); 
    627         Keyboard.Listen(Key.S, ButtonState.Down, thrust, "", -1.0, ship); 
    628         Keyboard.Listen(Key.A, ButtonState.Down, tilt, "", 1.0, ship); 
    629         Keyboard.Listen(Key.D, ButtonState.Down, tilt, "", -1.0, ship); 
    630         Keyboard.Listen(Key.Space, ButtonState.Down, fire, "", weapon); 
     728        Keyboard.Listen(Key.W, ButtonState.Down, thrust, "", 1.0, ship1); 
     729        Keyboard.Listen(Key.S, ButtonState.Down, thrust, "", -1.0, ship1); 
     730        Keyboard.Listen(Key.A, ButtonState.Down, tilt, "", 1.0, ship1); 
     731        Keyboard.Listen(Key.D, ButtonState.Down, tilt, "", -1.0, ship1); 
     732        Keyboard.Listen(Key.Space, ButtonState.Down, fire, "", weapon, ship1); 
    631733        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    632734    } 
     
    637739        Keyboard.Listen(Key.NumPad4, ButtonState.Down, tilt, "", 1.0, ship2); 
    638740        Keyboard.Listen(Key.NumPad6, ButtonState.Down, tilt, "", -1.0, ship2); 
    639         Keyboard.Listen(Key.Add, ButtonState.Down, fire, "", weapon2); 
     741        Keyboard.Listen(Key.Add, ButtonState.Down, fire, "", weapon2, ship2); 
    640742    } 
    641743    void thrust(double direction, Player ship) 
    642744    { 
    643         Vector shipdirection = Vector.FromLengthAndAngle(100.0*direction, ship.Angle); 
     745        Vector shipdirection = Vector.FromLengthAndAngle(100.0 * direction, ship.Angle); 
    644746        ship.Push(shipdirection); 
    645747    } 
    646748    void tilt(double direction, Player ship) 
    647749    { 
    648         ship.AngularAcceleration = 10.0*direction; 
     750        ship.AngularAcceleration = 10.0 * direction; 
    649751    } 
    650752    void singleplayerbase() 
     
    663765        a.Start(); 
    664766    } 
     767 
    665768    void coopbase() 
    666769    { 
     
    680783        a.Start(); 
    681784    } 
     785 
    682786    void Spawnrunes() 
    683787    { 
  • 2013/26/OtsoR/Projekti/Projekti/ProjektiContent/ProjektiContent.contentproj

    r4250 r4278  
    573573  </ItemGroup> 
    574574  <ItemGroup> 
    575     <Compile Include="miniboss.png"> 
    576       <Name>miniboss</Name> 
     575    <Compile Include="bigenemy.png"> 
     576      <Name>bigenemy</Name> 
     577      <Importer>TextureImporter</Importer> 
     578      <Processor>TextureProcessor</Processor> 
     579    </Compile> 
     580  </ItemGroup> 
     581  <ItemGroup> 
     582    <Compile Include="missile.png"> 
     583      <Name>missile</Name> 
    577584      <Importer>TextureImporter</Importer> 
    578585      <Processor>TextureProcessor</Processor> 
Note: See TracChangeset for help on using the changeset viewer.