Changeset 7212 for 2016/23


Ignore:
Timestamp:
2016-06-09 09:18:14 (3 years ago)
Author:
sieerinn
Message:

Pelaaja muutettu PlatformCharacteriksi? ja aikalaskuri lisätty

Location:
2016/23/ohjaajat/Punasininen/Punasininen/Punasininen
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 2016/23/ohjaajat/Punasininen/Punasininen/Punasininen/Player.cs

    r7211 r7212  
    77using Jypeli.Widgets; 
    88 
    9 public class Player : PlatformCharacter2 
     9public class Player : PlatformCharacter 
    1010{ 
    1111    public Weapon Secondary; 
     
    2020 
    2121        Tag = "player"; 
    22         Acceleration = 1500; 
     22        //Acceleration = 1500; 
    2323    } 
    2424} 
  • 2016/23/ohjaajat/Punasininen/Punasininen/Punasininen/Punasininen.cs

    r7211 r7212  
    1212    private const double SPEED = 450; 
    1313    private const double JUMPSPEED = 1250; 
    14     private const int TILE_SIZE = 40; 
     14    private const int TILE_SIZE = 60; 
    1515 
    1616    private Player blue; 
     
    2929    private Image orangePistolpic = LoadImage("orangegun"); 
    3030 
     31    DoubleMeter matchTimer; // Remaining time in seconds. 
    3132    DoubleMeter percentageTracker; 
    3233 
     
    4647        for (int i = 1; i <= numberOfImages; i++) 
    4748        { 
    48             images[i-1] = LoadImage(string.Format("{0}{1:0000}", prefix, i)); 
     49            images[i - 1] = LoadImage(string.Format("{0}{1:0000}", prefix, i)); 
    4950        } 
    5051        return images; 
     
    5758        ColorTileMap map = ColorTileMap.FromLevelAsset("dungeon1"); 
    5859        map.SetTileMethod(Color.Black, AddPlatform); 
     60        //map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate (Vector paikka, double leveys, double korkeus) { blue = CreatePlayer(paikka, leveys, korkeus, bluepic, blueColor); }); 
     61        //map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate(Vector paikka, double leveys, double korkeus) { blue = CreatePlayer(paikka, leveys, korkeus, bluepic, blueColor);}); 
    5962        map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate(Vector paikka, double leveys, double korkeus) { blue = CreatePlayer(paikka, leveys, korkeus, blueColor, blueWalkImages, bluePistolpic);}); 
     63 
    6064        map.SetTileMethod(Color.FromHexCode("FFD800"), CreateWeaponCrate); 
     65 
     66        //map.SetTileMethod(Color.Red, delegate (Vector paikka, double leveys, double korkeus) { red = CreatePlayer(paikka, leveys, korkeus, redpic, redColor); }); 
     67        //map.SetTileMethod(Color.Red, delegate(Vector paikka, double leveys, double korkeus) { red = CreatePlayer(paikka, leveys, korkeus, redpic, redColor); }); 
    6168        map.SetTileMethod(Color.Red, delegate(Vector paikka, double leveys, double korkeus) { red = CreatePlayer(paikka, leveys, korkeus, redColor, orangeWalkImages, orangePistolpic); }); 
    6269        map.Execute(TILE_SIZE, TILE_SIZE); 
     
    7986        percentageBar.BindTo(percentageTracker); 
    8087        Add(percentageBar); 
     88 
     89        matchTimer = new DoubleMeter(30); 
     90 
     91        var timeLabel = new Label(); 
     92        timeLabel.Y = Window.Height / 2 - 100; 
     93        timeLabel.BindTo(matchTimer); 
     94        timeLabel.TextColor = blueColor; 
     95        timeLabel.DoubleFormatString = "{0}"; 
     96        timeLabel.TextScale *= 3; 
     97        Add(timeLabel); 
     98 
     99        var timer = new Timer(); 
     100        timer.Interval = 1; 
     101        timer.Timeout += () => 
     102        { 
     103            matchTimer.Value -= 1; 
     104            timeLabel.TextColor = matchTimer.Value % 2 == 0 ? blueColor : redColor; 
     105        }; 
     106        timer.Start(); 
     107 
    81108    } 
    82109 
     
    117144        }; 
    118145 
    119         AddCollisionHandler(player, "platform", delegate(PhysicsObject a, PhysicsObject b) 
     146        AddCollisionHandler(player, "platform", delegate (PhysicsObject a, PhysicsObject b) 
    120147        { 
    121148            ColorTile(a, b); 
    122149        }); 
    123         AddCollisionHandler(player, "crate", delegate(PhysicsObject a, PhysicsObject b) 
     150        AddCollisionHandler(player, "crate", delegate (PhysicsObject a, PhysicsObject b) 
    124151        { 
    125152            GunLottery(player); 
    126153            b.Destroy(); 
    127154        }); 
    128         AddCollisionHandler(player, "death", delegate(PhysicsObject a, PhysicsObject b) 
     155        AddCollisionHandler(player, "death", delegate (PhysicsObject a, PhysicsObject b) 
    129156        { 
    130157            Restore((Player)a); 
     
    163190    void Win(Player player) 
    164191    { 
    165        Pause(); 
     192        Pause(); 
    166193        //Haluaisin tehdä tähän jonkinlaisen hauskan ponnahdusefektin jossain vaiheessa. Sellaisen napakan zoomin ja sitten boing. Hurdur. 
    167        Camera.ZoomTo(player.Left, player.Bottom, player.Right, player.Top + 100); 
     194        Camera.ZoomTo(player.Left, player.Bottom, player.Right, player.Top + 100); 
    168195 
    169196        Label announcement = new Label("Kiva homma hei") 
     
    174201        }; 
    175202        Add(announcement); 
    176         
     203 
    177204    } 
    178205 
    179206    public void ColorTile(PhysicsObject player, PhysicsObject platform) 
    180207    { 
    181         var imgs = player.Color == blueColor? blueTileImages : orangeTileImages; 
     208        var imgs = player.Color == blueColor ? blueTileImages : orangeTileImages; 
    182209        var glowImg = player.Color == blueColor ? blueGlow : orangeGlow; 
    183         ((Tile)platform).SetColor(imgs, glowImg, player.Color); 
    184  
     210 
     211        ((Tile)platform).SetColor(imgs, glowImg, player.Color, UpdatePercentage); 
     212    } 
     213 
     214    void UpdatePercentage() 
     215    { 
    185216        List<GameObject> colored = GetObjects(o => (o.Color == red.Color || o.Color == blue.Color) && (String)o.Tag == "platform"); 
    186         percentageTracker.Value = (double)colored.FindAll(o => o.Color == red.Color).Count/colored.Count * 100; 
     217        percentageTracker.Value = (double)colored.FindAll(o => o.Color == red.Color).Count / colored.Count * 100; 
    187218    } 
    188219 
     
    199230        ControllerTwo.ListenAnalog(AnalogControl.LeftStick, 0.1, Move, "Liikuta pelaajaa", blue); 
    200231        ControllerTwo.Listen(Button.A, ButtonState.Pressed, Jump, "Pelaaja hyppää", blue, JUMPSPEED); 
    201         ControllerOne.ListenAnalog(AnalogControl.RightStick, 0.1, Aim, null, blue); 
     232        ControllerTwo.ListenAnalog(AnalogControl.RightStick, 0.1, Aim, null, blue); 
    202233        ControllerTwo.ListenAnalog(AnalogControl.RightTrigger, 0.1, Shoot, "", blue); 
    203234        ControllerTwo.ListenAnalog(AnalogControl.LeftTrigger, 0.1, Shoot, "", blue); 
     
    212243    { 
    213244        if (stick.StateVector.Magnitude > 0.15) 
    214             player.Walk(stick.StateVector.X > 0 ? Direction.Right : Direction.Left); 
     245        { 
     246            //player.Walk(stick.StateVector.X > 0 ? Direction.Right : Direction.Left); 
     247            player.Walk(stick.StateVector.X * 300); 
     248        } 
     249 
    215250    } 
    216251 
     
    223258            { 
    224259                bullet.Image = null; 
    225                 bullet.Color = player.Color;   
     260                bullet.Color = player.Color; 
    226261            } 
    227262        } 
  • 2016/23/ohjaajat/Punasininen/Punasininen/Punasininen/Tile.cs

    r7209 r7212  
    1919    } 
    2020 
    21     public void SetColor(Image[] animation, Image glowImage, Color newColor) 
     21    public void SetColor(Image[] animation, Image glowImage, Color newColor, Action colorChanged) 
    2222    { 
    2323        var overlay = new GameObject(Width, Height); 
     
    2929            this.Color = newColor; 
    3030            overlay.Destroy(); 
     31 
     32            if (colorChanged != null) 
     33            { 
     34                colorChanged(); 
     35            } 
    3136        }; 
    3237        overlay.Animation.Start(); 
Note: See TracChangeset for help on using the changeset viewer.