Browse Source

chore: 🚧 Rename UseProp to ConsumeProp

dev
shangfengh 2 years ago
parent
commit
35e3c33fb3
6 changed files with 25 additions and 26 deletions
  1. +0
    -3
      logic/GameClass/GameObj/Character/Character.Skill.cs
  2. +19
    -17
      logic/GameClass/GameObj/Character/Character.cs
  3. +1
    -1
      logic/Gaming/CharacterManager.cs
  4. +1
    -1
      logic/Gaming/Game.cs
  5. +3
    -3
      logic/Gaming/PropManager.cs
  6. +1
    -1
      logic/Server/RpcServices.cs

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

@@ -50,9 +50,6 @@ namespace GameClass.GameObj
{ {
this.ActiveSkillDictionary.Add(activeSkill, SkillFactory.FindActiveSkill(activeSkill)); this.ActiveSkillDictionary.Add(activeSkill, SkillFactory.FindActiveSkill(activeSkill));
} }

// UsePassiveSkill(); //这一过程放到gamestart时进行

Debugger.Output(this, "constructed!"); Debugger.Output(this, "constructed!");
} }
} }

+ 19
- 17
logic/GameClass/GameObj/Character/Character.cs View File

@@ -306,7 +306,7 @@ namespace GameClass.GameObj
} }
public double OriVampire { get; protected set; } public double OriVampire { get; protected set; }
#endregion #endregion
#region 状态相关的基本属性与方法
#region 查询状态相关的基本属性与方法
private PlayerStateType playerState = PlayerStateType.Null; private PlayerStateType playerState = PlayerStateType.Null;
public PlayerStateType PlayerState public PlayerStateType PlayerState
{ {
@@ -370,6 +370,8 @@ namespace GameClass.GameObj
|| playerState == PlayerStateType.Stunned || playerState == PlayerStateType.Charmed || playerState == PlayerStateType.Stunned || playerState == PlayerStateType.Charmed
|| playerState == PlayerStateType.Null || playerState == PlayerStateType.Moving); || playerState == PlayerStateType.Null || playerState == PlayerStateType.Moving);
} }
#endregion
#region 更改状态相关的属性和方法
private GameObj? whatInteractingWith = null; private GameObj? whatInteractingWith = null;
public GameObj? WhatInteractingWith public GameObj? WhatInteractingWith
{ {
@@ -382,19 +384,6 @@ namespace GameClass.GameObj
} }
} }


public bool StartThread(long stateNum, RunningStateType runningState)
{
lock (ActionLock)
{
if (this.StateNum == stateNum)
{
this.runningState = runningState;
return true;
}
}
return false;
}

private long ChangePlayerState(RunningStateType running, PlayerStateType value = PlayerStateType.Null, GameObj? gameObj = null) private long ChangePlayerState(RunningStateType running, PlayerStateType value = PlayerStateType.Null, GameObj? gameObj = null)
{ {
//只能被SetPlayerState引用 //只能被SetPlayerState引用
@@ -572,6 +561,19 @@ namespace GameClass.GameObj
} }
} }


public bool StartThread(long stateNum, RunningStateType runningState)
{
lock (ActionLock)
{
if (this.StateNum == stateNum)
{
this.runningState = runningState;
return true;
}
}
return false;
}

public bool TryToRemoveFromGame(PlayerStateType playerStateType) public bool TryToRemoveFromGame(PlayerStateType playerStateType)
{ {
lock (actionLock) lock (actionLock)
@@ -641,7 +643,7 @@ namespace GameClass.GameObj
/// 使用物品栏中的道具 /// 使用物品栏中的道具
/// </summary> /// </summary>
/// <returns>被使用的道具</returns> /// <returns>被使用的道具</returns>
public Gadget UseProp(int indexing)
public Gadget ConsumeProp(int indexing)
{ {
if (indexing < 0 || indexing >= GameData.maxNumOfPropInPropInventory) if (indexing < 0 || indexing >= GameData.maxNumOfPropInPropInventory)
return new NullProp(); return new NullProp();
@@ -654,7 +656,7 @@ namespace GameClass.GameObj
} }
} }


public Gadget UseProp(PropType propType)
public Gadget ConsumeProp(PropType propType)
{ {
if (propType == PropType.Null) if (propType == PropType.Null)
{ {
@@ -689,7 +691,7 @@ namespace GameClass.GameObj
return new NullProp(); return new NullProp();
} }


public bool UseTool(PropType propType)
public bool UseTool(PropType propType)//占用道具,使其不能重复使用和被消耗
{ {
lock (inventoryLock) lock (inventoryLock)
{ {


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

@@ -393,7 +393,7 @@ namespace Gaming


for (int i = 0; i < GameData.maxNumOfPropInPropInventory; i++) for (int i = 0; i < GameData.maxNumOfPropInPropInventory; i++)
{ {
Gadget? prop = player.UseProp(i);
Gadget? prop = player.ConsumeProp(i);
if (prop != null) if (prop != null)
{ {
prop.ReSetPos(player.Position); prop.ReSetPos(player.Position);


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

@@ -238,7 +238,7 @@ namespace Gaming
Character? player = gameMap.FindPlayerToAction(playerID); Character? player = gameMap.FindPlayerToAction(playerID);
if (player != null) if (player != null)
{ {
propManager.UseProp(player, propType);
propManager.ConsumeProp(player, propType);
} }
} }
public void ThrowProp(long playerID, PropType propType = PropType.Null) public void ThrowProp(long playerID, PropType propType = PropType.Null)


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

@@ -17,11 +17,11 @@ namespace Gaming
private readonly CharacterManager characterManager; private readonly CharacterManager characterManager;
private readonly List<XY> availableCellForGenerateProp; private readonly List<XY> availableCellForGenerateProp;


public void UseProp(Character player, PropType propType)
public void ConsumeProp(Character player, PropType propType)
{ {
if (player.CharacterType == CharacterType.Robot || player.IsRemoved) if (player.CharacterType == CharacterType.Robot || player.IsRemoved)
return; return;
Gadget prop = player.UseProp(propType);
Gadget prop = player.ConsumeProp(propType);
switch (prop.GetPropType()) switch (prop.GetPropType())
{ {
case PropType.ShieldOrSpear: case PropType.ShieldOrSpear:
@@ -117,7 +117,7 @@ namespace Gaming
{ {
if (!gameMap.Timer.IsGaming || player.IsRemoved) if (!gameMap.Timer.IsGaming || player.IsRemoved)
return; return;
Gadget prop = player.UseProp(propType);
Gadget prop = player.ConsumeProp(propType);
if (prop.GetPropType() == PropType.Null) if (prop.GetPropType() == PropType.Null)
return; return;




+ 1
- 1
logic/Server/RpcServices.cs View File

@@ -305,7 +305,7 @@ namespace Server
public override Task<BoolRes> UseProp(PropMsg request, ServerCallContext context) public override Task<BoolRes> UseProp(PropMsg request, ServerCallContext context)
{ {
#if DEBUG #if DEBUG
Console.WriteLine($"UseProp ID: {request.PlayerId}");
Console.WriteLine($"ConsumeProp ID: {request.PlayerId}");
#endif #endif
BoolRes boolRes = new(); BoolRes boolRes = new();
if (request.PlayerId >= spectatorMinPlayerID) if (request.PlayerId >= spectatorMinPlayerID)


Loading…
Cancel
Save