Esempio n. 1
0
    public override void OnStartDragging(float x, float y)
    {
        if (currentSelAvatar != null)
        {
            currentSelAvatar.Color = MapAvatar.ColorDefault;
            currentSelAvatar       = null;
        }

        WorldPos2MapPos(x, y, out float gx, out float gy);
        var avatar = BattleStage.GetAvatarAt((int)gx, (int)gy);

        if (avatar == null || avatar.Warrior.Team != Room.PlayerMe)
        {
            base.OnStartDragging(x, y);
            return;
        }

        // 显示指针,并隐藏准备拖拽的对象
        currentSelAvatar = avatar;
        PointerIndicator.SetActive(true);
        PointerIndicator.GetComponent <PoniterIndicator>().SetIdleAnimation(currentSelAvatar);
        PointerIndicator.transform.position = currentSelAvatar.transform.position;
        dragPointerOffset = new Vector2(PointerIndicator.transform.position.x - x, PointerIndicator.transform.position.y - y);
        currentSelAvatar.gameObject.SetActive(false);
    }
Esempio n. 2
0
    public override void OnClicked(float x, float y)
    {
        WorldPos2MapPos(x, y, out float gx, out float gy);
        var avatar = BattleStage.GetAvatarAt((int)gx, (int)gy);

        if (currentSelAvatar == null && avatar != null && avatar.Warrior.Team == Room.PlayerMe)
        {
            // 选中要移动的角色
            currentSelAvatar        = avatar;
            avatar.IsShowClickFrame = true;
        }
        else if (currentSelAvatar != null)
        {
            // 交换角色位置
            var mapTile = BattleStage.GetMapTileAt((int)gx, (int)gy);
            currentSelAvatar.IsShowClickFrame = false;
            if (mapTile != null && mapTile.MapData.RespawnForChamp == false)
            {
                currentSelAvatar = null;
                return;
            }
            Room.DoExchangeWarroirsPosition(currentSelAvatar.X, currentSelAvatar.Y, (int)gx, (int)gy);
            currentSelAvatar = null;
        }
    }
Esempio n. 3
0
 // 清除攻击范围显示
 public void RemoveShowAttackRange()
 {
     FC.For(pathATKRange.Count, (i) =>
     {
         var avatar = BattleStage.GetAvatarAt(pathATKRange[i].X, pathATKRange[i].Y);
         if (avatar != null && avatar.AttackHint.activeSelf)
         {
             avatar.AttackHint.SetActive(false);
         }
     });
     BattleStage.RemoveTile(pathATKRange);
 }
Esempio n. 4
0
 // 显示攻击范围
 public void ShowAttackRange(float x, float y, Warrior worrior)
 {
     Debug.Assert(pathATKRange.Count == 0, "path range is not empty now.");
     FC.For(worrior.AttackRange.Length, (i) =>
     {
         int minX = (x - worrior.AttackRange[i]) < 0 ? 0 : (int)(x - worrior.AttackRange[i]);
         int maxX = (x + worrior.AttackRange[i]) >= BattleStage.Map.Width ? BattleStage.Map.Width : (int)(x + worrior.AttackRange[i] + 1);
         int minY = (y - worrior.AttackRange[i]) < 0 ? 0 : (int)(y - worrior.AttackRange[i]);
         int maxY = (y + worrior.AttackRange[i]) >= BattleStage.Map.Height ? BattleStage.Map.Height : (int)(y + worrior.AttackRange[i] + 1);
         FC.For2(minX, maxX, minY, maxY, (tx, ty) =>
         {
             if (MU.ManhattanDist((int)x, (int)y, tx, ty) == worrior.AttackRange[i])
             {
                 var tile = BattleStage.CreateMapTile(tx, ty);
                 pathATKRange.Add(tile);
                 var avatar = BattleStage.GetAvatarAt(tx, ty);
                 if (avatar != null && avatar.Warrior.Team != worrior.Team)
                 {
                     avatar.AttackHint.SetActive(true);
                 }
             }
         });
     });
 }