コード例 #1
0
        public override bool CanUse(Player player, InteractionObject target)
        {
            if (target.objectType != ObjectType.Stump)
            {
                return(false);
            }
            TreeStump treeStump = target.GetComponent <TreeStump>();

            return(treeStump != null && player.Stamina >= treeStump.staminaCost);
        }
コード例 #2
0
        public override void UseTool(Player player, InteractionObject target, GameObject toolObject)
        {
            if (!CanUse(player, target))
            {
                return;
            }
            toolObject.GetComponent <Animator>().SetTrigger("Use");
            TreeStump treeStump = target.GetComponent <TreeStump>();

            player.Stamina -= treeStump.staminaCost;
            treeStump.health--;
            if (treeStump.health <= 0)
            {
                ScoreManager.Instance.wood += treeStump.woodYield;
                Destroy(target.gameObject);
            }
        }