コード例 #1
0
ファイル: DefaultTactic.cs プロジェクト: donblas/magecrawl
        public override bool UseTactic(IGameEngineCore engine, Monster monster)
        {
            if (IsPlayerVisible(engine, monster))
            {
                List<Point> pathToPlayer = GetPathToPlayer(engine, monster);

                if (IsNextToPlayer(engine, pathToPlayer))
                {
                    if (AttackPlayer(engine, monster))
                        return true;
                }

                if (HasPathToPlayer(engine, pathToPlayer))
                {
                    if (MoveOnPath(engine, pathToPlayer, monster))
                        return true;
                }
            }
            else
            {
                if (WalkTowardsLastKnownPosition(engine, monster))
                    return true;
            }
            WanderRandomly(engine, monster);   // We have nothing else to do, so wander                
            return true;
        }
コード例 #2
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
 protected int GetPathToPlayerLength(IGameEngineCore engine, Monster monster)
 {
     List<Point> pathToPlayer = GetPathToPlayer(engine, monster);
     if (pathToPlayer == null)
         return -1;
     return pathToPlayer.Count;
 }
コード例 #3
0
 public override bool UseTactic(IGameEngineCore engine, Monster monster)
 {
     bool usedSkill = engine.MonsterSkillEngine.UseSkill(monster, MonsterSkillType.SlingStone, engine.Player.Position);
     if (usedSkill)
         UsedCooldown(monster, CooldownName, CooldownAmount);
     return usedSkill;
 }
コード例 #4
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
 private bool MoveCore(IGameEngineCore engine, Direction direction, Monster monster)
 {
     if (engine.Move(monster, direction))
         return true;
     Point position = PointDirectionUtils.ConvertDirectionToDestinationPoint(monster.Position, direction);
     if (monster.Intelligent && engine.Operate(monster, position))
         return true;
     return false;
 }
コード例 #5
0
 public override bool CouldUseTactic(IGameEngineCore engine, Monster monster)
 {
     if (CanUseCooldown(monster, CooldownName))
     {
         int range = GetPathToPlayer(engine, monster).Count;
         if (range > 2)
             return true;
     }
     return false;
 }
コード例 #6
0
 public override bool CouldUseTactic(IGameEngineCore engine, Monster monster)
 {
     // If see an ally who's wounded (I have something to do)
     List<Character> nearbyAllies = OtherNearbyEnemies(engine, monster);
     foreach (Character allyNeedingHealing in nearbyAllies.Where(x => x.CurrentHP < x.MaxHP).OrderBy(x => x.CurrentHP))
     {
         List<Point> pathToAlly = GetPathToCharacter(engine, monster, allyNeedingHealing);
         if (pathToAlly != null && pathToAlly.Count > 1)
             return true;
     }
     return false;
 }
コード例 #7
0
 public override bool CouldUseTactic(IGameEngineCore engine, Monster monster)
 {
     List<Character> nearbyAllies = OtherNearbyEnemies(engine, monster);
     if (nearbyAllies.Count > 0 && CanUseCooldown(monster, CooldownName))
     {
         foreach (Character allyNeedingHealing in nearbyAllies.Where(x => x.CurrentHP < x.MaxHP).OrderBy(x => x.CurrentHP))
         {
             List<Point> pathToAlly = GetPathToCharacter(engine, monster, allyNeedingHealing);
             if (pathToAlly != null && pathToAlly.Count <= 1)
                 return true;
         }
     }
     return false;
 }
コード例 #8
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
        protected bool WalkTowardsLastKnownPosition(IGameEngineCore engine, Monster monster)
        {
            if (monster.PlayerLastKnownPosition == Point.Invalid)
                return false;

            List<Point> pathTowards = engine.PathToPoint(monster, monster.PlayerLastKnownPosition, monster.Intelligent, false, true);
            if (pathTowards == null || pathTowards.Count == 0)
            {
                monster.PlayerLastKnownPosition = Point.Invalid;
                return false;
            }
            else
            {
                return MoveOnPath(engine, pathTowards, monster);
            }
        }
コード例 #9
0
 public override bool UseTactic(IGameEngineCore engine, Monster monster)
 {
     List<Character> nearbyAllies = OtherNearbyEnemies(engine, monster);
     if (nearbyAllies.Count > 0 && CanUseCooldown(monster, CooldownName))
     {
         foreach (Character allyNeedingHealing in nearbyAllies.Where(x => x.CurrentHP < x.MaxHP).OrderBy(x => x.CurrentHP))
         {
             List<Point> pathToAlly = GetPathToCharacter(engine, monster, allyNeedingHealing);
             if (pathToAlly != null && pathToAlly.Count <= 1)
             {
                 engine.MonsterSkillEngine.UseSkill(monster, MonsterSkillType.FirstAid, allyNeedingHealing.Position);
                 UsedCooldown(monster, CooldownName, CooldownAmount);
                 return true;
             }
         }
     }
     return false;
 }
コード例 #10
0
 public override bool UseTactic(IGameEngineCore engine, Monster monster)
 {
     if (s_random.Chance(50))
         return MoveTowardsPlayer(engine, monster);
     return false;
 }
