コード例 #1
0
        public BattleUnit FindUnitToAttack(Vector2 pos, uint team_index)
        {
            BattleUnit rel_unit         = null;
            float      min_hp           = float.MaxValue;
            var        neighbour_points = Pathfinder.GetPointNeighbours(pos, with_diagonal: true);

            foreach (var point in neighbour_points)
            {
                var tile_unit = GetTileUnit(point);
                if (tile_unit == null || tile_unit.GetTeamIndex() == team_index)
                {
                    continue;
                }

                var hp = tile_unit.GetHP();
                if (hp < min_hp)
                {
                    min_hp   = hp;
                    rel_unit = tile_unit;
                }
            }

            return(rel_unit);
        }
コード例 #2
0
 public void SetTargetUnit(BattleUnit unit) => target_unit     = unit;
コード例 #3
0
 public void ResetTargetUnit() => target_unit         = null;
コード例 #4
0
        public void GiveDamage(BattleUnit enemy)
        {
            var damage = UnityEngine.Random.Range(DAMAGE_MIN, DAMAGE_MAX);

            enemy.GetDamage(damage);
        }