Пример #1
0
        private void ShowEquipMenu()
        {
            if (_selectedRow < 0 || _selectedRow >= Inventory.SlotNames.Length)
            {
                return;
            }

            if (_controller.Inventory.Slots[_selectedRow].Cursed)
            {
                return; // You can't change items in a cursed slot. Period.
            }
            _controller.Inventory.Slots[_selectedRow].NewItems = false;

            var list = new List <Entity>();

            list.AddRange(_controller.Inventory.Items.Where(e => Inventory.CanEquipInSlot(_selectedRow, e)));
            list.Add(null);

            var o = new OptionWidget($"Wield {Inventory.SlotNames[_selectedRow].name}", list, i => {
                if (_controller.Inventory.Equip(i, _selectedRow))
                {
                    _controller.EndTurn();
                }

                Dirty = true;
            });

            _window.PopupStack.Push(o);
        }
Пример #2
0
    void OnMouseUp()
    {
        // Don't allow clicks until it is your turn
        if (_turnController.PlayerTurn != PlayerNumber)
        {
            return;
        }

        // Don't allow clicks until the turn starts
        if (!_dieRoller.DiceRolled)
        {
            return;
        }



        for (int i = 0; i < _dieRoller.CurrentRoll; i++)
        {
            if (_currentTile == null)
            {
                _currentTile = StartingTile;
            }
            else
            {
                _currentTile = _currentTile.NextTileForPlayer(PlayerNumber);
            }

            if (_currentTile == null)
            {
                // TODO: Move stone off board
                return;
            }
        }

        Debug.Log(_currentTile.transform.position);
        transform.position = _currentTile.transform.position;

        // For testing, end the turn now
        _turnController.EndTurn();
    }
Пример #3
0
    public void RollDice()
    {
        if (_diceRolled)
        {
            return;
        }

        _currentRoll = 0;

        // The DieRoller has four child sprite elements for the four dice being rolled
        // Here we iterate over those sprites and set them for the new die roll
        for (var i = 0; i < 4; i++)
        {
            // Assign dieValue either 0 or 1
            var dieValue = Random.Range(0, 2);

            _currentRoll += dieValue;

            // Get the appropriate set of sprites based on the die roll
            var sprites = (dieValue == 1) ? DieValueOneSprites : DieValueZeroSprites;

            // Get the image component for the die we're currently rolling
            var image = transform.GetChild(i).GetComponent <Image>();

            // Pick a sprite at random from the appropriate set, and set the image to that sprite
            image.sprite = sprites[Random.Range(0, 3)];

            // Before you roll, the sprites are silhouetted in black
            // To be able to see the sprite, set it's color to white
            image.color = Color.white;
        }

        _diceRolled = true;

        // If they rolled a zero, end the turn early
        if (_currentRoll == 0)
        {
            _turnController.EndTurn();
        }
    }
Пример #4
0
 public override void OnTurnStart()
 {
     turnController.EndTurn();
 }
