Skip to content

Commit

Permalink
Added knife and fixed pick up weapon bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuj committed Mar 17, 2022
1 parent 7e8f54c commit 0ddf39c
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 21 deletions.
Binary file modified Assets/LancasterGuy_Knife_Attacked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/LancasterGuy_Knife_Resting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,14 @@ public void ScanAndPickUpEntities()
{
if (Scene.GridToTileLocation(entity.Position) == Scene.GridToTileLocation(this.Position) && entity != doNotPickUp)
{
//UNCOMMENT
// This means, we have an entity that we can pick up.
entity.PickedUp();
entity.Initialise(Scene, Layer);
if (entity is Weapon)
{
weapon = (Weapon)entity;
weapon.SetCharacter(this);
}
entity.PickedUp();
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions Characters/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ private float clamp(float val, float min, float max)
else return val;
}

public void SpawnRandomWeapon()
public void SpawnRandomKnife()
{
Fists e = new Fists();
e.SetCharacter(this);
Knife k = new Knife();
k.Initialise(Scene, Layer);
k.Spawn(Position);
}

public void Respawn()
Expand Down
18 changes: 2 additions & 16 deletions Entities/Weapons/Knife.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,11 @@ namespace CampusCrawl.Entities.Weapons
{
internal class Knife : Weapon
{
int lungeSize = 10;
public Knife() : base("Assets/Knife.png", "Knife")
{
damage = 5;
damage = 2;
range = 1;
knockback = 20;
}

public void Lunge(float multiplier,bool player)
{
range += 2;
damage += 1 * multiplier;
float[] attackDirection = character.mouseDirection();
if (!player)
attackDirection = character.attackDirection;
character.PushSelf(-(int)attackDirection[0] * lungeSize, -(int)attackDirection[1] * lungeSize);
Attack(true,player);
damage -= 1 * multiplier;
range -= 2;
knockback = 15;
}
}
}
1 change: 1 addition & 0 deletions Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void StartGame(Point location)
mainPlayer.SetLayer("Objects");
BaseScene scene = (BaseScene)TileEngine.Instance.GetScene();
mainPlayer.CreateAndSetWeapon(new Fists());
mainPlayer.SpawnRandomKnife();
}
public override void Initialize()
{
Expand Down
Binary file modified campus-crawl.teproj
Binary file not shown.

0 comments on commit 0ddf39c

Please sign in to comment.