Browse Source

Merge pull request #182 from shangfengh/new

feat:  support UseProp and ThrowProp by default
tags/0.1.0
gsy1519 GitHub 2 years ago
parent
commit
124eb0c76d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 7 deletions
  1. +12
    -3
      logic/GameClass/GameObj/Character/Character.cs
  2. +3
    -3
      logic/Gaming/Game.cs
  3. +1
    -1
      logic/Gaming/PropManager.cs

+ 12
- 3
logic/GameClass/GameObj/Character/Character.cs View File

@@ -464,11 +464,20 @@ namespace GameClass.GameObj
{ {
lock (gameObjLock) lock (gameObjLock)
{ {
foreach (Prop prop in propInventory)
if (propType == PropType.Null)
{ {
if (prop.GetPropType() == propType)
return prop;
foreach (Prop prop in propInventory)
{
if (prop.GetPropType() != PropType.Null)
return prop;
}
} }
else
foreach (Prop prop in propInventory)
{
if (prop.GetPropType() == propType)
return prop;
}
return new NullProp(); return new NullProp();
} }
} }


+ 3
- 3
logic/Gaming/Game.cs View File

@@ -358,17 +358,17 @@ namespace Gaming
_ = attackManager.Attack(player, angle); _ = attackManager.Attack(player, angle);
} }
} }
public void UseProp(long playerID, PropType propType)
public void UseProp(long playerID, PropType propType = PropType.Null)
{ {
if (!gameMap.Timer.IsGaming) if (!gameMap.Timer.IsGaming)
return; return;
Character? player = gameMap.FindPlayer(playerID); Character? player = gameMap.FindPlayer(playerID);
if (player != null) if (player != null)
{ {
propManager.UseProp(player, propType);
PropManager.UseProp(player, propType);
} }
} }
public void ThrowProp(long playerID, PropType propType)
public void ThrowProp(long playerID, PropType propType = PropType.Null)
{ {
if (!gameMap.Timer.IsGaming) if (!gameMap.Timer.IsGaming)
return; return;


+ 1
- 1
logic/Gaming/PropManager.cs View File

@@ -21,7 +21,7 @@ namespace Gaming


private readonly List<XY> availableCellForGenerateProp; private readonly List<XY> availableCellForGenerateProp;


public void UseProp(Character player, PropType propType)
public static void UseProp(Character player, PropType propType)
{ {
if (player.IsResetting) if (player.IsResetting)
return; return;


Loading…
Cancel
Save