Exemplo n.º 1
0
        public AStarGridPathfinding.Result FindPath(StageCell startCell, StageCell goalCell)
        {
            var start = _aStarNodes[startCell.Coord.x, startCell.Coord.y];
            var goal  = _aStarNodes[goalCell.Coord.x, goalCell.Coord.y];

            return(_pathfinding.FindPath(_aStarNodes, start, goal));
        }
Exemplo n.º 2
0
        public void SpawnWall(StageCell cell)
        {
            var unit = Unit.Spawn(
                Constants.UnitType.StaticObject,
                _wallPrefab, transform, cell, Constants.CardinalDirection.N);

            StaticObjects.Add(unit);
        }
Exemplo n.º 3
0
 public void SpawnPlayer(StageCell cell)
 {
     Player = Unit.Spawn(
         Constants.UnitType.Player,
         _playerUnitPrefab,
         transform, cell, Constants.CardinalDirection.S);
     Player.UnitStatus.MaxHealth = 3;
     Player.UnitStatus.Health    = 3;
     Player.OnUnitDied          += OnUnitDied;
     Player.SetHealthBar(_playerHealthBar);
     Player.UpdateStatusView();
 }
Exemplo n.º 4
0
        public void SpawnEnemy(StageCell cell, Constants.CardinalDirection direction)
        {
            var unit = Unit.Spawn(
                Constants.UnitType.Enemy,
                _enemyUnitPrefab,
                transform, cell, direction);

            unit.UnitStatus.MaxHealth = 1;
            unit.UnitStatus.Health    = 1;
            unit.OnUnitDied          += OnUnitDied;
            unit.UpdateStatusView();
            Enemies.Add(unit.Id, unit);
        }
Exemplo n.º 5
0
        public IEnumerator Move(StageCell destinationCell)
        {
            // 移動前のセルから参照を外して移動先セルに参照をセットする
            Cell.Unit            = null;
            Cell                 = null;
            destinationCell.Unit = this;

            StartCoroutine(_unitAnimation.Rotate(destinationCell.Tile.transform, 0.4f));

            var speed = UnitType == Constants.UnitType.Player ? 3.5f : 6f;

            yield return(_unitAnimation.MoveOverSpeed(destinationCell.Tile.transform.position, speed));

            yield return(new WaitForSeconds(0.1f));

            Cell = destinationCell;
        }
Exemplo n.º 6
0
        public static T Spawn <T>(
            Constants.UnitType unitType,
            T prefab,
            Transform parent,
            StageCell cell,
            Constants.CardinalDirection direction) where T : Unit
        {
            var unit = Instantiate(prefab, cell.Tile.transform.position, prefab.transform.rotation);

            unit.transform.parent = parent;
            unit.Id   = _latestId++;
            unit.Cell = cell;
            unit.SetDirection(direction);
            unit.UnitType   = unitType;
            unit.UnitStatus = new UnitStatus();
            cell.Unit       = unit;

            return(unit);
        }
Exemplo n.º 7
0
 public AStarGridPathfinding.Result FindPath(StageCell start, StageCell goal)
 {
     return(_pathfinding.FindPath(start, goal));
 }