Пример #5
0
        public void OnKeyPress(char keyCode, EventFlags flags)
        {
            bool didTurn = false;

            switch (keyCode)
            {
            case 'a':     // Todo: Map actions
            {
                // TODO: Reserved for interactin with the map. Open doors, pray at altars, etc.
            }
            break;

            case 'c':
            {
                // TODO: Reserved for casting spells

                // Temporary: Heal spell
                var spell = new Spell(6, new IEffect[] { new ApplyStatusEffect {
                                                             UseOn  = EntityTarget.Self,
                                                             Effect = new StatusEffect
                                                             {
                                                                 TickEffect    = new IEffect[] { new HealEffect(5, 0, EntityTarget.Self) },
                                                                 FinalEffect   = new IEffect[] { new MapRevealEffect(MapRevealEffect.RevealMethod.Terrain, 10) },
                                                                 RunsToExecute = 10,
                                                                 RepeatTurns   = 2,
                                                                 Components    = new System.Collections.Generic.List <ECM.IComponent> {
                                                                     new Armor(20, ESlotType.Gloves)
                                                                 }
                                                             }
                                                         } });;

                if (spell.Cast(_controller.Player, _controller.Player))
                {
                    _controller.EndTurn();
                }
            }
            break;

            case 'd':     // Drop Item
            {
                var inv = _controller.Player.GetOne <Inventory>();
                var o   = new OptionWidget($"Drop Item", inv.Items, i => {
                        if (inv.Remove(i))
                        {
                            i.SetLevel(_controller.Player.Level, _controller.Player.Pos);
                            _controller.EndTurn();
                        }
                    });
                _window.PopupStack.Push(o);
            }
            break;

            case 'e':     // Use item
            {
                var l = _controller.Player.GetOne <Inventory>().Items.Where(i => i.EntityFlags.HasFlag(EEntityFlag.Consumable)).ToList();
                var o = new OptionWidget($"Consume", l, i => {
                        if (Eventing.On(new ConsumeEvent(_controller.Player, i)))
                        {
                            _controller.EndTurn();
                        }
                    });
                _window.PopupStack.Push(o);
            }
            break;

            case 'f':     // Fire ranged weapon
            {
                var item  = _controller.Player.GetOne <Inventory>()?.Slots[Inventory.SLOT_RANGED].Item;
                var enemy = _controller.SelectedTarget;

                if (item != null && enemy != null)
                {
                    // TODO: Fix
                    //if (Eventing.On(new AttackEvent(_controller.Player, item, enemy, Combat.EAttackMove.Projectile)))
                    //    _controller.EndTurn();
                }
            }
            break;

            case 'g':
            {
                var pos = _controller.Player.Pos;
                foreach (var i in _controller.Level.GetEntities(pos).ToArray())
                {
                    if (i.EntityFlags.HasFlag(EEntityFlag.Pickable))
                    {
                        i.SetLevel(null, Vec.Zero);
                        _controller.Player.GetOne <Inventory>().Add(i);
                        didTurn = true;
                    }
                }
            }
            break;

            case 's':
            {
                // TODO: Reserved for searching
            }
            break;

            case 't':
            {
                var l = _controller.Player.GetOne <Inventory>().Items.Where(i => i.EntityFlags.HasFlag(EEntityFlag.Throwable)).ToList();

                /* TODO: Reserved for throwing
                 * var o = new OptionWidget($"Throw", l, i => {
                 *
                 * });
                 * _window.PopupStack.Push(o);
                 */
            }
            break;

            case 'w':
            {
                var o = new InventoryWidget(_controller, _window);
                _window.PopupStack.Push(o);
            }
            break;

            case 'z':
            {
                // TODO: Reserved for zapping wands
            }
            break;

            case '>':
            {
                foreach (var entity in _controller.Level.GetEntities(_controller.Player.Pos))
                {
                    if (_controller.Player == entity)
                    {
                        continue;
                    }

                    if (Eventing.On(new DownEvent(_controller.Player, entity)))
                    {
                        didTurn = true;
                        break;
                    }
                }
            }
            break;

            case (char)9:
            {
                var id = _controller.VisibleEnemies.IndexOf(_controller.SelectedTarget);
                id++;
                var newTarget = (id < _controller.VisibleEnemies.Count) ? _controller.VisibleEnemies[id] : null;
                _controller.SelectedTarget = newTarget;
                break;
            }

#if WIZTOOLS
            case '\\':     // Well 'w' will be used for wield/wear
            {
                var o = new OptionWidget($"Wizard tools", WizTools.Tools.Items, i => {
                        Eventing.On(new CastEvent(_controller.Player, i));
                    });
                _window.PopupStack.Push(o);
            }
            break;
#endif
            default:
                break;
            }


            if (didTurn)
            {
                _controller.EndTurn();
            }
        }
Пример #6
0
 public bool Execute(TurnController turnController)
 {
     turnController.EndTurn();
     return(true);
 }
Пример #7
0
 public void EndTurn()
 {
     OnTurnEnd();
     controller.EndTurn();
 }