Browse Source

refactor: 🎨 delete the original class "PlaceType",and change MapInfoType into PlaceType

tags/0.1.0
shangfengh 2 years ago
parent
commit
06f1007a03
11 changed files with 51 additions and 77 deletions
  1. +1
    -1
      logic/GameClass/GameObj/Map/Doorway.cs
  2. +1
    -1
      logic/GameClass/GameObj/Map/EmergencyExit.cs
  3. +1
    -1
      logic/GameClass/GameObj/Map/Generator.cs
  4. +13
    -31
      logic/GameClass/GameObj/Map/Map.cs
  5. +1
    -1
      logic/GameClass/GameObj/Map/Wall.cs
  6. +1
    -1
      logic/GameClass/GameObj/OutOfBoundBlock.cs
  7. +1
    -1
      logic/GameClass/GameObj/Prop.cs
  8. +1
    -1
      logic/GameClass/Skill/PassiveSkill.cs
  9. +1
    -1
      logic/Gaming/PropManager.cs
  10. +1
    -9
      logic/Preparation/Utility/EnumType.cs
  11. +29
    -29
      logic/Server/CopyInfo.cs

+ 1
- 1
logic/GameClass/GameObj/Map/Doorway.cs View File

@@ -9,7 +9,7 @@ namespace GameClass.GameObj
public class Doorway : GameObj
{
public Doorway(XY initPos) :
base(initPos, GameData.numOfPosGridPerCell / 2, PlaceType.Land, GameObjType.Doorway)
base(initPos, GameData.numOfPosGridPerCell / 2, PlaceType.Null, GameObjType.Doorway)
{
this.CanMove = false;
}


+ 1
- 1
logic/GameClass/GameObj/Map/EmergencyExit.cs View File

@@ -9,7 +9,7 @@ namespace GameClass.GameObj
public class EmergencyExit : GameObj
{
public EmergencyExit(XY initPos) :
base(initPos, GameData.numOfPosGridPerCell / 2, PlaceType.Land, GameObjType.EmergencyExit)
base(initPos, GameData.numOfPosGridPerCell / 2, PlaceType.Null, GameObjType.EmergencyExit)
{
this.CanMove = false;
}


+ 1
- 1
logic/GameClass/GameObj/Map/Generator.cs View File

@@ -8,7 +8,7 @@ namespace GameClass.GameObj
public class Generator : GameObj
{
public Generator(XY initPos) :
base(initPos, GameData.numOfPosGridPerCell / 2, PlaceType.Land, GameObjType.Generator)
base(initPos, GameData.numOfPosGridPerCell / 2, PlaceType.Null, GameObjType.Generator)
{
this.CanMove = false;
}


+ 13
- 31
logic/GameClass/GameObj/Map/Map.cs View File

@@ -22,19 +22,11 @@ namespace GameClass.GameObj
{
try
{
uint type = ProtoGameMap[obj.Position.x / GameData.numOfPosGridPerCell, obj.Position.y / GameData.numOfPosGridPerCell];
if (type == 2)
return PlaceType.Grass1;
else if (type == 3)
return PlaceType.Grass2;
else if (type == 4)
return PlaceType.Grass3;
else
return PlaceType.Land; // 其他情况均返回land
return (PlaceType)ProtoGameMap[obj.Position.x / GameData.numOfPosGridPerCell, obj.Position.y / GameData.numOfPosGridPerCell];
}
catch
{
return PlaceType.Land;
return PlaceType.Null;
}
}

@@ -42,21 +34,11 @@ namespace GameClass.GameObj
{
try
{
switch (ProtoGameMap[pos.x / GameData.numOfPosGridPerCell, pos.y / GameData.numOfPosGridPerCell])
{
case 2:
return PlaceType.Grass1;
case 3:
return PlaceType.Grass2;
case 4:
return PlaceType.Grass3;
default:
return PlaceType.Land;
}
return (PlaceType)ProtoGameMap[pos.x / GameData.numOfPosGridPerCell, pos.y / GameData.numOfPosGridPerCell];
}
catch
{
return PlaceType.Land;
return PlaceType.Null;
}
}

@@ -114,7 +96,7 @@ namespace GameClass.GameObj
{
switch (mapResource[i, j])
{
case (uint)MapInfoObjType.Wall:
case (uint)PlaceType.Wall:
{
GameObjLockDict[GameObjType.Wall].EnterWriteLock();
try
@@ -127,7 +109,7 @@ namespace GameClass.GameObj
}
break;
}
case (uint)MapInfoObjType.Doorway:
case (uint)PlaceType.Doorway:
{
GameObjLockDict[GameObjType.Doorway].EnterWriteLock();
try
@@ -141,7 +123,7 @@ namespace GameClass.GameObj
break;
}

case (uint)MapInfoObjType.EmergencyExit:
case (uint)PlaceType.EmergencyExit:
{
GameObjLockDict[GameObjType.EmergencyExit].EnterWriteLock();
try
@@ -154,7 +136,7 @@ namespace GameClass.GameObj
}
break;
}
case (uint)MapInfoObjType.Generator:
case (uint)PlaceType.Generator:
{
GameObjLockDict[GameObjType.Generator].EnterWriteLock();
try
@@ -167,11 +149,11 @@ namespace GameClass.GameObj
}
break;
}
case (uint)MapInfoObjType.BirthPoint1:
case (uint)MapInfoObjType.BirthPoint2:
case (uint)MapInfoObjType.BirthPoint3:
case (uint)MapInfoObjType.BirthPoint4:
case (uint)MapInfoObjType.BirthPoint5:
case (uint)PlaceType.BirthPoint1:
case (uint)PlaceType.BirthPoint2:
case (uint)PlaceType.BirthPoint3:
case (uint)PlaceType.BirthPoint4:
case (uint)PlaceType.BirthPoint5:
{
birthPointList.Add(mapResource[i, j], GameData.GetCellCenterPos(i, j));
break;


+ 1
- 1
logic/GameClass/GameObj/Map/Wall.cs View File

@@ -8,7 +8,7 @@ namespace GameClass.GameObj
public class Wall : GameObj
{
public Wall(XY initPos) :
base(initPos, GameData.numOfPosGridPerCell / 2, PlaceType.Land, GameObjType.Wall)
base(initPos, GameData.numOfPosGridPerCell / 2, PlaceType.Null, GameObjType.Wall)
{
this.CanMove = false;
}


+ 1
- 1
logic/GameClass/GameObj/OutOfBoundBlock.cs View File

@@ -9,7 +9,7 @@ namespace GameClass.GameObj
public class OutOfBoundBlock : GameObj, IOutOfBound
{
public OutOfBoundBlock(XY initPos) :
base(initPos, int.MaxValue, PlaceType.Land, GameObjType.OutOfBoundBlock)
base(initPos, int.MaxValue, PlaceType.Null, GameObjType.OutOfBoundBlock)
{
this.CanMove = false;
}


+ 1
- 1
logic/GameClass/GameObj/Prop.cs View File

@@ -22,7 +22,7 @@ namespace GameClass.GameObj
public abstract PropType GetPropType();

public Prop(XY initPos, int radius = GameData.PropRadius) :
base(initPos, radius, PlaceType.Land, GameObjType.Prop)
base(initPos, radius, PlaceType.Null, GameObjType.Prop)
{
this.CanMove = false;
this.moveSpeed = GameData.PropMoveSpeed;


+ 1
- 1
logic/GameClass/Skill/PassiveSkill.cs View File

@@ -89,7 +89,7 @@ namespace GameClass.Skill // 被动技能开局时就释放,持续到游戏
{
lastPlace = nowPlace;
nowPlace = player.Place;
if ((lastPlace == PlaceType.Grass1 || lastPlace == PlaceType.Grass2 || lastPlace == PlaceType.Grass3) && nowPlace == PlaceType.Land)
if ((lastPlace == PlaceType.Grass) && nowPlace == PlaceType.Null)
{
if (!speedup)
{


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

@@ -234,7 +234,7 @@ namespace Gaming
{
for (int j = 0; j < gameMap.ProtoGameMap.GetLength(1); j++)
{
if (gameMap.ProtoGameMap[i, j] == (int)MapInfoObjType.Null)
if (gameMap.ProtoGameMap[i, j] == (int)PlaceType.Null)
{
availableCellForGenerateProp.Add(GameData.GetCellCenterPos(i, j));
}


+ 1
- 9
logic/Preparation/Utility/EnumType.cs View File

@@ -42,14 +42,6 @@ namespace Preparation.Utility
Circle = 1, // 子弹和人物为圆形,格子为方形
Square = 2
}
public enum PlaceType // 位置标志,包括陆地,草丛。游戏中每一帧都要刷新各个物体的该属性
{
Null = 0,
Land = 1,
Grass1 = 2,
Grass2 = 3,
Grass3 = 4,
}
public enum BulletType // 子弹类型
{
Null = 0,
@@ -108,7 +100,7 @@ namespace Preparation.Utility
Spear = 4
}

public enum MapInfoObjType
public enum PlaceType
{
Null = 0,
BirthPoint1 = 1,//必须从1开始


+ 29
- 29
logic/Server/CopyInfo.cs View File

@@ -77,23 +77,23 @@ namespace Server
}
switch (player.Place)
{
case Preparation.Utility.PlaceType.Land:
msg.MessageOfCharacter.Place = Communication.Proto.PlaceType.Land;
case Preparation.Utility.PlacccceType.Land:
msg.MessageOfCharacter.Place = Communication.Proto.PlacccceType.Land;
break;
case Preparation.Utility.PlaceType.Grass1:
msg.MessageOfCharacter.Place = Communication.Proto.PlaceType.Grass1;
case Preparation.Utility.PlacccceType.Grass1:
msg.MessageOfCharacter.Place = Communication.Proto.PlacccceType.Grass1;
break;
case Preparation.Utility.PlaceType.Grass2:
msg.MessageOfCharacter.Place = Communication.Proto.PlaceType.Grass2;
case Preparation.Utility.PlacccceType.Grass2:
msg.MessageOfCharacter.Place = Communication.Proto.PlacccceType.Grass2;
break;
case Preparation.Utility.PlaceType.Grass3:
msg.MessageOfCharacter.Place = Communication.Proto.PlaceType.Grass3;
case Preparation.Utility.PlacccceType.Grass3:
msg.MessageOfCharacter.Place = Communication.Proto.PlacccceType.Grass3;
break;
// case Preparation.Utility.PlaceType.Invisible:
// msg.MessageOfCharacter.Place = Communication.Proto.PlaceType.Invisible;
// case Preparation.Utility.PlacccceType.Invisible:
// msg.MessageOfCharacter.Place = Communication.Proto.PlacccceType.Invisible;
// break;
default:
msg.MessageOfCharacter.Place = Communication.Proto.PlaceType.NullPlaceType;
msg.MessageOfCharacter.Place = Communication.Proto.PlacccceType.NullPlaceType;
break;
}

@@ -212,20 +212,20 @@ namespace Server
msg.MessageOfBullet.ParentTeamID = bullet.Parent.TeamID;
switch (bullet.Place)
{
case Preparation.Utility.PlaceType.Land:
msg.MessageOfBullet.Place = Communication.Proto.PlaceType.Land;
case Preparation.Utility.PlacccceType.Land:
msg.MessageOfBullet.Place = Communication.Proto.PlacccceType.Land;
break;
case Preparation.Utility.PlaceType.Grass1:
msg.MessageOfBullet.Place = Communication.Proto.PlaceType.Grass1;
case Preparation.Utility.PlacccceType.Grass1:
msg.MessageOfBullet.Place = Communication.Proto.PlacccceType.Grass1;
break;
case Preparation.Utility.PlaceType.Grass2:
msg.MessageOfBullet.Place = Communication.Proto.PlaceType.Grass2;
case Preparation.Utility.PlacccceType.Grass2:
msg.MessageOfBullet.Place = Communication.Proto.PlacccceType.Grass2;
break;
case Preparation.Utility.PlaceType.Grass3:
msg.MessageOfBullet.Place = Communication.Proto.PlaceType.Grass3;
case Preparation.Utility.PlacccceType.Grass3:
msg.MessageOfBullet.Place = Communication.Proto.PlacccceType.Grass3;
break;
default:
msg.MessageOfBullet.Place = Communication.Proto.PlaceType.NullPlaceType;
msg.MessageOfBullet.Place = Communication.Proto.PlacccceType.NullPlaceType;
break;
}
return msg;
@@ -271,20 +271,20 @@ namespace Server
}
switch (prop.Place)
{
case Preparation.Utility.PlaceType.Land:
msg.MessageOfProp.Place = Communication.Proto.PlaceType.Land;
case Preparation.Utility.PlacccceType.Land:
msg.MessageOfProp.Place = Communication.Proto.PlacccceType.Land;
break;
case Preparation.Utility.PlaceType.Grass1:
msg.MessageOfProp.Place = Communication.Proto.PlaceType.Grass1;
case Preparation.Utility.PlacccceType.Grass1:
msg.MessageOfProp.Place = Communication.Proto.PlacccceType.Grass1;
break;
case Preparation.Utility.PlaceType.Grass2:
msg.MessageOfProp.Place = Communication.Proto.PlaceType.Grass2;
case Preparation.Utility.PlacccceType.Grass2:
msg.MessageOfProp.Place = Communication.Proto.PlacccceType.Grass2;
break;
case Preparation.Utility.PlaceType.Grass3:
msg.MessageOfProp.Place = Communication.Proto.PlaceType.Grass3;
case Preparation.Utility.PlacccceType.Grass3:
msg.MessageOfProp.Place = Communication.Proto.PlacccceType.Grass3;
break;
default:
msg.MessageOfProp.Place = Communication.Proto.PlaceType.NullPlaceType;
msg.MessageOfProp.Place = Communication.Proto.PlacccceType.NullPlaceType;
break;
}
return msg;


Loading…
Cancel
Save