From 69beee0d7ebb03265a244538eb7d6a91d44b77a6 Mon Sep 17 00:00:00 2001 From: shangfengh <3495281661@qq.com> Date: Sat, 19 Nov 2022 23:24:59 +0800 Subject: [PATCH] chore: :sparkles: add MoveManager and Team --- logic/GameClass/GameObj/Team.cs | 68 +++++++++++++++++++++++++++++++++ logic/Gaming/MoveManager.cs | 66 ++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 logic/GameClass/GameObj/Team.cs create mode 100644 logic/Gaming/MoveManager.cs diff --git a/logic/GameClass/GameObj/Team.cs b/logic/GameClass/GameObj/Team.cs new file mode 100644 index 0000000..281ea82 --- /dev/null +++ b/logic/GameClass/GameObj/Team.cs @@ -0,0 +1,68 @@ +using System.Collections.Generic; + +namespace GameClass.GameObj +{ + public class Team + { + private static long currentMaxTeamID = 0; + public static long CurrentMaxTeamID => currentMaxTeamID; + private readonly long teamID; + public long TeamID => teamID; + public const long invalidTeamID = long.MaxValue; + public const long noneTeamID = long.MinValue; + private readonly List playerList; + public int Score + { + get { + int score = 0; + foreach (var player in playerList) + score += player.Score; + return score; + } + } + public Character? GetPlayer(long ID) + { + foreach (Character player in playerList) + { + if (player.ID == ID) + { + return player; + } + } + return null; + } + public void AddPlayer(Character player) + { + playerList.Add(player); + } + public void OutPlayer(long ID) + { + int i; + for (i = 0; i < playerList.Count; ++i) + { + if (playerList[i].ID == ID) + break; + } + playerList.RemoveAt(i); + } + public long[] GetPlayerIDs() + { + long[] playerIDs = new long[playerList.Count]; + int num = 0; + foreach (Character player in playerList) + { + playerIDs[num++] = player.ID; + } + return playerIDs; + } + public static bool teamExists(long findTeamID) + { + return findTeamID < currentMaxTeamID; + } + public Team() + { + teamID = currentMaxTeamID++; + playerList = new List(); + } + } +} diff --git a/logic/Gaming/MoveManager.cs b/logic/Gaming/MoveManager.cs new file mode 100644 index 0000000..7c15aa6 --- /dev/null +++ b/logic/Gaming/MoveManager.cs @@ -0,0 +1,66 @@ +using System; +using GameClass.GameObj; +using GameEngine; +using Preparation.Utility; + +namespace Gaming +{ + public partial class Game + { + private readonly MoveManager moveManager; + private class MoveManager + { + + // 人物移动 + public void MovePlayer(Character playerToMove, int moveTimeInMilliseconds, double moveDirection) + { + moveEngine.MoveObj(playerToMove, moveTimeInMilliseconds, moveDirection); + } + + /* + private void ActivateMine(Character player, Mine mine) + { + gameMap.ObjListLock.EnterWriteLock(); + try { gameMap.ObjList.Remove(mine); } + catch { } + finally { gameMap.ObjListLock.ExitWriteLock(); } + + switch (mine.GetPropType()) + { + case PropType.Dirt: + player.AddMoveSpeed(Constant.dirtMoveSpeedDebuff, Constant.buffPropTime); + break; + case PropType.Attenuator: + player.AddAP(Constant.attenuatorAtkDebuff, Constant.buffPropTime); + break; + case PropType.Divider: + player.ChangeCD(Constant.dividerCdDiscount, Constant.buffPropTime); + break; + } + } + */ + + // private readonly Map gameMap; + private readonly MoveEngine moveEngine; + public MoveManager(Map gameMap) + { + // this.gameMap = gameMap; + this.moveEngine = new MoveEngine( + gameMap: gameMap, + OnCollision: (obj, collisionObj, moveVec) => + { + //if (collisionObj is Mine) + //{ + // ActivateMine((Character)obj, (Mine)collisionObj); + // return MoveEngine.AfterCollision.ContinueCheck; + //} + return MoveEngine.AfterCollision.MoveMax; }, + EndMove: obj => + { + // Debugger.Output(obj, " end move at " + obj.Position.ToString() + " At time: " + Environment.TickCount64); + } + ); + } + } + } +}