Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #22 from TCL606/TCL
Browse files Browse the repository at this point in the history
chore: Move gamobj to GameClass folder and add Skills
  • Loading branch information
Timothy-Liuxf authored Oct 1, 2021
2 parents cdb228c + 7188b01 commit 9155764
Show file tree
Hide file tree
Showing 29 changed files with 364 additions and 147 deletions.
14 changes: 14 additions & 0 deletions logic/GameClass/GameClass.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\FrameRateTask\FrameRateTask.csproj" />
<ProjectReference Include="..\GameEngine\GameEngine.csproj" />
<ProjectReference Include="..\Preparation\Preparation.csproj" />
<ProjectReference Include="..\Server\Server.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
using Preparation.Utility;
using Preparation.GameData;

namespace Preparation.GameObj
namespace GameClass.GameObj
{
/// <summary>
/// 出生点
/// </summary>
public class BirthPoint : ObjOfCharacter
{
public BirthPoint(XYPosition initPos) : base(initPos, Constant.numOfPosGridPerCell, PlaceType.Land)
public BirthPoint(XYPosition initPos) : base(initPos, GameData.numOfPosGridPerCell, PlaceType.Land)
{
this.CanMove = false;
this.Type = GameObjType.BirthPoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Preparation.Interface;
using Preparation.Utility;

namespace Preparation.GameObj
namespace GameClass.GameObj
{
public abstract class Bullet : ObjOfCharacter // LHR摸鱼中...已写完抽象类及一个派生类
{
Expand Down Expand Up @@ -75,7 +75,7 @@ public Bullet0(XYPosition initPos, int radius, int initSpeed, int ap, bool hasSp
public Bullet0(Character player, int radius, int initSpeed, int ap) : base(player, radius, initSpeed, ap) { }
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Circle;
public override double BulletBombRange => Constant.basicBulletBombRange;
public override double BulletBombRange => GameData.basicBulletBombRange;

public override bool CanAttack(GameObj target)
{
Expand All @@ -89,7 +89,7 @@ public AtomBomb(XYPosition initPos, int radius, int initSpeed, int ap, bool hasS
public AtomBomb(Character player, int radius, int initSpeed, int ap) : base(player, radius, initSpeed, ap) { }
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Circle;
public override double BulletBombRange => 3 * Constant.basicBulletBombRange;
public override double BulletBombRange => 3 * GameData.basicBulletBombRange;

public override bool CanAttack(GameObj target)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Preparation.Utility;
using Preparation.GameData;

namespace Preparation.GameObj
namespace GameClass.GameObj
{
public abstract partial class Character
{
Expand Down Expand Up @@ -73,10 +73,10 @@ private int ReCalculateFloatBuff(BuffType buffType, int orgVal, int maxVal, int
}

public void AddMoveSpeed(double add, int buffTime, Action<int> SetNewMoveSpeed, int orgMoveSpeed)
=> AddBuff(new BuffValue(add), buffTime, BuffType.MoveSpeed, () => SetNewMoveSpeed(ReCalculateFloatBuff(BuffType.MoveSpeed, orgMoveSpeed, Constant.MaxSpeed, Constant.MinSpeed)));
=> AddBuff(new BuffValue(add), buffTime, BuffType.MoveSpeed, () => SetNewMoveSpeed(ReCalculateFloatBuff(BuffType.MoveSpeed, orgMoveSpeed, GameData.MaxSpeed, GameData.MinSpeed)));

public void AddAP(double add, int buffTime, Action<int> SetNewAp, int orgAp)
=> AddBuff(new BuffValue(add), buffTime, BuffType.AP, () => SetNewAp(ReCalculateFloatBuff(BuffType.AP, orgAp, Constant.MaxAP, Constant.MinAP)));
=> AddBuff(new BuffValue(add), buffTime, BuffType.AP, () => SetNewAp(ReCalculateFloatBuff(BuffType.AP, orgAp, GameData.MaxAP, GameData.MinAP)));

public void ChangeCD(double discount, int buffTime, Action<int> SetNewCD, int orgCD)
=> AddBuff(new BuffValue(discount), buffTime, BuffType.CD, () => SetNewCD(ReCalculateFloatBuff(BuffType.CD, orgCD, int.MaxValue, 1)));
Expand Down
31 changes: 31 additions & 0 deletions logic/GameClass/GameObj/Character.SkillManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using GameClass.Skill;

namespace GameClass.GameObj
{
public partial class Character
{
private delegate bool ActiveSkill(Character player); //返回值:是否成功释放了技能
private delegate void PassiveSkill(Character player);
ActiveSkill commonSkill;
public bool UseCommonSkill()
{
return commonSkill(this);
}
private bool isCommonSkillAvailable = true; //普通技能可用标志
public bool IsCommonSkillAvailable
{
get => isCommonSkillAvailable;
set
{
lock (gameObjLock)
isCommonSkillAvailable = value;
}
}
PassiveSkill passiveSkill;
public void UsePassiveSkill()
{
passiveSkill(this);
return;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Preparation.Interface;
using Preparation.Utility;

namespace Preparation.GameObj
namespace GameClass.GameObj
{
public abstract partial class Character : GameObj, ICharacter // 负责人LHR摆烂中...该文件下抽象部分类已基本完工,剩下的在buffmanager里写
{
Expand All @@ -27,25 +27,22 @@ private set
}
}
}
public int orgCD { get; protected set; }

private bool isCommonSkillAvailable = true; //普通技能可用标志
public bool IsCommonSkillAvailable
{
get => isCommonSkillAvailable;
set
{
lock(gameObjLock)
isCommonSkillAvailable = value;
}
}
public int OrgCD { get; protected set; }
protected int maxBulletNum;
public int MaxBulletNum => maxBulletNum; // 人物最大子弹数
protected int bulletNum;
public int BulletNum => bulletNum; // 目前持有的子弹数
public int MaxHp { get; protected set; } // 最大血量
protected int hp;
public int HP => hp;
public int HP
{
get => hp;
set
{
lock (gameObjLock)
hp = value;
}
}
private int deathCount = 0;
public int DeathCount => deathCount; // 玩家的死亡次数

Expand All @@ -70,7 +67,7 @@ private set
private int attackRange;
public int AttackRange => attackRange;

private double vampire = 0; // 回血率:0-1之间
private double vampire; // 回血率:0-1之间
public double Vampire
{
get => vampire;
Expand All @@ -87,6 +84,8 @@ public double Vampire
vampire = value;
}
}
public double oriVampire = 0;

private int level = 1;
public int Level
{
Expand All @@ -107,13 +106,6 @@ public Bullet BulletOfPlayer
bulletOfPlayer = value;
}
}

private delegate bool CommonSkill(Character player); //返回是否成功释放
CommonSkill commonSkill;
public bool UseCommonSkill()
{
return commonSkill(this);
}
/*private Prop? propInventory;
public Prop? PropInventory //持有的道具
{
Expand Down Expand Up @@ -379,28 +371,28 @@ private void TryActivatingLIFE()
#endregion
public override void Reset()
{
/*AddDeathCount();
AddDeathCount();
base.Reset();
this.moveSpeed = OrgMoveSpeed;
hp = MaxHp;
ap = OrgAp;
PropInventory = null;
bulletNum = maxBulletNum / 2;
buffManeger.ClearAll();*/
buffManeger.ClearAll();
}
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Circle;
protected override bool IgnoreCollideExecutor(IGameObj targetObj)
{
/*if (targetObj is BirthPoint && object.ReferenceEquals(((BirthPoint)targetObj).Parent, this)) // 自己的出生点可以忽略碰撞
if (targetObj is BirthPoint && object.ReferenceEquals(((BirthPoint)targetObj).Parent, this)) // 自己的出生点可以忽略碰撞
{
return true;
}
else if (targetObj is Mine && ((Mine)targetObj).Parent?.TeamID == TeamID) // 自己队的炸弹忽略碰撞
{
return true;
}
return false;*/
return false;
}
public Character(XYPosition initPos, int initRadius, PlaceType initPlace,int initSpeed) :base(initPos,initRadius,initPlace)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Preparation.Interface;
using Preparation.Utility;

namespace Preparation.GameObj
namespace GameClass.GameObj
{
/// <summary>
/// 一切游戏元素的总基类,与THUAI4不同,继承IMoveable接口(出于一切物体其实都是可运动的指导思想)——LHR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
using Preparation.Utility;
using Preparation.GameData;

namespace Preparation.GameObj
namespace GameClass.GameObj
{
/// <summary>
/// 草丛
/// </summary>
public abstract class Grass : GameObj
{
public Grass(XYPosition initPos) : base(initPos, Constant.numOfPosGridPerCell, PlaceType.Land)
public Grass(XYPosition initPos) : base(initPos, GameData.numOfPosGridPerCell, PlaceType.Land)
{
this.CanMove = false;
this.Type = GameObjType.Grass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Preparation.Utility;
using Preparation.GameData;

namespace Preparation.GameObj
namespace GameClass.GameObj
{
public partial class Map:IMap
{
Expand All @@ -21,25 +21,28 @@ public partial class Map:IMap
public ReaderWriterLockSlim ObjListLock => objListLock;
public bool IsWall(XYPosition pos)
{
return MapInfo.defaultMap[pos.x / Constant.numOfPosGridPerCell, pos.y / Constant.numOfPosGridPerCell] == 1;
return MapInfo.defaultMap[pos.x / GameData.numOfPosGridPerCell, pos.y / GameData.numOfPosGridPerCell] == 1;
}
public bool OutOfBound(XYPosition pos)
public bool IsOutOfBound(IGameObj obj)
{
return pos.x >= Constant.lengthOfMap || pos.x <= 0 || pos.y >= Constant.lengthOfMap || pos.y <= 0;
return obj.Position.x >= GameData.lengthOfMap - obj.Radius
|| obj.Position.x <= obj.Radius
|| obj.Position.y >= GameData.lengthOfMap - obj.Radius
|| obj.Position.y <= obj.Radius;
}
public IOutOfBound GetOutOfBound(XYPosition pos)
{
return new OutOfBoundBlock(pos);
}
public IGameObj GetCell(XYPosition pos)
{
if (MapInfo.defaultMap[pos.x / Constant.numOfPosGridPerCell, pos.y / Constant.numOfPosGridPerCell] == 1)
if (MapInfo.defaultMap[pos.x / GameData.numOfPosGridPerCell, pos.y / GameData.numOfPosGridPerCell] == 1)
return new Wall(pos);
else if (MapInfo.defaultMap[pos.x / Constant.numOfPosGridPerCell, pos.y / Constant.numOfPosGridPerCell] == 2)
else if (MapInfo.defaultMap[pos.x / GameData.numOfPosGridPerCell, pos.y / GameData.numOfPosGridPerCell] == 2)
return new Grass1(pos);
else if (MapInfo.defaultMap[pos.x / Constant.numOfPosGridPerCell, pos.y / Constant.numOfPosGridPerCell] == 3)
else if (MapInfo.defaultMap[pos.x / GameData.numOfPosGridPerCell, pos.y / GameData.numOfPosGridPerCell] == 3)
return new Grass2(pos);
else if (MapInfo.defaultMap[pos.x / Constant.numOfPosGridPerCell, pos.y / Constant.numOfPosGridPerCell] == 4)
else if (MapInfo.defaultMap[pos.x / GameData.numOfPosGridPerCell, pos.y / GameData.numOfPosGridPerCell] == 4)
return new Grass3(pos);
else return new OutOfBoundBlock(pos);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Threading;
using Preparation.Interface;

namespace Preparation.GameObj
namespace GameClass.GameObj
{
public partial class Map
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Preparation.Utility;
using Preparation.GameData;

namespace Preparation.GameObj
namespace GameClass.GameObj
{
public static class MapInfo
{
Expand All @@ -12,7 +12,7 @@ public static class MapInfo
/// <returns></returns>
public static PlaceType GetPlaceType(GameObj obj)
{
uint type = defaultMap[obj.Position.x / Constant.numOfPosGridPerCell, obj.Position.y / Constant.numOfPosGridPerCell];
uint type = defaultMap[obj.Position.x / GameData.numOfPosGridPerCell, obj.Position.y / GameData.numOfPosGridPerCell];
if (type == 1)
return PlaceType.Grass1;
else if (type == 2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Preparation.Interface;
using Preparation.Utility;

namespace Preparation.GameObj
namespace GameClass.GameObj
{
/// <summary>
/// 所有物,玩家可以存进“物品栏”的东西
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Preparation.Interface;
using Preparation.Utility;

namespace Preparation.GameObj
namespace GameClass.GameObj
{
/// <summary>
/// 逻辑墙
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Preparation.Interface;
using Preparation.Utility;

namespace Preparation.GameObj
namespace GameClass.GameObj
{
public abstract class Prop : ObjOfCharacter //LHR摆烂中...抽象类及所有增益道具已写完
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using Preparation.Interface;
using Preparation.Utility;
using Preparation.Utility;
using Preparation.GameData;

namespace Preparation.GameObj
namespace GameClass.GameObj
{
/// <summary>
/// 墙体
/// </summary>
public class Wall : GameObj
{
public Wall(XYPosition initPos) : base(initPos, Constant.numOfPosGridPerCell, PlaceType.Land)
public Wall(XYPosition initPos) : base(initPos, GameData.numOfPosGridPerCell, PlaceType.Land)
{
this.CanMove = false;
this.Type = GameObjType.Wall;
Expand Down
Loading

0 comments on commit 9155764

Please sign in to comment.