Browse Source

chore: add MoveManager and Team

tags/0.1.0
shangfengh 3 years ago
parent
commit
69beee0d7e
2 changed files with 134 additions and 0 deletions
  1. +68
    -0
      logic/GameClass/GameObj/Team.cs
  2. +66
    -0
      logic/Gaming/MoveManager.cs

+ 68
- 0
logic/GameClass/GameObj/Team.cs View File

@@ -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<Character> 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<Character>();
}
}
}

+ 66
- 0
logic/Gaming/MoveManager.cs View File

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

Loading…
Cancel
Save