| @@ -16,7 +16,7 @@ namespace GameClass.GameObj | |||||
| public override int Speed => GameData.basicBulletMoveSpeed; | public override int Speed => GameData.basicBulletMoveSpeed; | ||||
| public override bool IsToBomb => false; | public override bool IsToBomb => false; | ||||
| public override int Backswing => GameData.basicBackswing; | public override int Backswing => GameData.basicBackswing; | ||||
| public override int RecoveryFromHit => GameData.basicRecoveryFromHit; | |||||
| public override int RecoveryFromHit => GameData.basicRecoveryFromHit; | |||||
| public override bool CanAttack(GameObj target) | public override bool CanAttack(GameObj target) | ||||
| { | { | ||||
| return false; | return false; | ||||
| @@ -182,5 +182,5 @@ namespace GameClass.GameObj | |||||
| public override BulletType TypeOfBullet => BulletType.LineBullet; | public override BulletType TypeOfBullet => BulletType.LineBullet; | ||||
| } | } | ||||
| } | } | ||||
| @@ -9,8 +9,8 @@ namespace GameClass.GameObj | |||||
| /// <summary> | /// <summary> | ||||
| /// //攻击力 | /// //攻击力 | ||||
| /// </summary> | /// </summary> | ||||
| public abstract double BulletBombRange{ get; } | |||||
| public abstract double BulletAttackRange{ get; } | |||||
| public abstract double BulletBombRange { get; } | |||||
| public abstract double BulletAttackRange { get; } | |||||
| public abstract int AP { get; } | public abstract int AP { get; } | ||||
| public abstract int Speed { get; } | public abstract int Speed { get; } | ||||
| public abstract bool IsToBomb { get; } | public abstract bool IsToBomb { get; } | ||||
| @@ -10,32 +10,44 @@ namespace GameClass.GameObj | |||||
| private readonly CharacterType characterType; | private readonly CharacterType characterType; | ||||
| public CharacterType CharacterType => characterType; | public CharacterType CharacterType => characterType; | ||||
| private readonly Occupation occupation; | |||||
| public Occupation Occupation => occupation; | |||||
| private readonly IOccupation occupation; | |||||
| public IOccupation Occupation => occupation; | |||||
| private Dictionary<ActiveSkillType, int> TimeUntilActiveSkillAvailable { get; set; } | |||||
| private Dictionary<ActiveSkillType, int> timeUntilActiveSkillAvailable; | |||||
| public Dictionary<ActiveSkillType, int> TimeUntilActiveSkillAvailable => timeUntilActiveSkillAvailable; | |||||
| public bool SetTimeUntilActiveSkillAvailable(ActiveSkillType activeSkillType, int timeUntilActiveSkillAvailable) | public bool SetTimeUntilActiveSkillAvailable(ActiveSkillType activeSkillType, int timeUntilActiveSkillAvailable) | ||||
| { | { | ||||
| lock (gameObjLock) | |||||
| if (TimeUntilActiveSkillAvailable.ContainsKey(activeSkillType)) | if (TimeUntilActiveSkillAvailable.ContainsKey(activeSkillType)) | ||||
| { | { | ||||
| TimeUntilActiveSkillAvailable[activeSkillType] = (timeUntilActiveSkillAvailable > 0) ? timeUntilActiveSkillAvailable : 0; | |||||
| lock (gameObjLock) | |||||
| this.timeUntilActiveSkillAvailable[activeSkillType] = (timeUntilActiveSkillAvailable > 0) ? timeUntilActiveSkillAvailable : 0; | |||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| public bool AddTimeUntilActiveSkillAvailable(ActiveSkillType activeSkillType, int addTimeUntilActiveSkillAvailable) | |||||
| { | |||||
| if (TimeUntilActiveSkillAvailable.ContainsKey(activeSkillType)) | |||||
| { | |||||
| lock (gameObjLock) | |||||
| this.timeUntilActiveSkillAvailable[activeSkillType] = (timeUntilActiveSkillAvailable[activeSkillType] + addTimeUntilActiveSkillAvailable > 0) ? timeUntilActiveSkillAvailable[activeSkillType] + addTimeUntilActiveSkillAvailable : 0; | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| public bool UseActiveSkill(ActiveSkillType activeSkillType) | public bool UseActiveSkill(ActiveSkillType activeSkillType) | ||||
| { | { | ||||
| if (Occupation.ListOfIActiveSkill.Contains(ActiveSkillFactory.FindIActiveSkill(activeSkillType))) | if (Occupation.ListOfIActiveSkill.Contains(ActiveSkillFactory.FindIActiveSkill(activeSkillType))) | ||||
| return ActiveSkillFactory.FindIActiveSkill(activeSkillType).; | |||||
| else false; | |||||
| return ActiveSkillFactory.FindIActiveSkill(activeSkillType).SkillEffect(this); | |||||
| return false; | |||||
| } | } | ||||
| readonly CharacterPassiveSkill passiveSkill; | |||||
| public void UsePassiveSkill() | |||||
| public void UsePassiveSkill(PassiveSkillType passiveSkillType) | |||||
| { | { | ||||
| passiveSkill(this); | |||||
| if (Occupation.ListOfIPassiveSkill.Contains(PassiveSkillFactory.FindIPassiveSkill(passiveSkillType))) | |||||
| PassiveSkillFactory.FindIPassiveSkill(passiveSkillType).SkillEffect(this); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -43,14 +55,7 @@ namespace GameClass.GameObj | |||||
| { | { | ||||
| return this.characterType switch | return this.characterType switch | ||||
| { | { | ||||
| this.CharacterType.Assassin => true, | |||||
| this.CharacterType.Vampire => true, | |||||
| this.CharacterType.Null => false, | |||||
| this.CharacterType.RecoverAfterBattle => false, | |||||
| this.CharacterType.SpeedUpWhenLeavingGrass => false, | |||||
| this.CharacterType.PSkill4 => false, | |||||
| this.CharacterType.PSkill5 => false, | |||||
| CharacterType.Assassin => true, | |||||
| _ => false, | _ => false, | ||||
| }; | }; | ||||
| } | } | ||||
| @@ -62,56 +67,30 @@ namespace GameClass.GameObj | |||||
| this.score = 0; | this.score = 0; | ||||
| this.propInventory = null; | this.propInventory = null; | ||||
| this.buffManeger = new BuffManeger(); | this.buffManeger = new BuffManeger(); | ||||
| IPassiveSkill pSkill; | |||||
| IActiveSkill cSkill; | |||||
| switch (characterType) | switch (characterType) | ||||
| { | { | ||||
| case this.CharacterType.Assassin: | |||||
| pSkill = null; | |||||
| break; | |||||
| case this.CharacterType.RecoverAfterBattle: | |||||
| pSkill = new RecoverAfterBattle(); | |||||
| break; | |||||
| case this.CharacterType.SpeedUpWhenLeavingGrass: | |||||
| pSkill = new SpeedUpWhenLeavingGrass(); | |||||
| break; | |||||
| case this.CharacterType.Vampire: | |||||
| pSkill = new Vampire(); | |||||
| break; | |||||
| default: | |||||
| pSkill = new NoPassiveSkill(); | |||||
| break; | |||||
| } | |||||
| switch (commonSkillType) | |||||
| { | |||||
| case ActiveSkillType.BecomeAssassin: | |||||
| cSkill = new BecomeInvisible(); | |||||
| break; | |||||
| case ActiveSkillType.BecomeVampire: | |||||
| cSkill = new BecomeVampire(); | |||||
| break; | |||||
| case ActiveSkillType.NuclearWeapon: | |||||
| cSkill = new NuclearWeapon(); | |||||
| break; | |||||
| case ActiveSkillType.SuperFast: | |||||
| cSkill = new SuperFast(); | |||||
| case CharacterType.Assassin: | |||||
| this.occupation = new Assassin(); | |||||
| break; | break; | ||||
| default: | default: | ||||
| cSkill = new NoCommonSkill(); | |||||
| this.occupation = null; | |||||
| break; | break; | ||||
| } | } | ||||
| this.MaxHp = cSkill.MaxHp; | |||||
| this.hp = cSkill.MaxHp; | |||||
| this.OrgMoveSpeed = cSkill.MoveSpeed; | |||||
| this.moveSpeed = cSkill.MoveSpeed; | |||||
| this.maxBulletNum = cSkill.MaxBulletNum; | |||||
| this.MaxHp = occupation.MaxHp; | |||||
| this.hp = occupation.MaxHp; | |||||
| this.OrgMoveSpeed = occupation.MoveSpeed; | |||||
| this.moveSpeed = occupation.MoveSpeed; | |||||
| this.cd = occupation.CD; | |||||
| this.maxBulletNum = occupation.MaxBulletNum; | |||||
| this.bulletNum = maxBulletNum; | this.bulletNum = maxBulletNum; | ||||
| this.bulletOfPlayer = pSkill.InitBullet; | |||||
| this.OriBulletOfPlayer = pSkill.InitBullet; | |||||
| this.passiveSkill = pSkill.SkillEffect; | |||||
| this.commonSkill = cSkill.SkillEffect; | |||||
| this.bulletOfPlayer = occupation.InitBullet; | |||||
| this.OriBulletOfPlayer = occupation.InitBullet; | |||||
| this.characterType = characterType; | this.characterType = characterType; | ||||
| this.commonSkillType = commonSkillType; | |||||
| foreach (var activeSkill in this.Occupation.ListOfIActiveSkill) | |||||
| { | |||||
| this.TimeUntilActiveSkillAvailable.Add(ActiveSkillFactory.FindActiveSkillType(activeSkill), 0); | |||||
| } | |||||
| // UsePassiveSkill(); //创建player时开始被动技能,这一过程也可以放到gamestart时进行 | // UsePassiveSkill(); //创建player时开始被动技能,这一过程也可以放到gamestart时进行 | ||||
| // 这可以放在AddPlayer中做 | // 这可以放在AddPlayer中做 | ||||
| @@ -13,6 +13,23 @@ namespace GameClass.GameObj | |||||
| private readonly object beAttackedLock = new(); | private readonly object beAttackedLock = new(); | ||||
| #region 角色的基本属性及方法,包括与道具的交互方法 | #region 角色的基本属性及方法,包括与道具的交互方法 | ||||
| /// <summary> | |||||
| /// 装弹冷却 | |||||
| /// </summary> | |||||
| protected int cd; | |||||
| public int CD | |||||
| { | |||||
| get => cd; | |||||
| private set | |||||
| { | |||||
| lock (gameObjLock) | |||||
| { | |||||
| cd = value; | |||||
| Debugger.Output(this, string.Format("'s CD has been set to: {0}.", value)); | |||||
| } | |||||
| } | |||||
| } | |||||
| public int OrgCD { get; protected set; } | |||||
| protected int fixSpeed = 1; | protected int fixSpeed = 1; | ||||
| /// <summary> | /// <summary> | ||||
| @@ -72,7 +89,7 @@ namespace GameClass.GameObj | |||||
| get => score; | get => score; | ||||
| } | } | ||||
| // public double AttackRange => BulletFactory.BulletAttackRange(this.BulletOfPlayer); | |||||
| // public double AttackRange => BulletFactory.BulletAttackRange(this.BulletOfPlayer); | |||||
| private double vampire = 0; // 回血率:0-1之间 | private double vampire = 0; // 回血率:0-1之间 | ||||
| public double Vampire | public double Vampire | ||||
| @@ -256,11 +273,11 @@ namespace GameClass.GameObj | |||||
| /// <returns>减操作是否成功</returns> | /// <returns>减操作是否成功</returns> | ||||
| public int TrySubHp(int sub) | public int TrySubHp(int sub) | ||||
| { | { | ||||
| int previousHp = hp; | |||||
| lock (gameObjLock) | |||||
| hp = hp >= sub ? 0 : hp - sub; | |||||
| Debugger.Output(this, " hp has subed to: " + hp.ToString()); | |||||
| return previousHp - hp; | |||||
| int previousHp = hp; | |||||
| lock (gameObjLock) | |||||
| hp = hp >= sub ? 0 : hp - sub; | |||||
| Debugger.Output(this, " hp has subed to: " + hp.ToString()); | |||||
| return previousHp - hp; | |||||
| } | } | ||||
| /* /// <summary> | /* /// <summary> | ||||
| /// 增加死亡次数 | /// 增加死亡次数 | ||||
| @@ -325,7 +342,7 @@ namespace GameClass.GameObj | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| bullet.Parent.HP = (int)(bullet.Parent.HP + (bullet.Parent.Vampire * TrySubHp(bullet.AP))); | |||||
| bullet.Parent.HP = (int)(bullet.Parent.HP + (bullet.Parent.Vampire * TrySubHp(bullet.AP))); | |||||
| } | } | ||||
| #if DEBUG | #if DEBUG | ||||
| Console.WriteLine($"PlayerID:{ID} is being shot! Now his hp is {hp}."); | Console.WriteLine($"PlayerID:{ID} is being shot! Now his hp is {hp}."); | ||||
| @@ -1,5 +1,5 @@ | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| namespace GameClass.GameObj | |||||
| namespace GameClass.GameObj | |||||
| ======= | ======= | ||||
| using Preparation.Utility; | using Preparation.Utility; | ||||
| @@ -133,9 +133,11 @@ namespace GameClass.Skill | |||||
| { | { | ||||
| lock (activeSkill.ActiveSkillLock) | lock (activeSkill.ActiveSkillLock) | ||||
| { | { | ||||
| if (player.TimeUntilCommonSkillAvailable == 0) | |||||
| ActiveSkillType activeSkillType = FindActiveSkillType(activeSkill); | |||||
| if (player.TimeUntilActiveSkillAvailable[activeSkillType] == 0) | |||||
| { | { | ||||
| player.TimeUntilCommonSkillAvailable = activeSkill.SkillCD; | |||||
| player.SetTimeUntilActiveSkillAvailable(activeSkillType, activeSkill.SkillCD); | |||||
| new Thread | new Thread | ||||
| (() => | (() => | ||||
| { | { | ||||
| @@ -144,7 +146,7 @@ namespace GameClass.Skill | |||||
| () => !player.IsResetting, | () => !player.IsResetting, | ||||
| () => | () => | ||||
| { | { | ||||
| player.TimeUntilCommonSkillAvailable -= (int)GameData.frameDuration; | |||||
| player.AddTimeUntilActiveSkillAvailable(activeSkillType, -(int)GameData.frameDuration); | |||||
| }, | }, | ||||
| timeInterval: GameData.frameDuration, | timeInterval: GameData.frameDuration, | ||||
| () => 0, | () => 0, | ||||
| @@ -160,10 +162,10 @@ namespace GameClass.Skill | |||||
| Debugger.Output(player, "return to normal."); | Debugger.Output(player, "return to normal."); | ||||
| new FrameRateTaskExecutor<int>( | new FrameRateTaskExecutor<int>( | ||||
| () => player.TimeUntilCommonSkillAvailable > 0 && !player.IsResetting, | |||||
| () => player.TimeUntilActiveSkillAvailable[activeSkillType] > 0 && !player.IsResetting, | |||||
| () => | () => | ||||
| { | { | ||||
| player.TimeUntilCommonSkillAvailable -= (int)GameData.frameDuration; | |||||
| player.AddTimeUntilActiveSkillAvailable(activeSkillType, -(int)GameData.frameDuration); | |||||
| }, | }, | ||||
| timeInterval: GameData.frameDuration, | timeInterval: GameData.frameDuration, | ||||
| () => 0, | () => 0, | ||||
| @@ -175,7 +177,7 @@ namespace GameClass.Skill | |||||
| } | } | ||||
| .Start(); | .Start(); | ||||
| player.TimeUntilCommonSkillAvailable = 0; | |||||
| player.SetTimeUntilActiveSkillAvailable(activeSkillType, 0); | |||||
| Debugger.Output(player, "CommonSkill is ready."); | Debugger.Output(player, "CommonSkill is ready."); | ||||
| } | } | ||||
| ) | ) | ||||
| @@ -190,8 +192,8 @@ namespace GameClass.Skill | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| public static IActiveSkill FindIActiveSkill(ActiveSkillType activeSkillType) | |||||
| { | |||||
| public static IActiveSkill FindIActiveSkill(ActiveSkillType activeSkillType) | |||||
| { | |||||
| switch (activeSkillType) | switch (activeSkillType) | ||||
| { | { | ||||
| case ActiveSkillType.BecomeInvisible: | case ActiveSkillType.BecomeInvisible: | ||||
| @@ -199,7 +201,17 @@ namespace GameClass.Skill | |||||
| default: | default: | ||||
| return null; | return null; | ||||
| } | } | ||||
| } | |||||
| } | |||||
| public static ActiveSkillType FindActiveSkillType(IActiveSkill ActiveSkill) | |||||
| { | |||||
| switch (ActiveSkill) | |||||
| { | |||||
| case BecomeInvisible: | |||||
| return ActiveSkillType.BecomeInvisible; | |||||
| default: | |||||
| return ActiveSkillType.Null; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -7,7 +7,7 @@ namespace GameClass.Skill | |||||
| public interface ISkill | public interface ISkill | ||||
| { | { | ||||
| } | } | ||||
| public interface IPassiveSkill: ISkill | |||||
| public interface IPassiveSkill : ISkill | |||||
| { | { | ||||
| public void SkillEffect(Character player); | public void SkillEffect(Character player); | ||||
| } | } | ||||
| @@ -7,26 +7,34 @@ using System.Collections.Generic; | |||||
| namespace GameClass.Skill | namespace GameClass.Skill | ||||
| { | { | ||||
| public abstract class Occupation | |||||
| public interface IOccupation | |||||
| { | { | ||||
| public abstract int MoveSpeed { get; } | |||||
| public abstract int MaxHp { get; } | |||||
| public abstract BulletType InitBullet { get; } | |||||
| public abstract List<IActiveSkill> ListOfIActiveSkill { get; } | |||||
| public abstract List<IPassiveSkill> ListOfIPassiveSkill { get; } | |||||
| public int MoveSpeed { get; } | |||||
| public int MaxHp { get; } | |||||
| public BulletType InitBullet { get; } | |||||
| public int CD { get; } | |||||
| public int MaxBulletNum { get; } | |||||
| public List<IActiveSkill> ListOfIActiveSkill { get; } | |||||
| public List<IPassiveSkill> ListOfIPassiveSkill { get; } | |||||
| } | } | ||||
| public class Assassin : Occupation | |||||
| public class Assassin : IOccupation | |||||
| { | { | ||||
| private const int moveSpeed = GameData.basicMoveSpeed/380*473; | |||||
| public override int MoveSpeed => moveSpeed; | |||||
| private const int moveSpeed = GameData.basicMoveSpeed / 380 * 473; | |||||
| public int MoveSpeed => moveSpeed; | |||||
| private const int maxHp = GameData.basicHp; | private const int maxHp = GameData.basicHp; | ||||
| public override int MaxHp => maxHp; | |||||
| public int MaxHp => maxHp; | |||||
| public override BulletType InitBullet => BulletType.CommonAttackOfGhost; | |||||
| public const int cd = 0; | |||||
| public int CD => cd; | |||||
| public override List<IActiveSkill> ListOfIActiveSkill => new(new IActiveSkill[]{new BecomeInvisible(),}); | |||||
| public override List<IPassiveSkill> ListOfIPassiveSkill => new(new IPassiveSkill[] {}); | |||||
| public const int maxBulletNum = 1; | |||||
| public int MaxBulletNum => maxBulletNum; | |||||
| public BulletType InitBullet => BulletType.CommonAttackOfGhost; | |||||
| public List<IActiveSkill> ListOfIActiveSkill => new(new IActiveSkill[] { new BecomeInvisible(), }); | |||||
| public List<IPassiveSkill> ListOfIPassiveSkill => new(new IPassiveSkill[] { }); | |||||
| } | } | ||||
| } | } | ||||
| @@ -149,4 +149,25 @@ namespace GameClass.Skill // 被动技能开局时就释放,持续到游戏 | |||||
| { | { | ||||
| } | } | ||||
| } | } | ||||
| public static class PassiveSkillFactory | |||||
| { | |||||
| public static IPassiveSkill FindIPassiveSkill(PassiveSkillType passiveSkillType) | |||||
| { | |||||
| switch (passiveSkillType) | |||||
| { | |||||
| default: | |||||
| return null; | |||||
| } | |||||
| } | |||||
| public static PassiveSkillType FindpassiveSkillType(IPassiveSkill passiveSkill) | |||||
| { | |||||
| switch (passiveSkill) | |||||
| { | |||||
| default: | |||||
| return PassiveSkillType.Null; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -37,15 +37,15 @@ namespace Gaming | |||||
| } | } | ||||
| private bool CanBeBombed(Bullet bullet, GameObjType gameObjType) | private bool CanBeBombed(Bullet bullet, GameObjType gameObjType) | ||||
| { | { | ||||
| if (gameObjType==GameObjType.Character)return true; | |||||
| return false; | |||||
| if (gameObjType == GameObjType.Character) return true; | |||||
| return false; | |||||
| } | } | ||||
| private void BombObj(Bullet bullet, GameObj objBeingShot) | private void BombObj(Bullet bullet, GameObj objBeingShot) | ||||
| { | { | ||||
| switch (objBeingShot.Type) | switch (objBeingShot.Type) | ||||
| { | { | ||||
| case GameObjType.Character: | case GameObjType.Character: | ||||
| Character playerBeingShot= (Character)objBeingShot; | |||||
| Character playerBeingShot = (Character)objBeingShot; | |||||
| if (playerBeingShot.BeAttacked(bullet)) | if (playerBeingShot.BeAttacked(bullet)) | ||||
| { | { | ||||
| playerBeingShot.CanMove = false; | playerBeingShot.CanMove = false; | ||||
| @@ -80,30 +80,30 @@ namespace Gaming | |||||
| playerBeingShot.Reset(); | playerBeingShot.Reset(); | ||||
| ((Character?)bullet.Parent)?.AddScore(GameData.addScoreWhenKillOneLevelPlayer); // 给击杀者加分 | ((Character?)bullet.Parent)?.AddScore(GameData.addScoreWhenKillOneLevelPlayer); // 给击杀者加分 | ||||
| /* new Thread | |||||
| (() => | |||||
| { | |||||
| /* new Thread | |||||
| (() => | |||||
| { | |||||
| Thread.Sleep(GameData.reviveTime); | |||||
| Thread.Sleep(GameData.reviveTime); | |||||
| playerBeingShot.AddShield(GameData.shieldTimeAtBirth); // 复活加个盾 | |||||
| playerBeingShot.AddShield(GameData.shieldTimeAtBirth); // 复活加个盾 | |||||
| // gameMap.GameObjLockDict[GameObjType.Character].EnterWriteLock(); | |||||
| // try | |||||
| //{ | |||||
| // gameMap.GameObjDict[GameObjType.Character].Add(playerBeingShot); | |||||
| // } | |||||
| // finally { gameMap.GameObjLockDict[GameObjType.Character].ExitWriteLock(); } | |||||
| // gameMap.GameObjLockDict[GameObjType.Character].EnterWriteLock(); | |||||
| // try | |||||
| //{ | |||||
| // gameMap.GameObjDict[GameObjType.Character].Add(playerBeingShot); | |||||
| // } | |||||
| // finally { gameMap.GameObjLockDict[GameObjType.Character].ExitWriteLock(); } | |||||
| if (gameMap.Timer.IsGaming) | |||||
| { | |||||
| playerBeingShot.CanMove = true; | |||||
| if (gameMap.Timer.IsGaming) | |||||
| { | |||||
| playerBeingShot.CanMove = true; | |||||
| } | |||||
| playerBeingShot.IsResetting = false; | |||||
| } | } | ||||
| playerBeingShot.IsResetting = false; | |||||
| } | |||||
| ) | |||||
| { IsBackground = true }.Start(); | |||||
| */ | |||||
| ) | |||||
| { IsBackground = true }.Start(); | |||||
| */ | |||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -141,14 +141,14 @@ namespace Gaming | |||||
| gameMap.GameObjLockDict[GameObjType.Bullet].ExitWriteLock(); | gameMap.GameObjLockDict[GameObjType.Bullet].ExitWriteLock(); | ||||
| } | } | ||||
| if (!bullet.IsToBomb) | |||||
| if (!bullet.IsToBomb) | |||||
| { | { | ||||
| if (objBeingShot==null) | |||||
| if (objBeingShot == null) | |||||
| { | { | ||||
| if (bullet.Backswing>0) | |||||
| if (bullet.Backswing > 0) | |||||
| { | { | ||||
| bullet.Parent.CanMove=false; | |||||
| bullet.Parent.IsMoving=false; | |||||
| bullet.Parent.CanMove = false; | |||||
| bullet.Parent.IsMoving = false; | |||||
| new Thread | new Thread | ||||
| (() => | (() => | ||||
| @@ -165,13 +165,13 @@ namespace Gaming | |||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| BombObj(bullet, objBeingShot); | BombObj(bullet, objBeingShot); | ||||
| if (bullet.RecoveryFromHit>0) | |||||
| if (bullet.RecoveryFromHit > 0) | |||||
| { | { | ||||
| bullet.Parent.CanMove=false; | |||||
| bullet.Parent.IsMoving=false; | |||||
| bullet.Parent.CanMove = false; | |||||
| bullet.Parent.IsMoving = false; | |||||
| new Thread | new Thread | ||||
| (() => | (() => | ||||
| @@ -226,12 +226,12 @@ namespace Gaming | |||||
| { | { | ||||
| BombObj(bullet, beAttackedObj); | BombObj(bullet, beAttackedObj); | ||||
| } | } | ||||
| if (objBeingShot==null) | |||||
| if (objBeingShot == null) | |||||
| { | { | ||||
| if (bullet.Backswing>0) | |||||
| if (bullet.Backswing > 0) | |||||
| { | { | ||||
| bullet.Parent.CanMove=false; | |||||
| bullet.Parent.IsMoving=false; | |||||
| bullet.Parent.CanMove = false; | |||||
| bullet.Parent.IsMoving = false; | |||||
| new Thread | new Thread | ||||
| (() => | (() => | ||||
| @@ -247,12 +247,12 @@ namespace Gaming | |||||
| { IsBackground = true }.Start(); | { IsBackground = true }.Start(); | ||||
| } | } | ||||
| } | } | ||||
| else | |||||
| else | |||||
| { | { | ||||
| if (bullet.RecoveryFromHit>0) | |||||
| if (bullet.RecoveryFromHit > 0) | |||||
| { | { | ||||
| bullet.Parent.CanMove=false; | |||||
| bullet.Parent.IsMoving=false; | |||||
| bullet.Parent.CanMove = false; | |||||
| bullet.Parent.IsMoving = false; | |||||
| new Thread | new Thread | ||||
| (() => | (() => | ||||
| @@ -268,7 +268,7 @@ namespace Gaming | |||||
| ) | ) | ||||
| { IsBackground = true }.Start(); | { IsBackground = true }.Start(); | ||||
| } | } | ||||
| } | |||||
| } | |||||
| beAttackedList.Clear(); | beAttackedList.Clear(); | ||||
| } | } | ||||
| @@ -31,7 +31,7 @@ namespace Gaming | |||||
| public List<Team> TeamList => teamList; | public List<Team> TeamList => teamList; | ||||
| private readonly Map gameMap; | private readonly Map gameMap; | ||||
| public Map GameMap => gameMap; | public Map GameMap => gameMap; | ||||
| // private readonly int numOfTeam; | |||||
| // private readonly int numOfTeam; | |||||
| public long AddPlayer(PlayerInitInfo playerInitInfo) | public long AddPlayer(PlayerInitInfo playerInitInfo) | ||||
| { | { | ||||
| if (!Team.teamExists(playerInitInfo.teamID)) | if (!Team.teamExists(playerInitInfo.teamID)) | ||||
| @@ -132,7 +132,7 @@ namespace Gaming | |||||
| if (kvp.Key == GameObjType.Bullet || kvp.Key == GameObjType.Character || kvp.Key == GameObjType.Prop) | if (kvp.Key == GameObjType.Bullet || kvp.Key == GameObjType.Character || kvp.Key == GameObjType.Prop) | ||||
| { | { | ||||
| gameMap.GameObjLockDict[kvp.Key].EnterWriteLock(); | gameMap.GameObjLockDict[kvp.Key].EnterWriteLock(); | ||||
| try | |||||
| try | |||||
| { | { | ||||
| foreach (var item in gameMap.GameObjDict[kvp.Key]) | foreach (var item in gameMap.GameObjDict[kvp.Key]) | ||||
| { | { | ||||
| @@ -236,14 +236,14 @@ namespace Gaming | |||||
| return false; | return false; | ||||
| } | } | ||||
| public bool UseCommonSkill(long playerID) | |||||
| public bool UseActiveSkill(long playerID, ActiveSkillType activeSkillType) | |||||
| { | { | ||||
| if (!gameMap.Timer.IsGaming) | if (!gameMap.Timer.IsGaming) | ||||
| return false; | return false; | ||||
| Character? player = gameMap.FindPlayer(playerID); | Character? player = gameMap.FindPlayer(playerID); | ||||
| if (player != null) | if (player != null) | ||||
| { | { | ||||
| return skillManager.UseCommonSkill(player); | |||||
| return skillManager.UseActiveSkill(player, activeSkillType); | |||||
| } | } | ||||
| else | else | ||||
| return false; | return false; | ||||
| @@ -258,7 +258,7 @@ namespace Gaming | |||||
| { | { | ||||
| foreach (Character player in gameMap.GameObjDict[GameObjType.Character]) | foreach (Character player in gameMap.GameObjDict[GameObjType.Character]) | ||||
| { | { | ||||
| skillManager.UsePassiveSkill(player); | |||||
| skillManager.UseAllPassiveSkill(player); | |||||
| } | } | ||||
| } | } | ||||
| finally | finally | ||||
| @@ -342,7 +342,7 @@ namespace Gaming | |||||
| gameMap = new Map(mapResource); | gameMap = new Map(mapResource); | ||||
| // 加入队伍 | // 加入队伍 | ||||
| // this.numOfTeam = numOfTeam; | |||||
| // this.numOfTeam = numOfTeam; | |||||
| teamList = new List<Team>(); | teamList = new List<Team>(); | ||||
| for (int i = 0; i < numOfTeam; ++i) | for (int i = 0; i < numOfTeam; ++i) | ||||
| { | { | ||||
| @@ -1,5 +1,8 @@ | |||||
| using System; | using System; | ||||
| using Preparation.Utility; | |||||
| using GameClass.GameObj; | using GameClass.GameObj; | ||||
| using System.Reflection; | |||||
| using GameClass.Skill; | |||||
| namespace Gaming | namespace Gaming | ||||
| { | { | ||||
| @@ -8,13 +11,18 @@ namespace Gaming | |||||
| readonly SkillManager skillManager; | readonly SkillManager skillManager; | ||||
| private class SkillManager | private class SkillManager | ||||
| { | { | ||||
| public bool UseCommonSkill(Character character) | |||||
| public bool UseActiveSkill(Character character, ActiveSkillType activeSkillType) | |||||
| { | { | ||||
| return character.UseCommonSkill(); | |||||
| return character.UseActiveSkill(activeSkillType); | |||||
| } | } | ||||
| public void UsePassiveSkill(Character character) | |||||
| public void UsePassiveSkill(Character character, PassiveSkillType passiveSkillType) | |||||
| { | { | ||||
| character.UsePassiveSkill(); | |||||
| character.UsePassiveSkill(passiveSkillType); | |||||
| } | |||||
| public void UseAllPassiveSkill(Character character) | |||||
| { | |||||
| foreach (var passiveSkill in character.Occupation.ListOfIPassiveSkill) | |||||
| character.UsePassiveSkill(PassiveSkillFactory.FindpassiveSkillType(passiveSkill)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -75,6 +75,16 @@ namespace Preparation.Utility | |||||
| ASkill4 = 5, | ASkill4 = 5, | ||||
| ASkill5 = 6 | ASkill5 = 6 | ||||
| } | } | ||||
| public enum PassiveSkillType | |||||
| { | |||||
| Null = 0, | |||||
| BecomeInvisible = 1, | |||||
| BecomeVampire = 2, | |||||
| NuclearWeapon = 3, | |||||
| SuperFast = 4, | |||||
| ASkill4 = 5, | |||||
| ASkill5 = 6 | |||||
| } | |||||
| public enum BuffType // buff | public enum BuffType // buff | ||||
| { | { | ||||
| Null = 0, | Null = 0, | ||||
| @@ -40,13 +40,14 @@ namespace Preparation.Utility | |||||
| } | } | ||||
| public static bool ApproachToInteract(XY pos1, XY pos2) | public static bool ApproachToInteract(XY pos1, XY pos2) | ||||
| { | { | ||||
| return Math.Abs(PosGridToCellX(pos1) - PosGridToCellX(pos2))<=1 && Math.Abs(PosGridToCellY(pos1) - PosGridToCellY(pos2))<=1; | |||||
| return Math.Abs(PosGridToCellX(pos1) - PosGridToCellX(pos2)) <= 1 && Math.Abs(PosGridToCellY(pos1) - PosGridToCellY(pos2)) <= 1; | |||||
| } | } | ||||
| #endregion | #endregion | ||||
| #region 角色相关 | #region 角色相关 | ||||
| public const int characterRadius = numOfPosGridPerCell / 2; // 人物半径 | public const int characterRadius = numOfPosGridPerCell / 2; // 人物半径 | ||||
| public const int basicApOfGhost = 500; // 初始攻击力 | public const int basicApOfGhost = 500; // 初始攻击力 | ||||
| public const int basicHp = 1003; // 初始血量 | public const int basicHp = 1003; // 初始血量 | ||||
| public const int basicCD = 3000; // 初始子弹冷却 | |||||
| public const int basicBackswing = 500;//基本后摇时间 | public const int basicBackswing = 500;//基本后摇时间 | ||||
| public const int basicRecoveryFromHit = 4300;//基本命中攻击恢复时长 | public const int basicRecoveryFromHit = 4300;//基本命中攻击恢复时长 | ||||
| public const int basicBulletNum = 3; // 基本初始子弹量 | public const int basicBulletNum = 3; // 基本初始子弹量 | ||||