Browse Source

fix: 🐛 change Environment.TickCount64 to Environment.TickCount

tags/v0.1.0
shangfengh 2 years ago
parent
commit
0cb4072260
11 changed files with 34 additions and 34 deletions
  1. +3
    -3
      logic/GameClass/GameObj/Map/Chest.cs
  2. +4
    -4
      logic/GameClass/GameObj/Map/Door.cs
  3. +5
    -5
      logic/GameClass/GameObj/Map/Doorway.cs
  4. +3
    -3
      logic/GameClass/GameObj/Map/MapGameTimer.cs
  5. +1
    -1
      logic/Gaming/AttackManager.cs
  6. +1
    -1
      logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs
  7. +1
    -1
      logic/Gaming/SkillManager/SkillManager.PassiveSkill.cs
  8. +1
    -1
      logic/Preparation/Interface/IDoorway.cs
  9. +5
    -5
      logic/Preparation/Interface/ISkill.cs
  10. +9
    -9
      logic/Server/CopyInfo.cs
  11. +1
    -1
      logic/Server/GameServer.cs

+ 3
- 3
logic/GameClass/GameObj/Map/Chest.cs View File

@@ -19,8 +19,8 @@ namespace GameClass.GameObj
private readonly Gadget[] propInChest = new Gadget[GameData.maxNumOfPropInChest] { new NullProp(), new NullProp() }; private readonly Gadget[] propInChest = new Gadget[GameData.maxNumOfPropInChest] { new NullProp(), new NullProp() };
public Gadget[] PropInChest => propInChest; public Gadget[] PropInChest => propInChest;


private int openStartTime = 0;
public int OpenStartTime => openStartTime;
private long openStartTime = 0;
public long OpenStartTime => openStartTime;
private Character? whoOpen = null; private Character? whoOpen = null;
public Character? WhoOpen => whoOpen; public Character? WhoOpen => whoOpen;
public bool Open(Character character) public bool Open(Character character)
@@ -28,7 +28,7 @@ namespace GameClass.GameObj
lock (GameObjReaderWriterLock) lock (GameObjReaderWriterLock)
{ {
if (whoOpen != null) return false; if (whoOpen != null) return false;
openStartTime = Environment.TickCount;
openStartTime = Environment.TickCount64;
whoOpen = character; whoOpen = character;
} }
return true; return true;


+ 4
- 4
logic/GameClass/GameObj/Map/Door.cs View File

@@ -70,8 +70,8 @@ namespace GameClass.GameObj
} }
} }


