示例#1
0
    void Update()
    {
        Player.Update();

        if (Input.GetKeyDown(KeyCode.F))
        {
            var thing = ThingsBehaviour.Instance.SearchNearly(PlayerGameObject);
            if (thing != null)
            {
                var gameObj      = ThingsBehaviour.Instance.Things[thing];
                var distance     = Utils.Distance(gameObj, PlayerGameObject);
                var skillContext = new SkillContext(Player, distance, null);

                if (!_useThingSkill.ReadyToUse(skillContext))
                {
                    return;
                }

                _usableThing         = thing;
                _useThingSkill.Thing = thing;

                Player.Use(_useThingSkill, skillContext);
            }
        }
    }
示例#2
0
    private void OnButtonClick(int cellPos)
    {
        var skillContext = new SkillContext(_player, 0, null);

        if (!_useThingSkill.ReadyToUse(skillContext))
        {
            return;
        }

        var bagCell = _bag.Cells.Skip(cellPos).FirstOrDefault();

        if (bagCell != null)
        {
            var thing = bagCell.Item;
            if (thing is IStack stack)
            {
                thing = stack.Prototype.CreateInstance();
            }

            _lastClickedCell          = bagCell;
            _useThingSkill.OnEndCast += OnUseThingEndCast;

            _useThingSkill.Thing = thing;
            _player.Use(_useThingSkill, skillContext);
        }
    }