Browse Source

build: 🚧 building the prop system

tags/0.1.0
shangfengh 3 years ago
parent
commit
fea0ff0aa4
8 changed files with 85 additions and 65 deletions
  1. +32
    -21
      logic/GameClass/GameObj/Character/Character.BuffManager.cs
  2. +9
    -3
      logic/GameClass/GameObj/Character/Character.Student.cs
  3. +6
    -1
      logic/GameClass/GameObj/Character/Character.cs
  4. +27
    -16
      logic/GameClass/GameObj/Prop.cs
  5. +1
    -1
      logic/Gaming/AttackManager.cs
  6. +6
    -19
      logic/Gaming/PropManager.cs
  7. +2
    -3
      logic/Preparation/Utility/EnumType.cs
  8. +2
    -1
      logic/Preparation/Utility/GameData.cs

+ 32
- 21
logic/GameClass/GameObj/Character/Character.BuffManager.cs View File

@@ -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


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

@@ -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}.");


+ 6
- 1
logic/GameClass/GameObj/Character/Character.cs View File

@@ -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() // 要加锁吗?
{


+ 27
- 16
logic/GameClass/GameObj/Prop.cs View File

@@ -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;
}
/// <summary>
///
///
/// </summary>
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;
}
/// <summary>
/// 矛
/// </summary>
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();
}
}
}
}

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

@@ -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


+ 6
- 19
logic/Gaming/PropManager.cs View File

@@ -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)


+ 2
- 3
logic/Preparation/Utility/EnumType.cs View File

@@ -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 // 职业
{


+ 2
- 1
logic/Preparation/Utility/GameData.cs View File

@@ -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;


Loading…
Cancel
Save