Пример #1
0
        public override IEnumerable <IActionEffect> Execute()
        {
            ++_gameContext.CurrentDungeonIndex;
            if (_gameContext.CurrentDungeonIndex < 6)
            {
                GameObject.Find("PrisonLevelIndicator").GetComponent <Text>().text = "Prison level: " + -(5 - _gameContext.CurrentDungeonIndex);
            }
            if (_gameContext.CurrentDungeonIndex >= _gameContext.Dungeons.Count)
            {
                _textEffectPresenter.ShowTextEffect(ActorData.LogicalPosition, "Sniff! It's... It's fresh air!", Color.yellow);
                _gameContext.PlayerActor.ActorData.LogicalPosition =
                    new Vector2Int(6, -41);                     // dawno tego nie robiłem... niesamowite uczucie
                //new Vector2Int(5, -65); // this leads close to Farwis. dawno tego nie robiłem... niesamowite uczucie

                _gameContext.PlayerActor.ActorData.VisionRayLength = 8; _gameContext.VisiblePositions = new HashSet <Vector2Int>();
                IEnumerable <ActorData> enemiesAround =
                    _entityDetector.DetectActors(_gameContext.PlayerActor.ActorData.LogicalPosition, 20)
                    .Where(a => a.Team == Team.Beasts);
                foreach (var actorData in enemiesAround)
                {
                    actorData.VisionRayLength = 8;
                }
                //this still breaks the field of view!
            }
            else
            {
                Dungeon    nextDungeon          = _gameContext.Dungeons[_gameContext.CurrentDungeonIndex];
                BoundsInt  furthestRoomToStairs = FurthestRoomToStairsResolver.GetFurthestRoomToStairs(nextDungeon);
                Vector2Int startingPosition     = new Vector2Int((int)furthestRoomToStairs.center.x, (int)furthestRoomToStairs.center.y);
                _gameContext.PlayerActor.ActorData.LogicalPosition = startingPosition;
                TileBase stairsDownTile = Resources.Load <TileBase>("Tiles/Environment/Stairs_down");
                _gameContext.EnvironmentTilemap.SetTile(startingPosition.ToVector3Int(), stairsDownTile);
                _gameContext.WallsTilemap.SetTile(startingPosition.ToVector3Int(), null);
                IEnumerable <ActorData> actorAround = _entityDetector.DetectActors(startingPosition, 3);
                foreach (var actorData in actorAround)
                {
                    _entityRemover.CleanSceneAndGameContextAfterDeath(actorData);
                    Debug.Log("Removing an actor, because he was too close: " + actorData.ActorType);
                }
            }

            Action action = () =>
            {
                _gameContext.PlayerActor.RefreshWorldPosition();
            };

            yield return(new LambdaEffect(action));
        }
Пример #2
0
        public void HandleDeath(ActorData actorData)
        {
            ItemDefinition weaponToSpawn = actorData.WeaponWeld;

            _entityRemover.CleanSceneAndGameContextAfterDeath(actorData);
            //_entitySpawner.SpawnItem(_gameConfig.ItemConfig.Definitions.FirstOrDefault(i => i.ItemType == ItemType.PotionOfFriend), actorData.LogicalPosition);
            if (actorData.ActorType == ActorType.Basher)
            {
                _gameContext.BasherDead = true;
            }
            if (actorData.IsBoss && _gameContext.CurrentDungeonIndex == 0)
            {
                _entitySpawner.SpawnItem(_gameConfig.ItemConfig.Definitions.First(i => i.ItemType == ItemType.PotionOfBuddy), actorData.LogicalPosition);
            }
            else if (actorData.ActorType != ActorType.Buddy && actorData.ActorType != ActorType.Friend && _rng.Check(0.42f))
            {
                ItemDefinition[] itemPool = actorData.XpGiven < 15
                                        ? _gameConfig.ItemConfig.ItemPoolWeak
                                        : actorData.XpGiven < 26 ? _gameConfig.ItemConfig.ItemPoolMedium : _gameConfig.ItemConfig.ItemPoolStrong;
                ItemDefinition item = _rng.Choice(itemPool);

                _entitySpawner.SpawnItem(item, actorData.LogicalPosition);
            }

            if (!weaponToSpawn.WeaponDefinition.IsBodyPart && actorData.ActorType != ActorType.Buddy && actorData.ActorType != ActorType.Friend)
            {
                _entitySpawner.SpawnItem(weaponToSpawn, actorData.LogicalPosition);
            }

            if (actorData.ControlledByPlayer)
            {
                _uiConfig.RestartButton.gameObject.SetActive(true);
                var postMortem = "You died at level " + actorData.Level + " after surviving " + actorData.RoundsCount +
                                 " rounds. \r\nIf you have trouble playing, check out \"Combat help\" to the right. Restart?";
                _uiConfig.RestartButton.transform.GetComponentInChildren <Text>().text = postMortem;
            }
        }