Beispiel #1
0
        public bool MoveCharacter(BattleEntities.Character characterBattle, Grid.Row destination)
        {
            if (characterBattle.Move(Grid, destination))
            {
                EventManager.CharacterMove(characterBattle, destination);
                return(true);
            }

            return(false);
        }
Beispiel #2
0
        public bool Move(Grid grid, Grid.Row destination)
        {
            List <Grid.Row> path = new List <Grid.Row>();

            if ((path = Dijkstra.GetBestPath(grid, m_row, destination, MovementPoints)) != null)
            {
                m_row.occuped = false;

                m_row             = destination;
                m_row.occuped     = true;
                m_movementPoints -= path.Count;
                return(true);
            }

            return(false);
        }
Beispiel #3
0
 public void StartBattle(Grid.Row row)
 {
     m_row       = row;
     m_isStarted = true;
 }
Beispiel #4
0
 public static void CharacterMove(BattleEntities.Character character, Grid.Row destination)
 {
     OnCharacterMove?.Invoke(character, destination);
 }
Beispiel #5
0
        //don't use bool with client (unity)
        public bool LaunchSpell(BattleEntities.Character characterBattle, BattleEntities.Spell spell, Grid.Row destination)
        {
            List <Grid.Row> range = Grid.GetAOERange(spell.EffectRange.GridRange, destination, characterBattle.Row);
            List <BattleEntities.Character> targets = new List <BattleEntities.Character>();


            if (!characterBattle.LaunchSpell(spell))
            {
                return(false);
            }

            EventManager.LaunchSpell(spell, range);

            for (int i = 0; i < range.Count; i++)
            {
                BattleEntities.Character character = null;
                if ((character = Characters.Find(x => x.Row == range[i])) != null)
                {
                    targets.Add(character);
                }
            }

            for (int i = 0; i < targets.Count; i++)
            {
                targets[i].HitDamages(spell);
                if (targets[i].IsDead)
                {
                    m_charactersDead.Add(m_characters.Find(x => x == targets[i]));
                    m_characters.Remove(targets[i]);

                    if (targets[i] == ActualCharacter)
                    {
                        NextCharacterTurn();
                    }
                }
            }

            if (PlayerLose(m_players[0]))
            {
                EndGame(m_players[1]);
            }

            else if (PlayerLose(m_players[1]))
            {
                EndGame(m_players[0]);
            }

            return(true);
        }