示例#1
0
    public void AddEnemyToBattle(RPGCharacter ch)
    {
        UnityEngine.Assertions.Assert.AreEqual(ch.GetCamp(), EnumCharacterCamp.Enemy);
        RPGEnemy player = ch as RPGEnemy;

        enemies.Enemies.Add(player);
    }
示例#2
0
    /// <summary>
    /// 添加到战场
    /// </summary>
    public void AddPlayerToBattle(RPGCharacter ch)
    {
        UnityEngine.Assertions.Assert.AreEqual(ch.GetCamp(), EnumCharacterCamp.Player);
        RPGPlayer player = ch as RPGPlayer;

        players.Players.Add(player);
        players.PlayersLogic.Add(player.Logic);
    }
示例#3
0
    public void ExecuteMove(Vector2Int destPos)
    {
        Vector2Int srcPos = currentCharacter.GetTileCoord();

        CurrentCharacterLogic.SetTileCoord(destPos);
        CurrentCharacterLogic.ConsumeActionPoint(EnumActionType.Move);
        ChangeState(EBattleState.Lock);
        ClearRangeAction();
        gameMode.BattlePlayer.MoveUnitAfterAction(currentCharacter.GetCamp(), srcPos, destPos, ConstTable.UNIT_MOVE_SPEED(), CheckRangeEvent);
    }
示例#4
0
 public void Change(RPGCharacter ch, int ChangedHP, float delayTime = 0.0f)
 {
     if (ch.GetCamp() == EnumCharacterCamp.Player)
     {
         Player.Change(ChangedHP, delayTime);
     }
     else
     {
         Enemy.Change(ChangedHP, delayTime);
     }
 }
示例#5
0
    public void AddUnitToMap(RPGCharacter p, Vector2Int tilePos)
    {
        var       logic = p.Logic;
        Transform unit  = gameMode.unitShower.AddUnit(p.GetCamp(), logic.GetName(), logic.GetStaySprites(), logic.GetMoveSprites(), tilePos);

        p.SetTransform(unit);
        logic.SetTileCoord(tilePos);
        var camp = p.GetCamp();

        if (camp == EnumCharacterCamp.Player)
        {
            chapterManager.AddPlayerToBattle(p);
            PositionMath.SetTilePlayerOccupied(tilePos);
        }
        if (camp == EnumCharacterCamp.Enemy)
        {
            chapterManager.AddEnemyToBattle(p);
            PositionMath.SetTileEnemyOccupied(tilePos);
        }
    }
示例#6
0
文件: SLGMap.cs 项目: PenpenLi/Hifior
    public void InitActionScope(RPGCharacter Gamechar, int Movement, bool Show = true)
    {
        HideAllRange();
        bPlayer = (Gamechar.GetCamp() == EnumCharacterCamp.Player);//0,2为我方的单位

        _Mov = Movement;

        /* if (Gamechar.SkillGroup.isHaveStaticSkill(18))//探险家,无视地形,将其职业设为天马
         *   _Job = 15;//medifyneed
         * if (Gamechar.SkillGroup.isHaveStaticSkill(19))
         *   _Mov += 2;*/
        _Career         = Gamechar.Logic.GetCareer();
        CharacterCenter = new Vector2Int(Gamechar.GetTileCoord().x, Gamechar.GetTileCoord().x);

        ResetMoveAcessList();
        bMoveAcessList[CharacterCenter.x, CharacterCenter.y]         = true;
        bMoveAcessListExcluded[CharacterCenter.x, CharacterCenter.y] = true;
        _FootData.Add(CharacterCenter, new Vector2Int(-1, -1));
        _TempFootData.Add(CharacterCenter, _Mov);

        int countPoint = 0;

        while (countPoint < _Mov)
        {
            _FindDistance(Gamechar.Logic.GetCareer(), _Mov);//递归查询距离   _FindDistance(Table._JobTable.getBranch(gamechar.attribute.Job), _Mov, 0, 0);
            countPoint++;
        }

        WeaponItem item = Gamechar.Logic.Info.Items.GetEquipWeapon();

        item = new WeaponItem(1);
        if (item != null)//装备武器不为空
        {
            _AttackRangeData.Clear();
            _ItemRangeMin    = item.GetDefinition().RangeType.SelectRange.x;
            _ItemRangeMax    = item.GetDefinition().RangeType.SelectRange.y;
            _WeaponRangeType = item.GetDefinition().RangeType.SelectType;
            if (_ItemRangeMax != 0 && _ItemRangeMax - _ItemRangeMin > -1) //武器有距离
            {
                for (int i = 0; i < PList.Count; i++)                     //遍历可移动的区域
                {
                    AttackScan(PList[i]);                                 //递归查询距离   _FindDistance(Table._JobTable.getBranch(gamechar.attribute.Job), _Mov, 0, 0);
                }
            }
        }

        if (Show)
        {
            ShowMoveableRange();
            ShowAttackableRange();
        }
    }
