| @@ -61,34 +61,7 @@ namespace GameClass.GameObj | |||||
| this.CanMove = true; | this.CanMove = true; | ||||
| this.score = 0; | this.score = 0; | ||||
| this.buffManager = new BuffManager(); | this.buffManager = new BuffManager(); | ||||
| switch (characterType) | |||||
| { | |||||
| case CharacterType.Assassin: | |||||
| this.occupation = new Assassin(); | |||||
| break; | |||||
| case CharacterType.Robot: | |||||
| this.occupation = new Robot(); | |||||
| break; | |||||
| case CharacterType.Teacher: | |||||
| this.occupation = new Teacher(); | |||||
| break; | |||||
| case CharacterType.Klee: | |||||
| this.occupation = new Klee(); | |||||
| break; | |||||
| case CharacterType.StraightAStudent: | |||||
| this.occupation = new StraightAStudent(); | |||||
| break; | |||||
| case CharacterType.ANoisyPerson: | |||||
| this.occupation = new ANoisyPerson(); | |||||
| break; | |||||
| case CharacterType.TechOtaku: | |||||
| this.occupation = new TechOtaku(); | |||||
| break; | |||||
| case CharacterType.Athlete: | |||||
| default: | |||||
| this.occupation = new Athlete(); | |||||
| break; | |||||
| } | |||||
| this.occupation = OccupationFactory.FindIOccupation(characterType); | |||||
| this.MaxHp = this.hp = Occupation.MaxHp; | this.MaxHp = this.hp = Occupation.MaxHp; | ||||
| this.OrgMoveSpeed = this.moveSpeed = Occupation.MoveSpeed; | this.OrgMoveSpeed = this.moveSpeed = Occupation.MoveSpeed; | ||||
| this.BulletOfPlayer = this.OriBulletOfPlayer = Occupation.InitBullet; | this.BulletOfPlayer = this.OriBulletOfPlayer = Occupation.InitBullet; | ||||
| @@ -103,7 +76,7 @@ namespace GameClass.GameObj | |||||
| foreach (var activeSkill in this.Occupation.ListOfIActiveSkill) | foreach (var activeSkill in this.Occupation.ListOfIActiveSkill) | ||||
| { | { | ||||
| this.IActiveSkillDictionary.Add(activeSkill, SkillFactory.FindIActiveSkill(activeSkill)); | this.IActiveSkillDictionary.Add(activeSkill, SkillFactory.FindIActiveSkill(activeSkill)); | ||||
| this.TimeUntilActiveSkillAvailable.Add(activeSkill, IActiveSkillDictionary[activeSkill].SkillCD); | |||||
| this.TimeUntilActiveSkillAvailable.Add(activeSkill, 0); | |||||
| } | } | ||||
| // UsePassiveSkill(); //创建player时开始被动技能,这一过程也可以放到gamestart时进行 | // UsePassiveSkill(); //创建player时开始被动技能,这一过程也可以放到gamestart时进行 | ||||
| @@ -122,12 +122,12 @@ namespace GameClass.GameObj | |||||
| public Student(XY initPos, int initRadius, CharacterType characterType) : base(initPos, initRadius, characterType) | public Student(XY initPos, int initRadius, CharacterType characterType) : base(initPos, initRadius, characterType) | ||||
| { | { | ||||
| this.OrgFixSpeed = this.fixSpeed = ((IStudent)Occupation).FixSpeed; | |||||
| this.TreatSpeed = this.OrgTreatSpeed = ((IStudent)Occupation).TreatSpeed; | |||||
| this.MaxGamingAddiction = ((IStudent)Occupation).MaxGamingAddiction; | |||||
| this.OrgFixSpeed = this.fixSpeed = ((IStudentType)Occupation).FixSpeed; | |||||
| this.TreatSpeed = this.OrgTreatSpeed = ((IStudentType)Occupation).TreatSpeed; | |||||
| this.MaxGamingAddiction = ((IStudentType)Occupation).MaxGamingAddiction; | |||||
| } | } | ||||
| } | } | ||||
| public class Golem : Student | |||||
| public class Golem : Student, IGolem | |||||
| { | { | ||||
| private Character? parent; // 主人 | private Character? parent; // 主人 | ||||
| public Character? Parent | public Character? Parent | ||||
| @@ -1,250 +0,0 @@ | |||||
| using Preparation.Interface; | |||||
| using Preparation.Utility; | |||||
| namespace GameClass.GameObj | |||||
| { | |||||
| public class CanBeginToCharge : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD * 24 / 30; | |||||
| public int DurationTime => GameData.commonSkillTime * 5 / 10; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class BecomeInvisible : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD; | |||||
| public int DurationTime => GameData.commonSkillTime * 6 / 10; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class Punish : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD; | |||||
| public int DurationTime => 0; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class Rouse : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD; | |||||
| public int DurationTime => 0; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class Howl : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD * 3 / 4; | |||||
| public int DurationTime => 0; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class JumpyBomb : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD / 2; | |||||
| public int DurationTime => GameData.commonSkillTime * 3 / 10; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class UseKnife : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD * 2 / 3; | |||||
| public int DurationTime => GameData.commonSkillTime / 10; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class UseRobot : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.frameDuration; | |||||
| public int DurationTime => 0; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class WriteAnswers : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD; | |||||
| public int DurationTime => 0; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| private int degreeOfMeditation = 0; | |||||
| public int DegreeOfMeditation | |||||
| { | |||||
| get => degreeOfMeditation; | |||||
| set | |||||
| { | |||||
| lock (commonSkillLock) | |||||
| { | |||||
| degreeOfMeditation = value; | |||||
| } | |||||
| } | |||||
| } | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class SummonGolem : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD; | |||||
| public int DurationTime => 0; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| private Golem? golemSummoned = null; | |||||
| public Golem? GolemSummoned | |||||
| { | |||||
| get => golemSummoned; | |||||
| set | |||||
| { | |||||
| lock (commonSkillLock) | |||||
| { | |||||
| golemSummoned = value; | |||||
| } | |||||
| } | |||||
| } | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class NullSkill : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD; | |||||
| public int DurationTime => GameData.commonSkillTime; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = false; | |||||
| } | |||||
| } | |||||
| public static class SkillFactory | |||||
| { | |||||
| public static IActiveSkill FindIActiveSkill(ActiveSkillType activeSkillType) | |||||
| { | |||||
| switch (activeSkillType) | |||||
| { | |||||
| case ActiveSkillType.BecomeInvisible: | |||||
| return new BecomeInvisible(); | |||||
| case ActiveSkillType.UseKnife: | |||||
| return new UseKnife(); | |||||
| case ActiveSkillType.Howl: | |||||
| return new Howl(); | |||||
| case ActiveSkillType.CanBeginToCharge: | |||||
| return new CanBeginToCharge(); | |||||
| case ActiveSkillType.Punish: | |||||
| return new Punish(); | |||||
| case ActiveSkillType.JumpyBomb: | |||||
| return new JumpyBomb(); | |||||
| case ActiveSkillType.WriteAnswers: | |||||
| return new WriteAnswers(); | |||||
| case ActiveSkillType.SummonGolem: | |||||
| return new SummonGolem(); | |||||
| case ActiveSkillType.UseRobot: | |||||
| return new UseRobot(); | |||||
| case ActiveSkillType.Rouse: | |||||
| return new Rouse(); | |||||
| default: | |||||
| return new NullSkill(); | |||||
| } | |||||
| } | |||||
| public static ActiveSkillType FindActiveSkillType(IActiveSkill ActiveSkill) | |||||
| { | |||||
| switch (ActiveSkill) | |||||
| { | |||||
| case BecomeInvisible: | |||||
| return ActiveSkillType.BecomeInvisible; | |||||
| case Howl: | |||||
| return ActiveSkillType.Howl; | |||||
| case UseKnife: | |||||
| return ActiveSkillType.UseKnife; | |||||
| case CanBeginToCharge: | |||||
| return ActiveSkillType.CanBeginToCharge; | |||||
| case Punish: | |||||
| return ActiveSkillType.Punish; | |||||
| case JumpyBomb: | |||||
| return ActiveSkillType.JumpyBomb; | |||||
| case WriteAnswers: | |||||
| return ActiveSkillType.WriteAnswers; | |||||
| case SummonGolem: | |||||
| return ActiveSkillType.SummonGolem; | |||||
| case UseRobot: | |||||
| return ActiveSkillType.UseRobot; | |||||
| case Rouse: | |||||
| return ActiveSkillType.Rouse; | |||||
| default: | |||||
| return ActiveSkillType.Null; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -173,7 +173,7 @@ namespace Gaming | |||||
| playerTreated.PlayerState = PlayerStateType.Treated; | playerTreated.PlayerState = PlayerStateType.Treated; | ||||
| player.PlayerState = PlayerStateType.Treating; | player.PlayerState = PlayerStateType.Treating; | ||||
| new FrameRateTaskExecutor<int>( | new FrameRateTaskExecutor<int>( | ||||
| loopCondition: () => playerTreated.PlayerState == PlayerStateType.Treated && player.PlayerState == PlayerStateType.Treating && gameMap.Timer.IsGaming && GameData.ApproachToInteract(playerTreated.Position, player.Position), | |||||
| loopCondition: () => playerTreated.PlayerState == PlayerStateType.Treated && player.PlayerState == PlayerStateType.Treating && gameMap.Timer.IsGaming, | |||||
| loopToDo: () => | loopToDo: () => | ||||
| { | { | ||||
| if (playerTreated.AddDegreeOfTreatment(GameData.frameDuration * player.TreatSpeed, player)) | if (playerTreated.AddDegreeOfTreatment(GameData.frameDuration * player.TreatSpeed, player)) | ||||
| @@ -182,11 +182,10 @@ namespace Gaming | |||||
| timeInterval: GameData.frameDuration, | timeInterval: GameData.frameDuration, | ||||
| finallyReturn: () => 0 | finallyReturn: () => 0 | ||||
| ) | ) | ||||
| .Start(); | .Start(); | ||||
| if (playerTreated.PlayerState == PlayerStateType.Treated) playerTreated.PlayerState = PlayerStateType.Null; | |||||
| if (player.PlayerState == PlayerStateType.Treating) player.PlayerState = PlayerStateType.Null; | if (player.PlayerState == PlayerStateType.Treating) player.PlayerState = PlayerStateType.Null; | ||||
| else if (playerTreated.PlayerState == PlayerStateType.Treated) playerTreated.PlayerState = PlayerStateType.Null; | |||||
| } | } | ||||
| ) | ) | ||||
| { IsBackground = true }.Start(); | { IsBackground = true }.Start(); | ||||
| @@ -270,26 +270,6 @@ namespace Gaming | |||||
| else | else | ||||
| return false; | return false; | ||||
| } | } | ||||
| public void AllActiveSkillDisabledTemporarily() | |||||
| { | |||||
| if (!gameMap.Timer.IsGaming) | |||||
| return; | |||||
| gameMap.GameObjLockDict[GameObjType.Character].EnterWriteLock(); | |||||
| try | |||||
| { | |||||
| foreach (Character player in gameMap.GameObjDict[GameObjType.Character]) | |||||
| { | |||||
| foreach (var activeSkill in player.Occupation.ListOfIActiveSkill) | |||||
| { | |||||
| player.SetTimeUntilActiveSkillAvailable(activeSkill, 0); | |||||
| } | |||||
| } | |||||
| } | |||||
| finally | |||||
| { | |||||
| gameMap.GameObjLockDict[GameObjType.Character].ExitWriteLock(); | |||||
| } | |||||
| } | |||||
| public void AllPlayerUsePassiveSkill() | public void AllPlayerUsePassiveSkill() | ||||
| { | { | ||||
| @@ -15,4 +15,6 @@ namespace Preparation.Interface | |||||
| public bool IsGhost(); | public bool IsGhost(); | ||||
| } | } | ||||
| public interface IStudent : ICharacter { } | |||||
| public interface IGolem : IStudent { } | |||||
| } | } | ||||
| @@ -18,18 +18,18 @@ namespace Preparation.Interface | |||||
| public int SpeedOfOpenChest { get; } | public int SpeedOfOpenChest { get; } | ||||
| } | } | ||||
| public interface IGhost : IOccupation | |||||
| public interface IGhostType : IOccupation | |||||
| { | { | ||||
| } | } | ||||
| public interface IStudent : IOccupation | |||||
| public interface IStudentType : IOccupation | |||||
| { | { | ||||
| public int FixSpeed { get; } | public int FixSpeed { get; } | ||||
| public int TreatSpeed { get; } | public int TreatSpeed { get; } | ||||
| public int MaxGamingAddiction { get; } | public int MaxGamingAddiction { get; } | ||||
| } | } | ||||
| public class Assassin : IGhost | |||||
| public class Assassin : IGhostType | |||||
| { | { | ||||
| private const int moveSpeed = (int)(GameData.basicGhostMoveSpeed * 1.1); | private const int moveSpeed = (int)(GameData.basicGhostMoveSpeed * 1.1); | ||||
| public int MoveSpeed => moveSpeed; | public int MoveSpeed => moveSpeed; | ||||
| @@ -60,7 +60,7 @@ namespace Preparation.Interface | |||||
| public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | ||||
| public int SpeedOfOpenChest => speedOfOpenChest; | public int SpeedOfOpenChest => speedOfOpenChest; | ||||
| } | } | ||||
| public class Klee : IGhost | |||||
| public class Klee : IGhostType | |||||
| { | { | ||||
| private const int moveSpeed = (int)(GameData.basicGhostMoveSpeed * 155 / 127); | private const int moveSpeed = (int)(GameData.basicGhostMoveSpeed * 155 / 127); | ||||
| public int MoveSpeed => moveSpeed; | public int MoveSpeed => moveSpeed; | ||||
| @@ -91,7 +91,7 @@ namespace Preparation.Interface | |||||
| public int speedOfOpenChest = (int)(GameData.basicSpeedOfOpenChest * 1.1); | public int speedOfOpenChest = (int)(GameData.basicSpeedOfOpenChest * 1.1); | ||||
| public int SpeedOfOpenChest => speedOfOpenChest; | public int SpeedOfOpenChest => speedOfOpenChest; | ||||
| } | } | ||||
| public class ANoisyPerson : IGhost | |||||
| public class ANoisyPerson : IGhostType | |||||
| { | { | ||||
| private const int moveSpeed = (int)(GameData.basicGhostMoveSpeed * 1.07); | private const int moveSpeed = (int)(GameData.basicGhostMoveSpeed * 1.07); | ||||
| public int MoveSpeed => moveSpeed; | public int MoveSpeed => moveSpeed; | ||||
| @@ -122,7 +122,7 @@ namespace Preparation.Interface | |||||
| public int speedOfOpenChest = (int)(GameData.basicSpeedOfOpenChest); | public int speedOfOpenChest = (int)(GameData.basicSpeedOfOpenChest); | ||||
| public int SpeedOfOpenChest => speedOfOpenChest; | public int SpeedOfOpenChest => speedOfOpenChest; | ||||
| } | } | ||||
| public class Teacher : IStudent | |||||
| public class Teacher : IStudentType | |||||
| { | { | ||||
| private const int moveSpeed = GameData.basicStudentMoveSpeed * 3 / 4; | private const int moveSpeed = GameData.basicStudentMoveSpeed * 3 / 4; | ||||
| public int MoveSpeed => moveSpeed; | public int MoveSpeed => moveSpeed; | ||||
| @@ -162,7 +162,7 @@ namespace Preparation.Interface | |||||
| public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | ||||
| public int SpeedOfOpenChest => speedOfOpenChest; | public int SpeedOfOpenChest => speedOfOpenChest; | ||||
| } | } | ||||
| public class Athlete : IStudent | |||||
| public class Athlete : IStudentType | |||||
| { | { | ||||
| private const int moveSpeed = GameData.basicStudentMoveSpeed * 40 / 38; | private const int moveSpeed = GameData.basicStudentMoveSpeed * 40 / 38; | ||||
| public int MoveSpeed => moveSpeed; | public int MoveSpeed => moveSpeed; | ||||
| @@ -202,7 +202,7 @@ namespace Preparation.Interface | |||||
| public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | ||||
| public int SpeedOfOpenChest => speedOfOpenChest; | public int SpeedOfOpenChest => speedOfOpenChest; | ||||
| } | } | ||||
| public class StraightAStudent : IStudent | |||||
| public class StraightAStudent : IStudentType | |||||
| { | { | ||||
| private const int moveSpeed = (int)(GameData.basicStudentMoveSpeed * 0.8); | private const int moveSpeed = (int)(GameData.basicStudentMoveSpeed * 0.8); | ||||
| public int MoveSpeed => moveSpeed; | public int MoveSpeed => moveSpeed; | ||||
| @@ -242,7 +242,7 @@ namespace Preparation.Interface | |||||
| public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | ||||
| public int SpeedOfOpenChest => speedOfOpenChest; | public int SpeedOfOpenChest => speedOfOpenChest; | ||||
| } | } | ||||
| public class Robot : IStudent | |||||
| public class Robot : IStudentType | |||||
| { | { | ||||
| private const int moveSpeed = (int)(GameData.basicStudentMoveSpeed); | private const int moveSpeed = (int)(GameData.basicStudentMoveSpeed); | ||||
| public int MoveSpeed => moveSpeed; | public int MoveSpeed => moveSpeed; | ||||
| @@ -282,7 +282,7 @@ namespace Preparation.Interface | |||||
| public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | ||||
| public int SpeedOfOpenChest => speedOfOpenChest; | public int SpeedOfOpenChest => speedOfOpenChest; | ||||
| } | } | ||||
| public class TechOtaku : IStudent | |||||
| public class TechOtaku : IStudentType | |||||
| { | { | ||||
| private const int moveSpeed = (int)(GameData.basicStudentMoveSpeed * 0.75); | private const int moveSpeed = (int)(GameData.basicStudentMoveSpeed * 0.75); | ||||
| public int MoveSpeed => moveSpeed; | public int MoveSpeed => moveSpeed; | ||||
| @@ -322,7 +322,7 @@ namespace Preparation.Interface | |||||
| public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | ||||
| public int SpeedOfOpenChest => speedOfOpenChest; | public int SpeedOfOpenChest => speedOfOpenChest; | ||||
| } | } | ||||
| public class Sunshine : IStudent | |||||
| public class Sunshine : IStudentType | |||||
| { | { | ||||
| private const int moveSpeed = GameData.basicStudentMoveSpeed; | private const int moveSpeed = GameData.basicStudentMoveSpeed; | ||||
| public int MoveSpeed => moveSpeed; | public int MoveSpeed => moveSpeed; | ||||
| @@ -362,4 +362,31 @@ namespace Preparation.Interface | |||||
| public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | public int speedOfOpenChest = GameData.basicSpeedOfOpenChest; | ||||
| public int SpeedOfOpenChest => speedOfOpenChest; | public int SpeedOfOpenChest => speedOfOpenChest; | ||||
| } | } | ||||
| public static class OccupationFactory | |||||
| { | |||||
| public static IOccupation FindIOccupation(CharacterType characterType) | |||||
| { | |||||
| switch (characterType) | |||||
| { | |||||
| case CharacterType.Assassin: | |||||
| return new Assassin(); | |||||
| case CharacterType.Robot: | |||||
| return new Robot(); | |||||
| case CharacterType.Teacher: | |||||
| return new Teacher(); | |||||
| case CharacterType.Klee: | |||||
| return new Klee(); | |||||
| case CharacterType.StraightAStudent: | |||||
| return new StraightAStudent(); | |||||
| case CharacterType.ANoisyPerson: | |||||
| return new ANoisyPerson(); | |||||
| case CharacterType.TechOtaku: | |||||
| return new TechOtaku(); | |||||
| case CharacterType.Athlete: | |||||
| default: | |||||
| return new Athlete(); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -1,4 +1,7 @@ | |||||
| namespace Preparation.Interface | |||||
| using Preparation.Interface; | |||||
| using Preparation.Utility; | |||||
| namespace Preparation.Interface | |||||
| { | { | ||||
| public interface ISkill | public interface ISkill | ||||
| { | { | ||||
| @@ -13,4 +16,248 @@ | |||||
| public object ActiveSkillLock { get; } | public object ActiveSkillLock { get; } | ||||
| public bool IsBeingUsed { get; set; } | public bool IsBeingUsed { get; set; } | ||||
| } | } | ||||
| } | |||||
| public class CanBeginToCharge : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD * 24 / 30; | |||||
| public int DurationTime => GameData.commonSkillTime * 5 / 10; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class BecomeInvisible : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD; | |||||
| public int DurationTime => GameData.commonSkillTime * 6 / 10; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class Punish : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD; | |||||
| public int DurationTime => 0; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class Rouse : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD; | |||||
| public int DurationTime => 0; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class Howl : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD * 3 / 4; | |||||
| public int DurationTime => 0; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class JumpyBomb : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD / 2; | |||||
| public int DurationTime => GameData.commonSkillTime * 3 / 10; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class UseKnife : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD * 2 / 3; | |||||
| public int DurationTime => GameData.commonSkillTime / 10; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class UseRobot : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.frameDuration; | |||||
| public int DurationTime => 0; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class WriteAnswers : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD; | |||||
| public int DurationTime => 0; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| private int degreeOfMeditation = 0; | |||||
| public int DegreeOfMeditation | |||||
| { | |||||
| get => degreeOfMeditation; | |||||
| set | |||||
| { | |||||
| lock (commonSkillLock) | |||||
| { | |||||
| degreeOfMeditation = value; | |||||
| } | |||||
| } | |||||
| } | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class SummonGolem : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD; | |||||
| public int DurationTime => 0; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| private IGolem? golemSummoned = null; | |||||
| public IGolem? GolemSummoned | |||||
| { | |||||
| get => golemSummoned; | |||||
| set | |||||
| { | |||||
| lock (commonSkillLock) | |||||
| { | |||||
| golemSummoned = value; | |||||
| } | |||||
| } | |||||
| } | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = value; | |||||
| } | |||||
| } | |||||
| public class NullSkill : IActiveSkill | |||||
| { | |||||
| public int SkillCD => GameData.commonSkillCD; | |||||
| public int DurationTime => GameData.commonSkillTime; | |||||
| private readonly object commonSkillLock = new object(); | |||||
| public object ActiveSkillLock => commonSkillLock; | |||||
| public bool isBeingUsed = false; | |||||
| public bool IsBeingUsed | |||||
| { | |||||
| get => isBeingUsed; set => isBeingUsed = false; | |||||
| } | |||||
| } | |||||
| public static class SkillFactory | |||||
| { | |||||
| public static IActiveSkill FindIActiveSkill(ActiveSkillType activeSkillType) | |||||
| { | |||||
| switch (activeSkillType) | |||||
| { | |||||
| case ActiveSkillType.BecomeInvisible: | |||||
| return new BecomeInvisible(); | |||||
| case ActiveSkillType.UseKnife: | |||||
| return new UseKnife(); | |||||
| case ActiveSkillType.Howl: | |||||
| return new Howl(); | |||||
| case ActiveSkillType.CanBeginToCharge: | |||||
| return new CanBeginToCharge(); | |||||
| case ActiveSkillType.Punish: | |||||
| return new Punish(); | |||||
| case ActiveSkillType.JumpyBomb: | |||||
| return new JumpyBomb(); | |||||
| case ActiveSkillType.WriteAnswers: | |||||
| return new WriteAnswers(); | |||||
| case ActiveSkillType.SummonGolem: | |||||
| return new SummonGolem(); | |||||
| case ActiveSkillType.UseRobot: | |||||
| return new UseRobot(); | |||||
| case ActiveSkillType.Rouse: | |||||
| return new Rouse(); | |||||
| default: | |||||
| return new NullSkill(); | |||||
| } | |||||
| } | |||||
| public static ActiveSkillType FindActiveSkillType(IActiveSkill ActiveSkill) | |||||
| { | |||||
| switch (ActiveSkill) | |||||
| { | |||||
| case BecomeInvisible: | |||||
| return ActiveSkillType.BecomeInvisible; | |||||
| case Howl: | |||||
| return ActiveSkillType.Howl; | |||||
| case UseKnife: | |||||
| return ActiveSkillType.UseKnife; | |||||
| case CanBeginToCharge: | |||||
| return ActiveSkillType.CanBeginToCharge; | |||||
| case Punish: | |||||
| return ActiveSkillType.Punish; | |||||
| case JumpyBomb: | |||||
| return ActiveSkillType.JumpyBomb; | |||||
| case WriteAnswers: | |||||
| return ActiveSkillType.WriteAnswers; | |||||
| case SummonGolem: | |||||
| return ActiveSkillType.SummonGolem; | |||||
| case UseRobot: | |||||
| return ActiveSkillType.UseRobot; | |||||
| case Rouse: | |||||
| return ActiveSkillType.Rouse; | |||||
| default: | |||||
| return ActiveSkillType.Null; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -59,7 +59,6 @@ namespace Server | |||||
| { | { | ||||
| game.AllPlayerUsePassiveSkill(); | game.AllPlayerUsePassiveSkill(); | ||||
| ReportGame(GameState.GameStart); | ReportGame(GameState.GameStart); | ||||
| game.AllActiveSkillDisabledTemporarily(); | |||||
| flag = false; | flag = false; | ||||
| } | } | ||||
| else ReportGame(GameState.GameRunning); | else ReportGame(GameState.GameRunning); | ||||
| @@ -196,8 +196,6 @@ | |||||
| - 不加说明,这里“学生”往往包括职业“教师” | - 不加说明,这里“学生”往往包括职业“教师” | ||||
| ### 初始状态 | ### 初始状态 | ||||
| - 所有玩家可以立刻使用主动技能 | |||||
| - 虽然一开始会接到仍需的冷却时间,但实际上是CD | |||||
| - 玩家出生点固定且一定为空地 | - 玩家出生点固定且一定为空地 | ||||
| ### 交互 | ### 交互 | ||||