Changeset 5999


Ignore:
Timestamp:
2015-06-10 13:53:17 (4 years ago)
Author:
lesejuku
Message:
 
Location:
2015/24/LeeviK/AS Bandit Experience/AS Bandit Experience
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • 2015/24/LeeviK/AS Bandit Experience/AS Bandit Experience/AS Bandit Experience/AS Bandit Experience.csproj.Debug.cachefile

    r5981 r5999  
    88Content\maaBLYAT.xnb 
    99Content\CheekiBreeki.xnb 
     10Content\LUUTA.xnb 
    1011Content\UzickoKolo.wma 
  • 2015/24/LeeviK/AS Bandit Experience/AS Bandit Experience/AS Bandit Experience/AS_Bandit_Experience.cs

    r5981 r5999  
    1212    GameObject banditKadet; 
    1313    Ase banditAse; 
     14    Vector aseenOsumaKohde; 
     15    bool piirraTracer = false; 
    1416    bool ladataankoAsetta = false; 
    1517    PhysicsObject Vodka; 
     
    4547 
    4648        banditAse = new Ase(HAHMOJEN_LEVEYS, HAHMOJEN_KORKEUS, 30, int.MaxValue, 3.0); //koko, lipaskoko, reserviluodit, latausnopeus 
     49        banditAse.Damage = 26; 
     50        banditAse.Spread = Angle.FromDegrees(5); 
    4751        banditAse.FireRate = 11.6; //metriä sekunnissa 
    4852        banditAse.Power.Value = 720; //ensimmäisen luodin lähtönopeus 
    4953        banditAse.Power.DefaultValue = 720; //muiden luotien lähtönopeus 
     54        banditAse.MaxRange = 150 * HAHMOJEN_LEVEYS; 
    5055        //SoundEffect AKSaani = LoadSoundEffect("CheekiBreeki"); 
    5156        //banditAse.AttackSound = AKSaani; //väliaikainen 
     
    6671        AddCollisionHandler(bandit, Vodka, ViinaRalli); 
    6772        //Camera.Follow(bandit); 
     73 
     74        Timer ajastin = new Timer(); 
     75        ajastin.Interval = 4.0; 
     76        ajastin.Timeout += SpawnLoner; 
     77        ajastin.Start(); 
    6878 
    6979        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     
    8797    } 
    8898 
     99    protected override void Paint(Canvas canvas) 
     100    { 
     101        if (piirraTracer) 
     102        { 
     103            canvas.BrushColor = Color.Orange; 
     104            canvas.DrawLine(banditAse.AbsolutePosition + Vector.FromLengthAndAngle(55, banditAse.AbsoluteAngle), aseenOsumaKohde); 
     105            piirraTracer = false; 
     106        } 
     107        base.Paint(canvas); 
     108    } 
     109 
    89110    void LiikutaBandit(Vector vektori, PhysicsObject bandit) 
    90111    { 
     
    94115    } 
    95116 
    96     void AmmuAseella(AssaultRifle ase) 
     117    void AmmuAseella(Ase ase) 
    97118    { 
    98119        if (ladataankoAsetta) return; 
    99120 
    100121        PhysicsObject ammus = ase.Shoot(); 
    101  
    102         if (ammus != null) 
    103         { 
    104             ammus.Size *= 10.2; 
     122        if (ammus == null) return; 
     123        ammus.Destroy(); 
     124 
     125        //if (ammus != null) 
     126        //{ 
     127        //    ammus.Size = new Vector(3.5, 1); 
     128        //    AddCollisionHandler(ammus, AmmusOsuu); 
     129        //} 
     130 
     131        Angle tamankertainenHajoama = RandomGen.NextAngle(-ase.Spread, ase.Spread); 
     132 
     133        PhysicsObject osumanKohde = ShootHitscan(ase, bandit, tamankertainenHajoama); 
     134        if (osumanKohde != null) 
     135        { 
     136            AmmusOsuu(osumanKohde); 
     137            aseenOsumaKohde = osumanKohde.AbsolutePosition; 
     138            piirraTracer = true; 
     139        } 
     140        else 
     141        { 
     142            aseenOsumaKohde = ase.Position + Vector.FromLengthAndAngle(ase.MaxRange, ase.AbsoluteAngle + tamankertainenHajoama); 
     143            piirraTracer = true; 
     144        } 
     145    } 
     146 
     147    /// <summary> 
     148    /// Ammutaan aseen suuntaan raycast aseen kantaman päähän. 
     149    /// Palauttaa asetta lähimmän PhysicsObjektin, johon säde osuu. 
     150    /// </summary> 
     151    /// <param name="a"></param> 
     152    /// <returns></returns> 
     153    PhysicsObject ShootHitscan(Ase a, GameObject owner, Angle poikkeama) 
     154    { 
     155        Vector farTarget = Vector.FromLengthAndAngle(a.MaxRange, a.AbsoluteAngle + poikkeama); 
     156 
     157        List<GameObject> potTargets = GetObjects(x => x is PhysicsObject && x != owner); 
     158 
     159        double closestDistance = double.MaxValue; 
     160        int closestIndex = -1; 
     161 
     162        for (int i = 0; i < potTargets.Count; i++) 
     163        { 
     164            if (potTargets[i].IsBlocking(a.AbsolutePosition, farTarget)) 
     165            { 
     166                double currentDistance = Vector.Distance(a.AbsolutePosition, potTargets[i].Position); 
     167 
     168                if (currentDistance < closestDistance) 
     169                { 
     170                    closestDistance = currentDistance; 
     171                    closestIndex = i; 
     172                } 
     173            } 
     174        } 
     175 
     176        if (closestIndex != -1) 
     177            return (PhysicsObject)potTargets[closestIndex]; 
     178        return null; 
     179    } 
     180 
     181    void AmmusOsuu(PhysicsObject kohde) 
     182    { 
     183        Loner k = kohde as Loner; 
     184        if (k != null) 
     185        { 
     186            k.Damagea(banditAse.Damage); 
    105187        } 
    106188    } 
     
    133215        Add(loner); 
    134216        return loner; 
     217 
    135218    } 
    136219    void LuoVodka() 
     
    150233        banditAse.Destroy(); 
    151234        banditKadet.Destroy(); 
     235        LuoMrDeath(); 
    152236 
    153237    
     
    155239    } 
    156240 
     241    void LuoMrDeath() 
     242    { 
     243        ClearAll(); 
     244        GameObject DEATH = new GameObject(LoadImage("death")); 
     245        Add(DEATH); 
     246        Level.Background.Color = Color.Black; 
     247        Keyboard.Listen(Key.Space, ButtonState.Pressed, delegate { 
     248            ClearAll(); 
     249            Begin(); 
     250        }, null); 
     251    } 
     252 
     253    void SpawnLoner() 
     254    { 
     255        //ANUS BREAKS 4 DAMAGE 
     256    } 
    157257} 
  • 2015/24/LeeviK/AS Bandit Experience/AS Bandit Experience/AS Bandit Experience/Ase.cs

    r5982 r5999  
    1414 
    1515    public double ReloadTime { get; set; } 
     16 
     17    public double Damage { get; set; } 
     18 
     19    public double MaxRange { get; set; } 
     20 
     21    public Angle Spread { get; set; } 
    1622 
    1723    public Ase(double width, double height, int magazineSize, int maxAmmoInReserve, double reloadTime) 
  • 2015/24/LeeviK/AS Bandit Experience/AS Bandit Experience/AS Bandit Experience/Loner.cs

    r5982 r5999  
    77public class Loner : PhysicsObject 
    88{ 
    9     DoubleMeter Health { get; set; } 
     9    public DoubleMeter Health { get; private set; } 
    1010 
    1111    //FollowerBrain AttackBrain { get; set; } 
     
    1717        this.Health.LowerLimit += Kuoli; 
    1818        this.Health.LowerLimit += this.Destroy; 
     19        this.Mass = 100; 
    1920 
    2021        //this.AttackBrain = new FollowerBrain(target); 
    2122        //this.Brain = AttackBrain; 
     23    } 
     24 
     25    public void Damagea(double amount) 
     26    { 
     27        this.Health.Value -= amount; 
    2228    } 
    2329 
  • 2015/24/LeeviK/AS Bandit Experience/AS Bandit Experience/AS Bandit Experience/obj/x86/Debug/AS Bandit Experience.csproj.FileListAbsolute.txt

    r5981 r5999  
    1717C:\MyTemp\LeeviK\AS Bandit Experience\AS Bandit Experience\AS Bandit Experience\bin\x86\Debug\Content\maaBLYAT.xnb 
    1818C:\MyTemp\LeeviK\AS Bandit Experience\AS Bandit Experience\AS Bandit Experience\bin\x86\Debug\Content\CheekiBreeki.xnb 
     19C:\MyTemp\LeeviK\AS Bandit Experience\AS Bandit Experience\AS Bandit Experience\bin\x86\Debug\Content\LUUTA.xnb 
  • 2015/24/LeeviK/AS Bandit Experience/AS Bandit Experience/AS Bandit Experience/obj/x86/Debug/ContentPipeline-{CF2287A8-9A13-468B-8E64-AE02CEDFA772}.xml

    r5981 r5999  
    8484      <Time>2015-06-10T11:17:45.3125965+03:00</Time> 
    8585    </Item> 
     86    <Item> 
     87      <Source>LUUTA.png</Source> 
     88      <Name>LUUTA</Name> 
     89      <Importer>TextureImporter</Importer> 
     90      <Processor>TextureProcessor</Processor> 
     91      <Options>None</Options> 
     92      <Output>C:\MyTemp\LeeviK\AS Bandit Experience\AS Bandit Experience\AS Bandit Experience\bin\x86\Debug\Content\LUUTA.xnb</Output> 
     93      <Time>2015-06-10T12:20:02.4763653+03:00</Time> 
     94    </Item> 
    8695    <BuildSuccessful>true</BuildSuccessful> 
    8796    <Settings> 
  • 2015/24/LeeviK/AS Bandit Experience/AS Bandit Experience/AS Bandit Experience/obj/x86/Debug/cachefile-{CF2287A8-9A13-468B-8E64-AE02CEDFA772}-targetpath.txt

    r5981 r5999  
    99Content\maaBLYAT.xnb 
    1010Content\CheekiBreeki.xnb 
     11Content\LUUTA.xnb 
  • 2015/24/LeeviK/AS Bandit Experience/AS Bandit Experience/AS Bandit ExperienceContent/AS Bandit ExperienceContent.contentproj

    r5981 r5999  
    106106    </Compile> 
    107107  </ItemGroup> 
     108  <ItemGroup> 
     109    <Compile Include="LUUTA.png"> 
     110      <Name>LUUTA</Name> 
     111      <Importer>TextureImporter</Importer> 
     112      <Processor>TextureProcessor</Processor> 
     113    </Compile> 
     114  </ItemGroup> 
    108115  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    109116  <!--  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.