示例#7
0
        public void Show(RPGCharacter ch)
        {
            Show();
            var logic = ch.Logic;

            if (ch.GetCamp() == EnumCharacterCamp.Player)
            {
                Player.Show(logic.GetName(), logic.GetCurrentHP(), logic.GetMaxHP());
            }
            else
            {
                Enemy.Show(logic.GetName(), logic.GetCurrentHP(), logic.GetMaxHP());
            }
        }
示例#8
0
    public void RemoveCharacter(RPGCharacter ch)
    {
        var camp = ch.GetCamp();

        if (camp == EnumCharacterCamp.Player)
        {
            players.Players.Remove(ch as RPGPlayer);
            ch.Logic.SetDead();
        }
        if (camp == EnumCharacterCamp.Enemy)
        {
            enemies.Enemies.Remove(ch as RPGEnemy);
        }
    }
示例#9
0
文件: SLGMap.cs 项目: PenpenLi/Hifior
    public void MoveToCroods(RPGCharacter Gamechar, int x, int y)
    {
        int startX = Gamechar.GetTileCoord().x;
        int startY = Gamechar.GetTileCoord().y;

        if (x == startX && y == startY)
        {
            return;
        }
        bPlayer = (Gamechar.GetCamp() == EnumCharacterCamp.Player); //0,2为我方的单位
        if (!IsEffectivelyCoordinate(x, y))                         //超出地图范围
        {
            return;
        }
        //被敌方单位占领则不可通过,被我方单位占领则可以通过,不被占领则当PassValue为小于10时可以通过
        bool bWalkable = false;

        for (int i = 0; i < TileWidth; i++)
        {
            for (int j = 0; j < TileHeight; j++)
            {
                if (GetMapPassValue(Gamechar.Logic.GetCareer(), i, j) > 10 || IsOccupiedByDiffentParty(i, j))
                {
                    bWalkable = false;
                }
                else if (IsOccupiedBySameParty(i, j))
                {
                    bWalkable = true;
                }
                else
                {
                    bWalkable = true;
                }
                AStarGrid[i, j] = new AStarNode(bWalkable, i, j);
            }
        }
        AStarNode           startNode = AStarGrid[startX, startY];
        AStarNode           endNode   = AStarGrid[x, y];
        List <AStarNode>    openSet   = new List <AStarNode>();
        HashSet <AStarNode> closeSet  = new HashSet <AStarNode>();

        openSet.Add(startNode);

        while (openSet.Count > 0)
        {
            AStarNode currentNode = openSet[0];
            for (int i = 0; i < openSet.Count; i++)
            {
                if (openSet[i].fCost < currentNode.fCost || openSet[i].fCost == currentNode.fCost && openSet[i].hCost < currentNode.hCost)
                {
                    currentNode = openSet[i];
                }
            }

            openSet.Remove(currentNode);
            closeSet.Add(currentNode);
            if (currentNode._gridX == endNode._gridX && currentNode._gridY == endNode._gridY)
            {
                GeneratePath(startNode, endNode);
                MoveByRoutine(Gamechar, _MoveRoute.ToArray());
                return;
            }
            foreach (AStarNode node in GetNeibourhood(currentNode))
            {
                if (!node._canWalk || closeSet.Contains(node))
                {
                    continue;
                }
                int newCost = currentNode.gCost + GetDistanceNode(currentNode, node);
                if (newCost < node.gCost || !openSet.Contains(node))
                {
                    node.gCost  = newCost;
                    node.hCost  = GetDistanceNode(node, endNode);
                    node.parent = currentNode;
                    if (!openSet.Contains(node))
                    {
                        openSet.Add(node);
                    }
                }
            }
        }
    }