Changeset 6334 for 2014/30


Ignore:
Timestamp:
2015-06-25 11:29:24 (8 years ago)
Author:
anlakane
Message:
 
Location:
2014/30/MitjaK/Attack to Agora/Attack to Agora
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2014/30/MitjaK/Attack to Agora/Attack to Agora/Attack to Agora.sln

    r6139 r6334  
    44Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Attack to Agora", "Attack to Agora\Attack to Agora\Attack to Agora.csproj", "{DDF55303-D454-45BC-81E0-ED7879E29D5C}" 
    55EndProject 
    6 Project("{96E2B04D-8817-42C6-938A-82C39BA4D311}") = "Attack to AgoraContent", "Attack to Agora\Attack to AgoraContent\Attack to AgoraContent.contentproj", "{2930AD0E-5824-4386-8008-3C0C45D1DA86}" 
     6Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Attack to AgoraContent", "Attack to Agora\Attack to AgoraContent\Attack to AgoraContent.contentproj", "{2930AD0E-5824-4386-8008-3C0C45D1DA86}" 
     7EndProject 
     8Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jypeli", "Muokattu Jypeli\Jypeli.csproj", "{74DD1DDD-283D-45D7-A79D-3DCB120708A6}" 
    79EndProject 
    810Global 
    911        GlobalSection(SolutionConfigurationPlatforms) = preSolution 
    1012                Debug|x86 = Debug|x86 
     13                DebugVisualize|x86 = DebugVisualize|x86 
    1114                Release|x86 = Release|x86 
    1215        EndGlobalSection 
     
    1417                {DDF55303-D454-45BC-81E0-ED7879E29D5C}.Debug|x86.ActiveCfg = Debug|x86 
    1518                {DDF55303-D454-45BC-81E0-ED7879E29D5C}.Debug|x86.Build.0 = Debug|x86 
     19                {DDF55303-D454-45BC-81E0-ED7879E29D5C}.DebugVisualize|x86.ActiveCfg = Debug|x86 
     20                {DDF55303-D454-45BC-81E0-ED7879E29D5C}.DebugVisualize|x86.Build.0 = Debug|x86 
    1621                {DDF55303-D454-45BC-81E0-ED7879E29D5C}.Release|x86.ActiveCfg = Release|x86 
    1722                {DDF55303-D454-45BC-81E0-ED7879E29D5C}.Release|x86.Build.0 = Release|x86 
    1823                {2930AD0E-5824-4386-8008-3C0C45D1DA86}.Debug|x86.ActiveCfg = Debug|x86 
     24                {2930AD0E-5824-4386-8008-3C0C45D1DA86}.DebugVisualize|x86.ActiveCfg = Debug|x86 
    1925                {2930AD0E-5824-4386-8008-3C0C45D1DA86}.Release|x86.ActiveCfg = Release|x86 
     26                {74DD1DDD-283D-45D7-A79D-3DCB120708A6}.Debug|x86.ActiveCfg = Debug|x86 
     27                {74DD1DDD-283D-45D7-A79D-3DCB120708A6}.Debug|x86.Build.0 = Debug|x86 
     28                {74DD1DDD-283D-45D7-A79D-3DCB120708A6}.DebugVisualize|x86.ActiveCfg = DebugVisualize|x86 
     29                {74DD1DDD-283D-45D7-A79D-3DCB120708A6}.DebugVisualize|x86.Build.0 = DebugVisualize|x86 
     30                {74DD1DDD-283D-45D7-A79D-3DCB120708A6}.Release|x86.ActiveCfg = Release|x86 
     31                {74DD1DDD-283D-45D7-A79D-3DCB120708A6}.Release|x86.Build.0 = Release|x86 
    2032        EndGlobalSection 
    2133        GlobalSection(SolutionProperties) = preSolution 
  • 2014/30/MitjaK/Attack to Agora/Attack to Agora/Attack to Agora/Attack to Agora/Attack to Agora.csproj

    r6313 r6334  
    6262  </PropertyGroup> 
    6363  <ItemGroup> 
    64     <Reference Include="Jypeli"> 
    65     </Reference> 
    6664    <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86"> 
    6765      <Private>False</Private> 
     
    118116    <Compile Include="Attack_to_Agora.cs" /> 
    119117    <Compile Include="Properties\AssemblyInfo.cs" /> 
     118    <Compile Include="Elava.cs" /> 
    120119  </ItemGroup> 
    121120  <ItemGroup> 
     
    151150  </ItemGroup> 
    152151  <ItemGroup> 
     152    <ProjectReference Include="..\..\Muokattu Jypeli\Jypeli.csproj"> 
     153      <Project>{74DD1DDD-283D-45D7-A79D-3DCB120708A6}</Project> 
     154      <Name>Jypeli</Name> 
     155    </ProjectReference> 
    153156    <ProjectReference Include="..\Attack to AgoraContent\Attack to AgoraContent.contentproj"> 
    154157      <Project>{2930AD0E-5824-4386-8008-3C0C45D1DA86}</Project> 
  • 2014/30/MitjaK/Attack to Agora/Attack to Agora/Attack to Agora/Attack to Agora/Attack_to_Agora.cs

    r6333 r6334  
    2424    Image cCaseF = LoadImage("caseavausruutu"); 
    2525 
    26     PlatformCharacter taistelija; 
     26    Elava taistelija; 
     27    AssaultRifle taistelijanAse; 
     28    const double ASEEN_DMG = 25.0; 
     29    const double WEAPON_INACCURACY = 20.0; 
     30    bool walkBackwards = false; 
    2731 
    2832    int kenttaNro = 1; 
     
    4044        taustamusiikki_1.Play(); 
    4145    } 
     46 
     47    protected override void Update(Time time) 
     48    { 
     49        if (!walkBackwards) 
     50        { 
     51            if (taistelija.Velocity.X < 0) 
     52                taistelijanAse.Angle = Angle.FromDegrees(180.0); 
     53            if (taistelija.Velocity.X > 0) 
     54                taistelijanAse.Angle = Angle.FromDegrees(0.0); 
     55        } 
     56        base.Update(time); 
     57    } 
     58 
     59    /// <summary> 
     60    /// Pimennetään ruutua pikku hiljaa. 
     61    /// Oletusnopeus 0.01. 
     62    /// </summary> 
     63    public void PimennaRuutua(double nopeus) 
     64    { 
     65        Timer ajastin = new Timer(); 
     66        ajastin.Interval = 0.1; 
     67        ajastin.Timeout += delegate 
     68        { 
     69            Level.AmbientLight -= nopeus; 
     70            if (Level.AmbientLight <= 0.0) 
     71            { 
     72                ajastin.Stop(); 
     73                ajastin.Reset(); 
     74            } 
     75        }; 
     76        ajastin.Start(); 
     77    } 
     78    /// <summary> 
     79    /// Kirkastetaan ruutua pikku hiljaa. 
     80    /// </summary> 
     81    public void KirkastaRuutua(double nopeus, double tavoite) 
     82    { 
     83        Timer ajastin = new Timer(); 
     84        ajastin.Interval = 0.1; 
     85        ajastin.Timeout += delegate 
     86        { 
     87            //if (Level.AmbientLight > 0.1) return; 
     88            Level.AmbientLight += nopeus; 
     89            if (Level.AmbientLight > tavoite) 
     90            { 
     91                ajastin.Stop(); 
     92                ajastin.Reset(); 
     93            } 
     94        }; 
     95        ajastin.Start(); 
     96    } 
     97 
     98    /// <summary> 
     99    /// Piirretään valojuovia. 
     100    /// </summary> 
     101    /// <param name="position">Valojuovan tämänhetkinen sijainti.</param> 
     102    /// <param name="color">Valojuovan väri.</param> 
     103    /// <param name="lifetimeInSeconds">Kauanko valojuova pysyy kentällä.</param> 
     104    void DrawTracers(Vector position, Color color, double lifetimeInSeconds, double brightnessFactor) 
     105    { 
     106        color.AlphaComponent = (byte)(32 * brightnessFactor); // 64 toimii 
     107        GameObject tracer = new GameObject(2, 2); 
     108        tracer.Shape = Shape.Circle; 
     109        tracer.Color = color; 
     110        tracer.Position = position; 
     111        tracer.MaximumLifetime = TimeSpan.FromSeconds(lifetimeInSeconds); 
     112        Add(tracer); 
     113    } 
     114    /// <summary> 
     115    /// Piirretään valojuovia. 
     116    /// </summary> 
     117    /// <param name="tracingObject">Olio, josta valojuovat tulevat.</param> 
     118    /// <param name="color">Valojuovan väri.</param> 
     119    /// <param name="lifetimeInSeconds">Kauanko valojuova pysyy kentällä.</param> 
     120    /// <param name="brightnessFactor">Valojuovan kirkkaus.</param> 
     121    void DrawTracers(PhysicsObject tracingObject, Color color, double lifetimeInSeconds, double brightnessFactor) 
     122    { 
     123        color.AlphaComponent = (byte)(32 * brightnessFactor); // 64 toimii 
     124        GameObject tracer = new GameObject(90, 2); 
     125        tracer.Shape = Shape.Circle; 
     126        tracer.Color = color; 
     127        tracer.Position = tracingObject.Position; 
     128        tracer.Angle = tracingObject.Angle; 
     129        tracer.MaximumLifetime = TimeSpan.FromSeconds(lifetimeInSeconds); 
     130        Add(tracer); 
     131    } 
     132 
    42133 
    43134    void Liikuta(PlatformCharacter pelaaja, double suunta) 
     
    67158    { 
    68159        SmoothTextures = false; 
    69         IsFullScreen = true; 
     160        // IsFullScreen = true; 
    70161        Gravity = new Vector(0, -2500); 
    71162        // Synkataan taustakuvan ja colortilemapin pikselit 
     
    96187        vasenreuna.X -= 75; 
    97188        vasenreuna.Tag = "vasenreuna"; 
    98         //PhysicsObject oikeareuna = Level.CreateRightBorder(); 
    99         //oikeareuna.X += 75; 
    100         //oikeareuna.Tag = "oikeareuna"; 
     189        PhysicsObject oikeareuna = Level.CreateRightBorder(); 
     190        oikeareuna.Tag = "oikeareuna"; 
    101191 
    102192        Varjo(); 
     
    106196    { 
    107197 
    108         taistelija = new PlatformCharacter(75, 75); 
     198        taistelija = new Elava(75, 75, 100.0); 
    109199        taistelija.Shape = Shape.Rectangle; 
    110200        taistelija.Animation = new Animation(chuckinkavely); 
     
    118208        Camera.Follow(taistelija); 
    119209        Camera.StayInLevel = true; 
     210 
     211        taistelijanAse = new AssaultRifle(20, 10); 
     212        taistelijanAse.FireRate = 20; 
     213        taistelijanAse.InfiniteAmmo = true; 
     214        taistelijanAse.Power.Value = 750; 
     215        taistelijanAse.Power.DefaultValue = 750; 
     216        taistelija.Add(taistelijanAse); 
    120217    } 
    121218 
     
    263360        Keyboard.Listen(Key.Space, ButtonState.Pressed, LiikutaYlos, null, taistelija); 
    264361        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     362        Keyboard.Listen(Key.Enter, ButtonState.Down, Ammu, null); 
     363        Keyboard.Listen(Key.LeftShift, ButtonState.Pressed, delegate { walkBackwards = true; }, null); 
     364        Keyboard.Listen(Key.LeftShift, ButtonState.Released, delegate { walkBackwards = false; }, null); 
    265365 
    266366#if DEBUG 
     
    269369    } 
    270370 
     371    void Ammu() 
     372    { 
     373        if (taistelijanAse == null)  
     374            return; 
     375 
     376        PhysicsObject ammus = taistelijanAse.Shoot(); 
     377 
     378        if (ammus == null)  
     379            return; 
     380        ammus.Size *= 0.2; 
     381 
     382        ammus.Hit(new Vector(0.0, RandomGen.NextDouble(-WEAPON_INACCURACY, WEAPON_INACCURACY))); 
     383        ammus.IsUpdated = true; 
     384        ammus.NeedsUpdateCall = true; 
     385        ammus.CanRotate = false; 
     386        ammus.Updated += delegate(PhysicsObject a)  
     387        {  
     388             DrawTracers(a, Color.Yellow, 0.2, 2.0);  
     389        }; 
     390 
     391        AddCollisionHandler(ammus, "vihollinen", AmmusOsuuViholliseen); 
     392        ammus.Collided += delegate { ammus.Destroy(); }; 
     393    } 
     394 
     395    void AmmusOsuuViholliseen(PhysicsObject ammus, PhysicsObject kohde) 
     396    { 
     397        Elava vihu = kohde as Elava; 
     398 
     399        if (vihu == null) return; 
     400 
     401        vihu.Damagea(ASEEN_DMG); 
     402    } 
     403 
    271404    void VoititPelin() 
    272405    { 
Note: See TracChangeset for help on using the changeset viewer.