- Timestamp:
- 2015-06-25 16:35:24 (8 years ago)
- Location:
- 2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun.cs
r6382 r6383 42 42 private HillBilly owner; 43 43 44 public virtual void DoTheThing( ) { }44 public virtual void DoTheThing(HillbillyRun game) { } 45 45 46 46 public SoundEffect sound; 47 48 public void Rid() 49 { 50 Owner.AnimWalk = Owner.Animations[0]; 51 Owner.AnimIdle = Owner.Animations[1]; 52 Owner.Improvement = null; 53 Owner = null; 54 } 47 55 } 48 56 49 57 public class MilkImprovement : Improvement 50 58 { 51 public override void DoTheThing( )52 { 53 HillbillyRun game = this.Game as HillbillyRun;59 public override void DoTheThing(HillbillyRun game) 60 { 61 //HillbillyRun game = this.Game as HillbillyRun; 54 62 Owner.PlayAnimation(Animations[1]); 55 63 game.CreateMilkParticles(this.Owner, 10, 200, 300, new Vector(0, -30), "milkparticle"); 56 64 this.sound.Play(); 57 58 65 } 59 66 … … 68 75 public class PitchForkImprovement : Improvement 69 76 { 70 public override void DoTheThing() 71 { 72 HillbillyRun game = this.Game as HillbillyRun; 73 Owner.PlayAnimation(Animations[1]); 77 public override void DoTheThing(HillbillyRun game) 78 { 79 //HillbillyRun game = this.Game as HillbillyRun; 74 80 //game.CreateMilkParticles(this.Owner, 10, 200, 300, new Vector(0, -30), "milkparticle"); 75 81 //TODO: hitting things w/ pitchfork 76 82 game.ForkThings(Owner); 77 83 } 78 84 … … 83 89 } 84 90 } 85 86 91 #endregion 87 92 88 93 public class HillBilly : PlatformCharacter 89 94 { 95 public List<Animation> Animations { get; set; } 96 90 97 private IntMeter lifeCounter = new IntMeter(4, 0, 4); 91 98 public IntMeter Life … … 108 115 public void GainImprovement(Improvement improvement) 109 116 { 117 110 118 this.AnimWalk = improvement.Animations[0]; 111 119 this.AnimIdle = new Animation(improvement.Animations[0].CurrentFrame); … … 116 124 } 117 125 118 public void UseImprovement(Improvement improvement) 119 { 120 if (Animation != improvement.Animations[1]) 121 { 122 improvement.DoTheThing(); 123 126 public void UseImprovement() 127 { 128 HillbillyRun game = this.Game as HillbillyRun; 129 if (this.Improvement == null) 130 { 131 game.CreateMilkParticles(this, 5, 100, 100, new Vector(0, Height / 3), "tears"); 132 } 133 else if (Animation != this.Improvement.Animations[1]) 134 { 135 this.Improvement.DoTheThing(game); 124 136 } 125 137 } … … 573 585 brain.FallsOffPlatforms = false; 574 586 worm.Brain = brain; 587 588 AddCollisionHandler(worm, "pitchfork", delegate(PhysicsObject w, PhysicsObject p) { w.Destroy(); }); 575 589 } 576 590 … … 775 789 player.AnimJump = new Animation(playerJump); 776 790 player.AnimFall = new Animation(playerFall); 791 player.Animations = new List<Animation>(); 792 player.Animations.Add(normalWalk); 793 player.Animations.Add(playerIdle); 777 794 player.AnimFall.StopOnLastFrame = true; 778 795 players.Add(player); … … 809 826 players.Remove(player); 810 827 811 if (player.Improvement != null) 812 { 813 Improvement parannus = player.Improvement; 814 //parannus.Image = player.Improvement.Image; 815 parannus.Position = player.Position; 816 parannus.IsVisible = true; 817 parannus.IgnoresCollisionResponse = false; 818 parannus.Tag = "improvement"; 819 //parannus.Animations = player.Improvement.Animations; 820 //parannus.Tag = player.Improvement.Tag; 821 //parannus.Size = new Vector(60, 60); 822 //Add(parannus); 823 } 828 //if (player.Improvement != null) 829 //{ 830 GetRidOfImprovement(player); 831 //Improvement parannus = player.Improvement; 832 //parannus.Position = player.Position; 833 //parannus.IsVisible = true; 834 //parannus.IgnoresCollisionResponse = false; 835 //parannus.Tag = "improvement"; 836 //} 824 837 825 838 player.Destroy(); … … 832 845 // AddCollisionHandler(player, "improvement", CollectImprovement); 833 846 } 834 835 //void CollectImprovement(PhysicsObject player, PhysicsObject fork)836 //{837 // //TODO: Collecting the fork838 // HillBilly billy = player as HillBilly;839 // if (billy == null)840 // return;841 842 // Improvement forkI = fork as Improvement;843 // billy.GainImprovement(forkI);844 845 // Remove(fork);846 //}847 847 848 848 void CreateGroundTop(Vector position, double width, double height) … … 890 890 Keyboard.Listen(Key.D, ButtonState.Down, delegate { startingPlayers[0].Walk(PLAYER_SPEED); }, "Player 1 moves right"); 891 891 Keyboard.Listen(Key.W, ButtonState.Down, delegate { startingPlayers[0].Jump(PLAYER_SPEED * 2); }, "Player 1 jumps"); //Just PLAYER_SPEED felt alright as well 892 Keyboard.Listen(Key.E, ButtonState.Pressed, UseImprovement, "Player 1 uses their tools", startingPlayers[0]); 892 Keyboard.Listen(Key.E, ButtonState.Pressed, delegate { startingPlayers[0].UseImprovement(); }, "Player 1 uses their tools"); 893 Keyboard.Listen(Key.Tab, ButtonState.Pressed, GetRidOfImprovement, "Player 1 throws their tools away", startingPlayers[0]); 893 894 894 895 Keyboard.Listen(Key.Left, ButtonState.Down, delegate { startingPlayers[1].Walk(-PLAYER_SPEED); }, "Player 2 moves left"); 895 896 Keyboard.Listen(Key.Right, ButtonState.Down, delegate { startingPlayers[1].Walk(PLAYER_SPEED); }, "Player 2 moves right"); 896 897 Keyboard.Listen(Key.Up, ButtonState.Down, delegate { startingPlayers[1].Jump(PLAYER_SPEED * 2); }, "Player 2 jumps"); 897 Keyboard.Listen(Key.RightShift, ButtonState.Pressed, UseImprovement, "Player 2 uses their tools", startingPlayers[1]); 898 Keyboard.Listen(Key.RightShift, ButtonState.Pressed, delegate { startingPlayers[1].UseImprovement(); }, "Player 2 uses their tools"); 899 Keyboard.Listen(Key.Enter, ButtonState.Pressed, GetRidOfImprovement, "Player 1 throws their tools away", startingPlayers[1]); 898 900 899 901 Keyboard.Listen(Key.F12, ButtonState.Pressed, NextLevel, null); … … 902 904 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Show help"); 903 905 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Exit game"); 906 } 907 908 void GetRidOfImprovement(HillBilly player) 909 { 910 if(player.Improvement != null) 911 { 912 Improvement parannus = player.Improvement; 913 parannus.Position = player.Position + player.FacingDirection.GetVector() * 100; 914 parannus.IsVisible = true; 915 parannus.IgnoresCollisionResponse = false; 916 parannus.Tag = "improvement"; 917 player.Improvement.Rid(); 918 } 904 919 } 905 920 … … 935 950 } 936 951 937 private void UseImprovement(HillBilly player)938 {939 if (player.Improvement == null)940 {952 //private void UseImprovement(HillBilly player) 953 //{ 954 // if (player.Improvement == null) 955 // { 941 956 942 CreateMilkParticles(player, 5, 100, 100, new Vector(0, player.Height/3), "tears");943 return;944 }945 946 player.UseImprovement(player.Improvement);947 }957 // CreateMilkParticles(player, 5, 100, 100, new Vector(0, player.Height/3), "tears"); 958 // return; 959 // } 960 961 // player.UseImprovement(player.Improvement); 962 //} 948 963 949 964 void Loss() … … 956 971 { 957 972 HillBilly billy = player as HillBilly; 958 if (billy == null )973 if (billy == null || billy.Improvement != null) 959 974 return; 960 975 … … 999 1014 } 1000 1015 } 1016 1017 public void ForkThings(HillBilly Owner) 1018 { 1019 PhysicsObject evilClone = new PhysicsObject(Owner.Width, Owner.Height * 0.7); 1020 evilClone.Position = Owner.Position + Owner.FacingDirection.GetVector() * 40 + new Vector(0, -(Owner.Height * 0.3)); 1021 evilClone.Color = Color.Red; 1022 evilClone.IsVisible = false; 1023 evilClone.Tag = "pitchfork"; 1024 evilClone.IgnoresCollisionResponse = true; 1025 evilClone.IgnoresPhysicsLogics = true; 1026 evilClone.LifetimeLeft = TimeSpan.FromSeconds(Owner.Animation.FPS * Owner.Animation.FrameCount); 1027 Add(evilClone); 1028 1029 Owner.PlayAnimation(Owner.Improvement.Animations[1], evilClone.Destroy); 1030 } 1031 1001 1032 1002 1033 protected override void Update(Time time) … … 1039 1070 */ 1040 1071 #endregion 1072 1073 1041 1074 }
Note: See TracChangeset
for help on using the changeset viewer.