Exemple #1
0
        /// <summary>
        ///   Adds enemies as children to the room, and adds them to the enemies list.
        /// </summary>
        private void AddEnemies()
        {
            var possibleEnemyPositions = NodeService.GetChildrenOfType <Position2D>(GetNode("PossibleEnemyPositions"));
            var enemyPositions         = ListService.SelectNRandom(possibleEnemyPositions, 3);

            foreach (var enemyPosition in enemyPositions)
            {
                var skeleton = ActorFactory.CreateSkeleton();
                _enemies.AddChild(skeleton);
                skeleton.Position = enemyPosition.Position;
            }
        }
Exemple #2
0
        /// <summary>
        ///   Adds doors as children to the room, and adds them to the doors list.
        /// </summary>
        private void AddDoors()
        {
            var possibleDoorPositions = NodeService.GetChildrenOfType <Position2D>(GetNode("PossibleDoorPositions"));
            var doorPositions         = ListService.SelectNRandom(possibleDoorPositions, 3);

            foreach (var doorPosition in doorPositions)
            {
                var door = NodeService.InstanceNotNull <Door>("res://Scenes/World/Door.tscn");
                _doors.Add(door);
                AddChild(door);

                var tileCoordinate = WorldToMap(doorPosition.GlobalPosition);
                var instancePos    = MapToWorld(tileCoordinate);
                int tileWidth      = (int)CellSize.x;
                instancePos.x      += tileWidth / 2;
                instancePos.y      += tileWidth / 2;
                door.GlobalPosition = instancePos;
            }
        }
Exemple #3
0
 public IEnumerable <AbstractEnemy> GetEnemies()
 {
     return(NodeService.GetChildrenOfType <AbstractEnemy>(_enemies));
 }