コード例 #1
0
        private void SubmitInput()
        {
            var inputWord = _currentInputWord.ToString();

            _currentInputWord.Length = 0;

            if (_requiredDirectionWord.ContainsKey(inputWord))
            {
                GameController.Instance.PlayerHasMoved = true;
                MovePlayer(_requiredDirectionWord[inputWord]);
            }
            else if (_requiredAttackWord.ContainsKey(inputWord))
            {
                var player = ActorCache.Instance.Player;
                if (player == null)
                {
                    return;
                }

                var target = _requiredAttackWord[inputWord];

                var playerPos = player.Entity.GetComponent <GridPositionComponent>();
                var enemyPos  = target.GetComponent <GridPositionComponent>();

                var newAttackWord = GetWordNonConflicting(_attackDifficulty);
                var spellHint     = _entitySpellHints[enemyPos.Owner];
                spellHint.Initialize(enemyPos.Owner.GameObject.transform, newAttackWord);
                spellHint.SetIcon(SpellHint.IconType.Attack);

                _requiredAttackWord.Remove(inputWord);
                _requiredAttackWord.Add(newAttackWord, target);

                GameController.Instance.PlayerHasMoved = true;

                if (Vector2.Distance(playerPos.Position, enemyPos.Position) <= 1)
                {
                    _attackSystem.AttackMelee(player.Entity, target);
                }
                else
                {
                    _attackSystem.AttackRanged(player.Entity, target);
                }
            }
            else if (_requiredLootWord.ContainsKey(inputWord))
            {
                GameController.Instance.PlayerHasMoved = true;

                var chest = _requiredLootWord[inputWord];
                _itemSystem.ChestPickup(chest);
                chest.Open();

                _requiredLootWord.Remove(inputWord);
                var spellHint = _chestSpellHints[chest];
                _chestSpellHints.Remove(chest);

                spellHint.Disable();
            }
        }