예제 #1
0
 public BattleMap(int w, int h, Func <int, int, TileType> tilesFun = null)
 {
     Width  = w;
     Height = h;
     Tiles  = new TileType[w, h];
     if (tilesFun != null)
     {
         ResetTiles(tilesFun);
     }
     objs = new BattleMapObj[w, h];
     BuildPathFinder();
 }
예제 #2
0
        // 添加对象到地图
        public void SetObjAt(int x, int y, BattleMapObj obj)
        {
            if (objs[x, y] == obj)
            {
                return;
            }

            Debug.Assert(objs[x, y] == null && (obj == null || obj.Map == this), "no warrior on the map specified");

            if (objs[x, y] != null)
            {
                RemoveObj(objs[x, y]);
            }

            objs[x, y] = obj;
        }
예제 #3
0
        // 查找指定角色的地图坐标
        public void FindXY(BattleMapObj target, out int px, out int py)
        {
            Debug.Assert(target != null, "the target should not be null");
            Debug.Assert(target.Map == this, "the obj is not in the map : " + target.ID);

            var found = false;
            var tx    = 0;
            var ty    = 0;

            ForeachObjs((x, y, obj) =>
            {
                if (obj == target)
                {
                    tx    = x;
                    ty    = y;
                    found = true;
                }
            }, null, () => !found);

            Debug.Assert(found, "can not find the obj in map : " + target.ID);

            px = tx;
            py = ty;
        }
예제 #4
0
        public int TY { get; set; } // 目标坐标 y

        // 只能放在空位
        public bool TargetFilter(BattleMapObj target) => target == null;
예제 #5
0
파일: Skill.cs 프로젝트: moto2002/Avocat
 // 判断自定对象是否是敌人的函数
 public static bool EnemyChecker(this ISkillWithOwner skill, BattleMapObj target) => target is Warrior && (target as Warrior).Team != skill.Owner.Team;
예제 #6
0
파일: Skill.cs 프로젝트: moto2002/Avocat
 // 判断自定对象是否是队友的函数
 public static bool IsTeammate(this ISkillWithOwner skill, BattleMapObj target) => target is Warrior && (target as Warrior).Team == skill.Owner.Team;
예제 #7
0
 // 只能治疗队友和自己
 public bool TargetFilter(BattleMapObj target) => this.IsTeammate(target);
예제 #8
0
 // 移除地图对象
 public void RemoveObj(BattleMapObj obj)
 {
     Debug.Assert(obj == null || obj.Map == this, "the warrior is not in the map");
     FindXY(obj, out int x, out int y);
     objs[x, y] = null;
 }