diff --git a/logic/GameClass/GameObj/Character/Character.BuffManager.cs b/logic/GameClass/GameObj/Character/Character.BuffManager.cs
index e0ddb2f..b50f3a4 100644
--- a/logic/GameClass/GameObj/Character/Character.BuffManager.cs
+++ b/logic/GameClass/GameObj/Character/Character.BuffManager.cs
@@ -48,30 +48,28 @@ namespace GameClass.GameObj
buffNode = buffList[(int)buffType].AddLast(bf);
}
ReCalculateFunc();
- if (buffTime != -1)
- {
- new Thread
- (
- () =>
- {
- Thread.Sleep(buffTime);
- try
- {
- lock (buffListLock[(int)buffType])
- {
- buffList[(int)buffType].Remove(buffNode);
- }
- }
- catch
+ new Thread
+ (
+ () =>
+ {
+
+ Thread.Sleep(buffTime);
+ try
+ {
+ lock (buffListLock[(int)buffType])
{
+ buffList[(int)buffType].Remove(buffNode);
}
- ReCalculateFunc();
-
}
- )
- { IsBackground = true }.Start();
- }
+ catch
+ {
+ }
+ ReCalculateFunc();
+
+ }
+ )
+ { IsBackground = true }.Start();
}
public int ReCalculateFloatBuff(BuffType buffType, int orgVal, int maxVal, int minVal)
@@ -111,7 +109,20 @@ namespace GameClass.GameObj
}
}
}
- public void AddAp() => AddBuff(new BuffValue(), -1, BuffType.AddAp, () => { });
+ public bool TryUseShield()
+ {
+ if (HasShield)
+ {
+ lock (buffListLock[(int)BuffType.Shield])
+ {
+ buffList[(int)BuffType.Shield].RemoveFirst();
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public void AddAp(int time) => AddBuff(new BuffValue(), time, BuffType.AddAp, () => { });
public bool HasAp
{
get
diff --git a/logic/GameClass/GameObj/Character/Character.Student.cs b/logic/GameClass/GameObj/Character/Character.Student.cs
index 8c73851..55b6b43 100644
--- a/logic/GameClass/GameObj/Character/Character.Student.cs
+++ b/logic/GameClass/GameObj/Character/Character.Student.cs
@@ -22,16 +22,22 @@ namespace GameClass.GameObj
return false; // 原来已经死了
if (bullet.Parent.TeamID != this.TeamID)
{
- if (HasShield)
+ if (TryUseShield())
{
if (bullet.HasSpear)
- bullet.Parent.AddScore(GameData.TrickerScoreAttackStudent(TrySubHp(bullet.AP)));
+ {
+ int subHp = TrySubHp(bullet.AP);
+ bullet.Parent.AddScore(GameData.TrickerScoreAttackStudent(subHp));
+ bullet.Parent.HP = (int)(bullet.Parent.HP + (bullet.Parent.Vampire * subHp));
+ }
else
return false;
}
else
{
- bullet.Parent.HP = (int)(bullet.Parent.HP + (bullet.Parent.Vampire * TrySubHp(bullet.AP)));
+ int subHp = TrySubHp(bullet.AP + GameData.ApSpearAdd);
+ bullet.Parent.AddScore(GameData.TrickerScoreAttackStudent(subHp));
+ bullet.Parent.HP = (int)(bullet.Parent.HP + (bullet.Parent.Vampire * subHp));
}
#if DEBUG
Console.WriteLine($"PlayerID:{ID} is being shot! Now his hp is {hp}.");
diff --git a/logic/GameClass/GameObj/Character/Character.cs b/logic/GameClass/GameObj/Character/Character.cs
index fd8f33c..e92b544 100644
--- a/logic/GameClass/GameObj/Character/Character.cs
+++ b/logic/GameClass/GameObj/Character/Character.cs
@@ -483,7 +483,7 @@ namespace GameClass.GameObj
public void AddLIFE(int LIFETime) => buffManager.AddLIFE(LIFETime);
public bool HasLIFE => buffManager.HasLIFE;
- public void AddAp() => buffManager.AddAp();
+ public void AddAp(int time) => buffManager.AddAp(time);
public bool HasAp => buffManager.HasAp;
public void AddSpear(int spearTime) => buffManager.AddSpear(spearTime);
@@ -531,6 +531,11 @@ namespace GameClass.GameObj
{
return buffManager.TryAddAp();
}
+
+ public bool TryUseShield()
+ {
+ return buffManager.TryUseShield();
+ }
#endregion
/* public override void Reset() // 要加锁吗?
{
diff --git a/logic/GameClass/GameObj/Prop.cs b/logic/GameClass/GameObj/Prop.cs
index 2116251..f129587 100644
--- a/logic/GameClass/GameObj/Prop.cs
+++ b/logic/GameClass/GameObj/Prop.cs
@@ -60,33 +60,23 @@ namespace GameClass.GameObj
}
public override PropType GetPropType() => PropType.AddLIFE;
}
- public sealed class AddHp : Prop
+ public sealed class AddHpOrAp : Prop
{
- public AddHp(XY initPos, PlaceType placeType) :
+ public AddHpOrAp(XY initPos, PlaceType placeType) :
base(initPos, placeType)
{
}
public override PropType GetPropType() => PropType.AddHpOrAp;
}
///
- /// 护盾
+ /// 矛盾
///
- public sealed class Shield : Prop
+ public sealed class ShieldOrSpear : Prop
{
- public Shield(XY initPos, PlaceType placeType) : base(initPos, placeType)
+ public ShieldOrSpear(XY initPos, PlaceType placeType) : base(initPos, placeType)
{
}
- public override PropType GetPropType() => PropType.Shield;
- }
- ///
- /// 矛
- ///
- public sealed class Spear : Prop
- {
- public Spear(XY initPos, PlaceType placeType) : base(initPos, placeType)
- {
- }
- public override PropType GetPropType() => PropType.Spear;
+ public override PropType GetPropType() => PropType.ShieldOrSpear;
}
public sealed class Key3 : Prop
{
@@ -143,4 +133,25 @@ namespace GameClass.GameObj
// public override PropType GetPropType() => PropType.addCD;
// }
// #endregion
+ public static class PropFactory
+ {
+ public static Prop GetProp(PropType propType, XY pos, PlaceType place)
+ {
+ switch (propType)
+ {
+ case PropType.ShieldOrSpear:
+ return new ShieldOrSpear(pos, place);
+ case PropType.AddHpOrAp:
+ return new AddHpOrAp(pos, place);
+ case PropType.Key3:
+ return new Key3(pos, place);
+ case PropType.Key5:
+ return new Key5(pos, place);
+ case PropType.Key6:
+ return new Key6(pos, place);
+ default:
+ return new NullProp();
+ }
+ }
+ }
}
diff --git a/logic/Gaming/AttackManager.cs b/logic/Gaming/AttackManager.cs
index 12438c6..a7641b4 100644
--- a/logic/Gaming/AttackManager.cs
+++ b/logic/Gaming/AttackManager.cs
@@ -309,7 +309,7 @@ namespace Gaming
if (bullet != null)
{
- bullet.AP += player.TryAddAp() ? GameData.PropAddAp : 0;
+ bullet.AP += player.TryAddAp() ? GameData.ApPropAdd : 0;
bullet.CanMove = true;
gameMap.Add(bullet);
moveEngine.MoveObj(bullet, (int)((bullet.BulletAttackRange - player.Radius - BulletFactory.BulletRadius(player.BulletOfPlayer)) * 1000 / bullet.MoveSpeed), angle); // 这里时间参数除出来的单位要是ms
diff --git a/logic/Gaming/PropManager.cs b/logic/Gaming/PropManager.cs
index c0cdd8a..73a887f 100644
--- a/logic/Gaming/PropManager.cs
+++ b/logic/Gaming/PropManager.cs
@@ -28,11 +28,10 @@ namespace Gaming
Prop prop = player.UseProp(indexing);
switch (prop.GetPropType())
{
- case PropType.Spear:
- player.AddSpear(GameData.PropDuration);
- break;
- case PropType.Shield:
- player.AddShield(GameData.PropDuration);
+ case PropType.ShieldOrSpear:
+ if (player.IsGhost())
+ player.AddSpear(GameData.PropDuration);
+ else player.AddShield(GameData.PropDuration);
break;
case PropType.AddLIFE:
player.AddLIFE(GameData.PropDuration);
@@ -43,7 +42,7 @@ namespace Gaming
case PropType.AddHpOrAp:
if (!player.IsGhost())
player.HP += GameData.basicTreatmentDegree;
- else player.AddAp();
+ else player.AddAp(GameData.PropDuration);
break;
default:
break;
@@ -115,19 +114,7 @@ namespace Gaming
private Prop ProduceOnePropNotKey(Random r, XY Pos)
{
- switch (r.Next(0, GameData.numOfPropTypeNotKey))
- {
- case 0:
- return new AddLIFE(Pos, gameMap.GetPlaceType(Pos));
- case 1:
- return new AddSpeed(Pos, gameMap.GetPlaceType(Pos));
- case 2:
- return new Shield(Pos, gameMap.GetPlaceType(Pos));
- case 3:
- return new Spear(Pos, gameMap.GetPlaceType(Pos));
- default:
- return new NullProp();
- }
+ return PropFactory.GetProp((PropType)r.Next(0, GameData.numOfPropTypeNotKey), Pos, gameMap.GetPlaceType(Pos));
}
private Chest GetChest(Random r)
diff --git a/logic/Preparation/Utility/EnumType.cs b/logic/Preparation/Utility/EnumType.cs
index 8cb3174..1579838 100644
--- a/logic/Preparation/Utility/EnumType.cs
+++ b/logic/Preparation/Utility/EnumType.cs
@@ -66,12 +66,11 @@ namespace Preparation.Utility
Null = 0,
AddSpeed = 1,
AddLIFE = 2,
- Shield = 3,
- Spear = 4,
+ AddHpOrAp = 3,
+ ShieldOrSpear = 4,
Key3 = 5,
Key5 = 6,
Key6 = 7,
- AddHpOrAp = 8,//AddHp,AddAp
}
public enum CharacterType // 职业
{
diff --git a/logic/Preparation/Utility/GameData.cs b/logic/Preparation/Utility/GameData.cs
index 2712659..5e8a679 100644
--- a/logic/Preparation/Utility/GameData.cs
+++ b/logic/Preparation/Utility/GameData.cs
@@ -171,7 +171,8 @@ namespace Preparation.Utility
public const long PropProduceTime = 10000;
public const int PropDuration = 10000;
- public const int PropAddAp = basicApOfGhost * 12 / 10;
+ public const int ApPropAdd = basicApOfGhost * 12 / 10;
+ public const int ApSpearAdd = basicApOfGhost * 6 / 10;
public const int numOfKeyEachArea = 2;
public const int numOfPropTypeNotKey = 4;