示例#1
0
    //获取攻击目标
    //一般来说isskill没什么用,但如果技能和平A攻击范围不同时有用
    //面对范围攻击的情况,此处返回值修改为list
    public List <Character> Get_target(bool skill) //TODO
    {
        List <Character> list = new List <Character>();

        Vector3Int location = Get_location();

        //设置battleData
        if (battleData == null)
        {
            battleData = controller.Instance.battleData;
        }
        Character[,,] enemies = battleData.GetCharacterList();
        Character enemy;
        int       enemyGroup = location[0] == 0? 1 : 0;

        for (int i = 0; i < 3; i++)
        {
            //检测当前位置有没有东西
            if (!battleData.hasCharacterInGrid(enemyGroup, location.y, i))
            {
                continue;
            }
            enemy = enemies[enemyGroup, location.y, i];
            if (enemy._hp > 0)
            {
                list.Add(enemy);
                return(list);
            }
        }

        for (int i = 0; i < 3; i++)
        {
            if (i != location.y)
            {
                for (int j = 0; j < 3; j++)
                {
                    //检测当前位置有没有东西
                    if (!battleData.hasCharacterInGrid(enemyGroup, i, j))
                    {
                        continue;
                    }
                    enemy = enemies[enemyGroup, i, j];
                    if (enemy._hp > 0)
                    {
                        list.Add(enemy);
                        return(list);
                    }
                }
            }
        }

        return(null);
    }
示例#2
0
    //根据list中的单位,加载prefab同时加载到格子里面
    //最好直接把prefab中的脚本换掉
    private void loadPrefab()
    {
        for (int i = 0; i < 2; i++)
        {
            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    //该位置的单位不为空
                    if (battleData.hasCharacterInGrid(i, x, y))
                    {
                        int id = battleData.GetCharacterList()[i, x, y].GetId();
                        //加载prefab
                        GameObject obj = Resources.Load("Prefabs/character/" + id) as GameObject;
                        obj = Instantiate(obj);
                        //Debug.Log(obj.GetComponent<Character>().GetInstanceID());
                        obj.SetActive(false);
                        GridUnit grid = GetGridUnitByVector3(new Vector3Int(i, x, y)); //获取对应格子
                        obj.transform.SetParent(CharacterTransform);                   //设置位置
                        //设置位置测试
                        obj.transform.position = grid.gameObject.transform.position;

                        //重置list中的character
                        battleData.GetCharacterList()[i, x, y] = obj.GetComponentInChildren <Character>();
                        //往格子里加单位
                        grid.SetCharacter(battleData.GetCharacterList()[i, x, y]);
                        //设置character中自己的坐标
                        battleData.GetCharacterList()[i, x, y].SetLocation(new Vector3Int(i, x, y));
                    }
                }
            }
        }
    }
示例#3
0
    //被动:行动结束后友方攻击力最高的攻击力加40%,持续1回合
    public override List <int> Action(battle_data battleData)
    {
        List <int> msg = base.Action(battleData);

        if (battleData == null)
        {
            battleData = controller.Instance.battleData;
        }
        Character[,,] enemies = battleData.GetCharacterList();
        Character friend;
        Character target = this;

        //检测攻击力最高的
        int f = Get_location()[0];

        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (!battleData.hasCharacterInGrid(f, i, j))
                {
                    continue;
                }
                friend = enemies[f, i, j];
                if (friend._hp > 0 && friend._atk > target._atk)
                {
                    target = friend;
                }
            }
        }

        //给攻击力最高的上buff
        target.Get_buff(new Buff(BuffKind.Atk, 40, true, 1));

        return(msg);
    }
示例#4
0
    //获取攻击目标
    //一般来说isskill没什么用,但如果技能和平A攻击范围不同时有用
    //面对范围攻击的情况,此处返回值修改为list
    public virtual List <Character> Get_target(bool skill)
    {
        List <Character> list = new List <Character>();

        Vector3Int location = Get_location();

        //设置battleData
        if (battleData == null)
        {
            battleData = controller.Instance.battleData;
        }
        Character[,,] enemies = battleData.GetCharacterList();
        Character enemy;
        int       enemyGroup = location[0] == 0 ? 1 : 0;

        //检测嘲讽
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (!battleData.hasCharacterInGrid(enemyGroup, i, j))
                {
                    continue;
                }
                enemy = enemies[enemyGroup, i, j];
                if (enemy._hp > 0)
                {
                    //检测嘲讽
                    foreach (Buff buff in enemy._buffs)
                    {
                        if (buff._buffKind == BuffKind.Taunt)
                        {
                            list.Add(enemy);
                            return(list);
                        }
                    }
                }
            }
        }

        //优先打本列的
        for (int i = 0; i < 3; i++)
        {
            //检测当前位置有没有东西
            if (!battleData.hasCharacterInGrid(enemyGroup, location.y, i))
            {
                continue;
            }
            enemy = enemies[enemyGroup, location.y, i];
            if (enemy._hp > 0)
            {
                list.Add(enemy);
                return(list);
            }
        }

        //没有本列的,优先打近的那一列
        for (int i = (location.y == 2 ? 2 : 0), step = (location.y == 2 ? -1 : 1);
             i < 3 && i >= 0;
             i += step)
        {
            if (i != location.y)
            {
                for (int j = 0; j < 3; j++)
                {
                    //检测当前位置有没有东西
                    if (!battleData.hasCharacterInGrid(enemyGroup, i, j))
                    {
                        continue;
                    }
                    enemy = enemies[enemyGroup, i, j];
                    if (enemy._hp > 0)
                    {
                        list.Add(enemy);
                        return(list);
                    }
                }
            }
        }

        return(null);
    }