コード例 #11
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
 protected bool MoveOnPath(IGameEngineCore engine, List<Point> path, Monster monster)
 {
     Direction nextPosition = PointDirectionUtils.ConvertTwoPointsToDirection(monster.Position, path[0]);
     return MoveCore(engine, nextPosition, monster);
 }
コード例 #12
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
 public abstract bool UseTactic(IGameEngineCore engine, Monster monster);
コード例 #13
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
 protected bool MoveTowardsPlayer(IGameEngineCore engine, Monster monster)
 {
     return MoveOnPath(engine, GetPathToPlayer(engine, monster), monster);
 }
コード例 #14
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
 protected bool AreOtherNearbyEnemies(IGameEngineCore engine, Monster monster)
 {
     return OtherNearbyEnemies(engine, monster).Count() > 1;
 }
コード例 #15
0
ファイル: RushTactic.cs プロジェクト: donblas/magecrawl
 public override bool CouldUseTactic(IGameEngineCore engine, Monster monster)
 {
    return GetPathToPlayerLength(engine, monster) == 2;
 }
コード例 #16
0
ファイル: EffectEngine.cs プロジェクト: donblas/magecrawl
 public EffectEngine(IGameEngineCore engine)
 {
     m_engine = engine;
 }
コード例 #17
0
 public override bool UseTactic(IGameEngineCore engine, Monster monster)
 {
     if (AreOtherNearbyEnemies(engine, monster))
         return MoveAwayFromPlayer(engine, monster);
     return false;
 }
コード例 #18
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
 protected bool IsNextToPlayer(IGameEngineCore engine, Monster monster)
 {
     return GetPathToPlayerLength(engine, monster) == 1;
 }
コード例 #19
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
 protected List<Point> GetPathToPlayer(IGameEngineCore engine, Monster monster)
 {
     return engine.PathToPoint(monster, engine.Player.Position, monster.Intelligent, false, true);
 }
コード例 #20
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
        protected bool WanderRandomly(IGameEngineCore engine, Monster monster)
        {
            foreach (Direction d in DirectionUtils.GenerateRandomDirectionList())
            {
                if (engine.Move(monster, d))
                    return true;
            }

            // If nothing else, 'wait'
            engine.Wait(monster);
            return false;
        }
コード例 #21
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
 protected bool IsPlayerVisible(IGameEngineCore engine, Monster monster)
 {
     return engine.FOVManager.VisibleSingleShot(engine.Map, monster.Position, monster.Vision, engine.Player.Position);
 }
コード例 #22
0
 public override bool CouldUseTactic(IGameEngineCore engine, Monster monster)
 {
     return IsNextToPlayer(engine, monster);
 }
コード例 #23
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
        protected bool MoveAwayFromPlayer(IGameEngineCore engine, Monster monster)
        {
            Direction directionTowardsPlayer = PointDirectionUtils.ConvertTwoPointsToDirection(monster.Position, engine.Player.Position);
            if (MoveCore(engine, PointDirectionUtils.GetDirectionOpposite(directionTowardsPlayer), monster))
                return true;

            foreach (Direction attemptDirection in PointDirectionUtils.GetDirectionsOpposite(directionTowardsPlayer))
            {
                if (MoveCore(engine, attemptDirection, monster))
                    return true;
            }
            return false;
        }
コード例 #24
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
 protected bool HasPathToPlayer(IGameEngineCore engine, List<Point> pathToPlayer)
 {
     return pathToPlayer != null && pathToPlayer.Count > 0;
 }
コード例 #25
0
ファイル: RushTactic.cs プロジェクト: donblas/magecrawl
 public override bool UseTactic(IGameEngineCore engine, Monster monster)
 {
     return engine.MonsterSkillEngine.UseSkill(monster, MonsterSkillType.Rush, engine.Player.Position);
 }
コード例 #26
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
 protected bool AttackPlayer(IGameEngineCore engine, Monster monster)
 {
     if (engine.Attack(monster, engine.Player.Position))
         return true;
     return false;
 }
コード例 #27
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
 protected bool IsNextToPlayer(IGameEngineCore engine, List<Point> pathToPlayer)
 {
     return pathToPlayer != null && pathToPlayer.Count == 1;
 }
コード例 #28
0
ファイル: BaseTactic.cs プロジェクト: donblas/magecrawl
 protected List<Character> OtherNearbyEnemies(IGameEngineCore engine, Monster monster)
 {
     return engine.MonstersInCharactersLOS(monster).Where(x => PointDirectionUtils.NormalDistance(x.Position, engine.Player.Position) < 4).OfType < Character>().ToList();
 }
コード例 #29
0
 public override bool CouldUseTactic(IGameEngineCore engine, Monster monster)
 {
     return true;
 }
コード例 #30
0
ファイル: Monster.cs プロジェクト: donblas/magecrawl
 protected void UpdateKnownPlayerLocation(IGameEngineCore engine)
 {
     PlayerLastKnownPosition = engine.Player.Position;
 }