private int openStartTime = 0;
public int OpenStartTime
private long openStartTime = 0;
public long OpenStartTime
{ {
get get
{ {
@@ -86,7 +86,7 @@ namespace GameClass.GameObj
{ {
if (isOpen) return false; if (isOpen) return false;
if (whoLockOrOpen != null) return false; if (whoLockOrOpen != null) return false;
openStartTime = Environment.TickCount;
openStartTime = Environment.TickCount64;
whoLockOrOpen = character; whoLockOrOpen = character;
return true; return true;
} }
@@ -97,7 +97,7 @@ namespace GameClass.GameObj
{ {
if (whoLockOrOpen != null) if (whoLockOrOpen != null)
{ {
if ((Environment.TickCount - openStartTime) >= GameData.degreeOfLockingOrOpeningTheDoor / whoLockOrOpen.SpeedOfOpeningOrLocking)
if ((Environment.TickCount64 - openStartTime) >= GameData.degreeOfLockingOrOpeningTheDoor / whoLockOrOpen.SpeedOfOpeningOrLocking)
isOpen = true; isOpen = true;
whoLockOrOpen = null; whoLockOrOpen = null;
} }


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

@@ -39,8 +39,8 @@ namespace GameClass.GameObj
} }
} }


private int openStartTime = 0;
public int OpenStartTime
private long openStartTime = 0;
public long OpenStartTime
{ {
get get
{ {
@@ -53,7 +53,7 @@ namespace GameClass.GameObj
lock (gameObjLock) lock (gameObjLock)
{ {
if (!powerSupply || openStartTime > 0) return false; if (!powerSupply || openStartTime > 0) return false;
openStartTime = Environment.TickCount;
openStartTime = Environment.TickCount64;
return true; return true;
} }
} }
@@ -62,14 +62,14 @@ namespace GameClass.GameObj
{ {
lock (gameObjLock) lock (gameObjLock)
{ {
if (Environment.TickCount - openStartTime + openDegree >= GameData.degreeOfOpenedDoorway)
if (Environment.TickCount64 - openStartTime + openDegree >= GameData.degreeOfOpenedDoorway)
{ {
openDegree = GameData.degreeOfOpenedDoorway; openDegree = GameData.degreeOfOpenedDoorway;
return true; return true;
} }
else else
{ {
openDegree = Environment.TickCount - openStartTime + openDegree;
openDegree = (int)(Environment.TickCount64 - openStartTime) + openDegree;
openStartTime = 0; openStartTime = 0;
return false; return false;
} }


+ 3
- 3
logic/GameClass/GameObj/Map/MapGameTimer.cs View File

@@ -12,8 +12,8 @@ namespace GameClass.GameObj


public class GameTimer : ITimer public class GameTimer : ITimer
{ {
private int startTime;
public int nowTime() => Environment.TickCount - startTime;
private long startTime;
public int nowTime() => (int)(Environment.TickCount64 - startTime);


private bool isGaming = false; private bool isGaming = false;
public bool IsGaming public bool IsGaming
@@ -35,7 +35,7 @@ namespace GameClass.GameObj
if (isGaming) if (isGaming)
return false; return false;
isGaming = true; isGaming = true;
startTime = Environment.TickCount;
startTime = Environment.TickCount64;
} }
Thread.Sleep(timeInMilliseconds); Thread.Sleep(timeInMilliseconds);
isGaming = false; isGaming = false;


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

@@ -30,7 +30,7 @@ namespace Gaming
}, },
EndMove: obj => EndMove: obj =>
{ {
Debugger.Output(obj, " end move at " + obj.Position.ToString() + " At time: " + Environment.TickCount);
Debugger.Output(obj, " end move at " + obj.Position.ToString() + " At time: " + Environment.TickCount64);
if (obj.CanMove && ((Bullet)obj).TypeOfBullet != BulletType.JumpyDumpty) if (obj.CanMove && ((Bullet)obj).TypeOfBullet != BulletType.JumpyDumpty)
BulletBomb((Bullet)obj, null); BulletBomb((Bullet)obj, null);
obj.ReSetCanMove(false); obj.ReSetCanMove(false);


+ 1
- 1
logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs View File

@@ -162,7 +162,7 @@ namespace Gaming
{ {
Character? whoAttacked = gameMap.FindPlayerInPlayerID(AttackID); Character? whoAttacked = gameMap.FindPlayerInPlayerID(AttackID);
if (whoAttacked == null || whoAttacked.NoHp()) if (whoAttacked == null || whoAttacked.NoHp())
return false;
return false;
ActiveSkill activeSkill = player.FindActiveSkill(ActiveSkillType.SparksNSplash); ActiveSkill activeSkill = player.FindActiveSkill(ActiveSkillType.SparksNSplash);


return ActiveSkillEffect(activeSkill, player, () => return ActiveSkillEffect(activeSkill, player, () =>


+ 1
- 1
logic/Gaming/SkillManager/SkillManager.PassiveSkill.cs View File

@@ -55,7 +55,7 @@ namespace Gaming // 被动技能开局时就释放,持续到游戏结束
} }
public void Lucky(Character player) public void Lucky(Character player)
{ {
player.PropInventory[0] = PropFactory.GetConsumables((PropType)((4 * Environment.TickCount) % 5 + 4), new XY(0, 0));
player.PropInventory[0] = PropFactory.GetConsumables((PropType)((4 * Environment.TickCount64) % 5 + 4), new XY(0, 0));
} }
} }
} }

+ 1
- 1
logic/Preparation/Interface/IDoorway.cs View File

@@ -4,7 +4,7 @@ namespace Preparation.Interface
{ {
public interface IDoorway : IGameObj public interface IDoorway : IGameObj
{ {
public int OpenStartTime { get; }
public long OpenStartTime { get; }
public int OpenDegree { get; } public int OpenDegree { get; }
public bool StopOpenning(); public bool StopOpenning();
public bool TryToOpen(); public bool TryToOpen();


+ 5
- 5
logic/Preparation/Interface/ISkill.cs View File

@@ -30,22 +30,22 @@ namespace Preparation.Interface
private readonly object skillLock = new(); private readonly object skillLock = new();
public object SkillLock => skillLock; public object SkillLock => skillLock;


private int openStartTime = 0;
public int OpenStartTime
private long startTime = 0;
public long StartTime
{ {
get get
{ {
lock (skillLock) lock (skillLock)
return openStartTime;
return startTime;
} }
} }
public bool StartSkill() public bool StartSkill()
{ {
lock (skillLock) lock (skillLock)
{ {
if (Environment.TickCount - openStartTime >= SkillCD)
if (Environment.TickCount64 - startTime >= SkillCD)
{ {
openStartTime = Environment.TickCount;
startTime = Environment.TickCount64;
return true; return true;
} }
} }


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

@@ -8,7 +8,7 @@ namespace Server


public static class CopyInfo public static class CopyInfo
{ {
public static MessageOfObj? Auto(GameObj gameObj, int time)
public static MessageOfObj? Auto(GameObj gameObj, long time)
{ {
switch (gameObj.Type) switch (gameObj.Type)
{ {
@@ -49,7 +49,7 @@ namespace Server
return objMsg; return objMsg;
} }


private static MessageOfObj? Student(Student player, int time)
private static MessageOfObj? Student(Student player, long time)
{ {
if (player.IsGhost()) return null; if (player.IsGhost()) return null;
MessageOfObj msg = new() MessageOfObj msg = new()
@@ -82,7 +82,7 @@ namespace Server


foreach (var keyValue in player.ActiveSkillDictionary) foreach (var keyValue in player.ActiveSkillDictionary)
{ {
int progress = (keyValue.Value.OpenStartTime - time) + keyValue.Value.SkillCD;
int progress = (int)((keyValue.Value.StartTime - time) + keyValue.Value.SkillCD);
msg.StudentMessage.TimeUntilSkillAvailable.Add(progress < 0 ? 0 : progress); msg.StudentMessage.TimeUntilSkillAvailable.Add(progress < 0 ? 0 : progress);
} }
for (int i = 0; i < GameData.maxNumOfSkill - player.ActiveSkillDictionary.Count; ++i) for (int i = 0; i < GameData.maxNumOfSkill - player.ActiveSkillDictionary.Count; ++i)
@@ -100,7 +100,7 @@ namespace Server
return msg; return msg;
} }


private static MessageOfObj? Tricker(Character player, int time)
private static MessageOfObj? Tricker(Character player, long time)
{ {
if (!player.IsGhost()) return null; if (!player.IsGhost()) return null;
MessageOfObj msg = new() MessageOfObj msg = new()
@@ -126,7 +126,7 @@ namespace Server
}; };
foreach (var keyValue in player.ActiveSkillDictionary) foreach (var keyValue in player.ActiveSkillDictionary)
{ {
int progress = keyValue.Value.SkillCD + (keyValue.Value.OpenStartTime - time);
int progress = (int)(keyValue.Value.SkillCD + (keyValue.Value.StartTime - time));
msg.TrickerMessage.TimeUntilSkillAvailable.Add(progress < 0 ? 0 : progress); msg.TrickerMessage.TimeUntilSkillAvailable.Add(progress < 0 ? 0 : progress);
} }
for (int i = 0; i < GameData.maxNumOfSkill - player.ActiveSkillDictionary.Count; ++i) for (int i = 0; i < GameData.maxNumOfSkill - player.ActiveSkillDictionary.Count; ++i)
@@ -225,7 +225,7 @@ namespace Server
}; };
return msg; return msg;
} }
private static MessageOfObj Gate(Doorway doorway, int time)
private static MessageOfObj Gate(Doorway doorway, long time)
{ {
MessageOfObj msg = new() MessageOfObj msg = new()
{ {
@@ -235,7 +235,7 @@ namespace Server
Y = doorway.Position.y Y = doorway.Position.y
} }
}; };
int progress = ((doorway.OpenStartTime > 0) ? (time - doorway.OpenStartTime) : 0) + doorway.OpenDegree;
int progress = ((doorway.OpenStartTime > 0) ? ((int)(time - doorway.OpenStartTime)) : 0) + doorway.OpenDegree;
msg.GateMessage.Progress = (progress > GameData.degreeOfOpenedDoorway) ? GameData.degreeOfOpenedDoorway : progress; msg.GateMessage.Progress = (progress > GameData.degreeOfOpenedDoorway) ? GameData.degreeOfOpenedDoorway : progress;
return msg; return msg;
} }
@@ -267,7 +267,7 @@ namespace Server
}; };
return msg; return msg;
} }
private static MessageOfObj Chest(Chest chest, int time)
private static MessageOfObj Chest(Chest chest, long time)
{ {
MessageOfObj msg = new() MessageOfObj msg = new()
{ {
@@ -277,7 +277,7 @@ namespace Server
Y = chest.Position.y Y = chest.Position.y
} }
}; };
int progress = (chest.WhoOpen != null) ? ((time - chest.OpenStartTime) * chest.WhoOpen.SpeedOfOpenChest) : 0;
int progress = (chest.WhoOpen != null) ? (((int)(time - chest.OpenStartTime)) * chest.WhoOpen.SpeedOfOpenChest) : 0;
msg.ChestMessage.Progress = (progress > GameData.degreeOfOpenedChest) ? GameData.degreeOfOpenedChest : progress; msg.ChestMessage.Progress = (progress > GameData.degreeOfOpenedChest) ? GameData.degreeOfOpenedChest : progress;
return msg; return msg;
} }


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

@@ -133,7 +133,7 @@ namespace Server
currentGameInfo.ObjMessage.Add(currentMapMsg); currentGameInfo.ObjMessage.Add(currentMapMsg);
IsSpectatorJoin = false; IsSpectatorJoin = false;
} }
int time = Environment.TickCount;
long time = Environment.TickCount64;
foreach (GameObj gameObj in gameObjList) foreach (GameObj gameObj in gameObjList)
{ {
MessageOfObj? msg = CopyInfo.Auto(gameObj, time); MessageOfObj? msg = CopyInfo.Auto(gameObj, time);


Loading…
Cancel
Save