Ejemplo n.º 1
0
    public IEnumerator StartingGame()
    {
        StartingOverlayPanel.SetActive(true);

        // done on start because otherwise there would be problem with retained Entitas entities (solvable of course)
        GeneratingText.text += Environment.NewLine + "...";
        yield return(new WaitForSeconds(0.3f));

        if (Difficulty.value == 0)         // easy
        {
        }

        float enemyCountRate = Difficulty.value == 0 ? 0.9f : Difficulty.value == 1 ? 1f : 1.1f;

        _worldActorFiller.FillWithActors(enemyCountRate);

        yield return(new WaitForSeconds(0.3f));

        _tilemapGenerator.Clear();
        yield return(new WaitForSeconds(0.3f));

        _tilemapGenerator.Generate();

        yield return(new WaitForSeconds(0.1f));

        foreach (GameObject gameObjectToEnable in ToEnableWhenStarting)
        {
            gameObjectToEnable.SetActive(true);
            yield return(new WaitForSeconds(0.05f));            // without this objects may start in wrong order, causing data to be corrupted
        }

        StartingOverlayPanel.SetActive(false);
        _uiFacade.AddLogEntry("<color=#adf>Welcome!</color> \nHave fun working with Osnowa.");
        _uiFacade.AddLogEntry("Feel free to play around with the engine.");

        gameObject.SetActive(false);
    }
Ejemplo n.º 2
0
        public override IEnumerable <IActionEffect> Execute()
        {
            if (Entity.entityHolder.EntityHeld != Guid.Empty || ItemToPickUp.hasHeld)
            {
                throw new InvalidOperationException(
                          "Actor should not try to pick up if he's holding an entity or someone else is holding an entity");
            }

            Entity.entityHolder.EntityHeld = ItemToPickUp.id.Id;
            ItemToPickUp.ReplaceHeld(Entity.id.Id);

            _uiFacade.AddLogEntry($"<color=#aaa>You pick up {ItemToPickUp.view.Controller.Name}.</color>");

            IActionEffect effect = ActionEffectFactory
                                   .CreateLambdaEffect(viewController => viewController.HoldOnFront(ItemToPickUp), Entity.view.Controller);

            yield return(effect);
        }
Ejemplo n.º 3
0
        public override IEnumerable <IActionEffect> Execute()
        {
            if (Entity.entityHolder.EntityHeld == _itemToDrop.id.Id)
            {
                IActionEffect dropEffect = ActionEffectFactory
                                           .CreateLambdaEffect(actorBehaviour => actorBehaviour.DropHeldEntity(_itemToDrop), Entity.view.Controller);

                Entity.ReplaceEntityHolder(Guid.Empty);

                string itemName = _itemToDrop.view.Controller.Name;

                Position?newPosition = _firstPlaceInAreaFinder.FindForItem(Entity.position.Position);
                _itemToDrop.RemoveHeld();
                _itemToDrop.ReplacePosition(newPosition ?? Entity.position.Position);
                _itemToDrop.view.Controller.RefreshWorldPosition();
                _uiFacade.AddLogEntry($"<color=#aaa>You drop {itemName} on the ground.</color>");

                yield return(dropEffect);
            }
        }
Ejemplo n.º 4
0
        public void TriggerAggressionIfEligible(GameEntity target)
        {
            if (target.isPlayerControlled)
            {
                return;
            }

            try
            {
                // interrupting current activity
                if (target.hasActivity)
                {
                    IActivity activity = target.activity.Activity;
                    if (!(activity is AttackActivity))
                    {
                        target.RemoveActivity();
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message + ", stack trace: " + e.StackTrace);
                throw;
            }

            if (target.isAggressive)
            {
                return;
            }

            target.isAggressive = true;
            _uiFacade.AddLogEntry($"{target.view.Controller.Name} becomes aggressive!");
            _positionEffectPresenter.ShowPositionEffect(target.position.Position, "!", Color.red);
            if (target.hasActivity)
            {
                target.RemoveActivity();
            }
        }
Ejemplo n.º 5
0
        public void HandleDeath(GameEntity entity)
        {
            entity.isMarkedForDestruction = true;

            if (_contextManager.Current.VisibleEntities.Contains(entity.view.Controller))
            {
                string name = entity.view.Controller.Name == "Player" ? "You" : entity.view.Controller.Name;
                string s    = name == "You" ? "" : "s";
                _uiFacade.AddLogEntry(name + $" die{s}!");
            }

            EntityRecipee toSpawn = null;

            if (toSpawn != null)
            {
                _viewCreator.SpawnEntity(toSpawn, entity.position.Position);
            }

            if (entity.isPlayerControlled)
            {
                _uiFacade.HandlePlayerDeath("You die...");
            }
        }