Changeset 6384 for 2015/26


Ignore:
Timestamp:
2015-06-25 16:47:08 (4 years ago)
Author:
sieerinn
Message:

Heiluri on valmis.

Location:
2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun.cs

    r6383 r6384  
    167167    public const double TILE_SIZE = 70; 
    168168 
    169     public String[] names = new String[] { "Adolfiina", "Rasputiina", "Hermanniina", "Joosefiina"}; 
    170          
     169    public String[] names = new String[] { "Adolfiina", "Rasputiina", "Hermanniina", "Joosefiina" }; 
     170 
    171171    private double cameraTargetX; // Sijainti jossa kameran pitäisi olla. 
    172172    private Vector cameraTarget; 
     
    196196    private Image treeBranchImage = LoadImage("bigtreebranch"); 
    197197    private Image forestBackgroundImage = LoadImage("forestbackground"); 
     198    private Image swingTrapImage = LoadImage("tukki"); 
    198199 
    199200    private Animation crawl; 
     
    444445 
    445446        level.SetTileMethod(Color.FromHexCode("FF6A00"), CreateTreeTrunk);  //Pihhh jostain heksoista. Ikävästi haisee luovuttamiselta! :----D 
    446         level.SetTileMethod(Color.FromHexCode("57007F"), CreateTreeRoot); 
     447        level.SetTileMethod(Color.FromHexCode("57007F"), CreateTreeRoot);   // Heksojen käytössä ei ole mitään hävettävää :P 
    447448        level.SetTileMethod(Color.FromHexCode("00FF21"), CreateTreeBranch); 
     449        level.SetTileMethod(Color.FromHexCode("5B7F00"), CreateSwingTrap); 
    448450 
    449451        level.Optimize(Color.Brown);    //Color.Black   //Tekee jännittäviä asioita wheatille, jos optimoidaan (tietysti). Jotenn.  
    450452 
    451453        level.Execute(TILE_SIZE, TILE_SIZE); 
     454    } 
     455 
     456    void CreateSwingTrap(Vector position, double width, double height) 
     457    { 
     458        const double swingArc = 30; // Heiluu 30 astetta edestakaisin. 
     459        const double swingSpeed = 1.5; 
     460        const double ropeLength = 400; 
     461        var center = position + new Vector(0, ropeLength); 
     462 
     463        // Ajastukset heilutteluun. 
     464        double deltaTime = 1 / 60.0; 
     465        double time = 0.0; 
     466 
     467        PhysicsObject swing = PhysicsObject.CreateStaticObject(width, height); 
     468        swing.Image = swingTrapImage; 
     469        swing.Position = position; 
     470        Add(swing); 
     471 
     472        GameObject rope = new GameObject(ropeLength, 10); 
     473        rope.Color = new Color(10, 30, 10); 
     474        Add(rope); 
     475 
     476        var updateTimer = new Timer { Interval = deltaTime }; 
     477        updateTimer.Timeout += delegate 
     478        { 
     479            time += deltaTime; 
     480 
     481            // Heilurin kulma on sinimuotoinen funktio ajan suhteen. 
     482            var angle = Angle.FromDegrees(-90.0 + Math.Sin(time * swingSpeed) * swingArc); 
     483            swing.Position = center + angle.GetVector() * ropeLength; 
     484            swing.Angle = angle; 
     485 
     486            // Päivitetään narun sijainti ja kulma. 
     487            rope.Angle = angle; 
     488            rope.Position = center + angle.GetVector() * ropeLength * 0.5; 
     489        }; 
     490        updateTimer.Start(); 
    452491    } 
    453492 
     
    490529        Add(roots, -1); 
    491530    } 
    492      
     531 
    493532    void CreateFlame(Vector position, double width, double height, bool suuri) 
    494533    { 
     
    697736        }; 
    698737 
    699         attackBrain.DistanceToTarget.AddTrigger(Window.Width / 2, TriggerDirection.Down, delegate()  
    700         {  
    701             castTimer.Start();  
    702             attackBrain.DistanceToTarget.RemoveTriggers(Window.Width/2); 
     738        attackBrain.DistanceToTarget.AddTrigger(Window.Width / 2, TriggerDirection.Down, delegate() 
     739        { 
     740            castTimer.Start(); 
     741            attackBrain.DistanceToTarget.RemoveTriggers(Window.Width / 2); 
    703742        }); 
    704743 
     
    716755                    CreatePitchfork(mage.Position, TILE_SIZE, TILE_SIZE); 
    717756                    mage.Destroy(); 
    718                     Timer.SingleShot(6, NextLevel);  
     757                    Timer.SingleShot(6, NextLevel); 
    719758                } 
    720759                Timer.SingleShot(0.5, delegate { immune = false; }); 
     
    843882 
    844883        AddCollisionHandler(player, "improvement", CollectImprovement); 
    845        // AddCollisionHandler(player, "improvement", CollectImprovement); 
     884        // AddCollisionHandler(player, "improvement", CollectImprovement); 
    846885    } 
    847886 
     
    953992    //{ 
    954993    //    if (player.Improvement == null) 
    955     //    { 
    956              
     994    //    {  
    957995    //        CreateMilkParticles(player, 5, 100, 100, new Vector(0, player.Height/3), "tears"); 
    958996    //        return; 
    959997    //    } 
    960  
    961998    //    player.UseImprovement(player.Improvement); 
    962999    //} 
  • 2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRunContent/HillbillyRunContent.contentproj

    r6310 r6384  
    316316    </Compile> 
    317317  </ItemGroup> 
     318  <ItemGroup> 
     319    <Compile Include="tukki.png"> 
     320      <Name>tukki</Name> 
     321      <Importer>TextureImporter</Importer> 
     322      <Processor>TextureProcessor</Processor> 
     323    </Compile> 
     324  </ItemGroup> 
    318325  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    319326  <!--  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.