示例#1
0
        private void ToPlant(Collider2D collision)
        {
            PlantSpotComponent plantSpotComponent = collision.gameObject.GetComponent <PlantSpotComponent>();

            if (plantSpotComponent == null)
            {
                return;
            }

            if (plantSpotComponent.GetInstanceID() != _interactableInstanceId)
            {
                return;
            }

            ActionSlotComponent selectedActionSlot = _uiManager.GetSelectedActionSlot();

            if (!plantSpotComponent.CanAcceptNewSeed())
            {
                return;
            }
            if (!selectedActionSlot.ItemCanBeUsedToPlant())
            {
                return;
            }

            _isPlanting = true;

            _animatorVariables.PlantSpotComponent = plantSpotComponent;
            _animatorVariables.SelectedActionSlot = selectedActionSlot;
            _animator.ResetTrigger(_animatorVariables.PlantSeed);
            _animator.SetTrigger(_animatorVariables.PlantSeed);
        }
示例#2
0
        private PlantSpotComponent HarvestPlnantValidatios(Collider2D collision)
        {
            PlantSpotComponent plantSpotComponent = collision.gameObject.GetComponent <PlantSpotComponent>();

            if (plantSpotComponent == null)
            {
                return(null);
            }
            if (plantSpotComponent.GetInstanceID() != _interactableInstanceId)
            {
                return(null);
            }
            if (!plantSpotComponent.IsReadyToHarvest())
            {
                return(null);
            }

            return(plantSpotComponent);
        }
示例#3
0
        private void EatFlower(Collider2D collision)
        {
            PlantSpotComponent plantSpotComponent = this.HarvestPlnantValidatios(collision);

            if (plantSpotComponent == null)
            {
                return;
            }

            if (_stomachComponent.StomachCantAcceptNewFood())
            {
                Debug.LogError("Player stomach Is Full while tryng to eat a flower!");
                this.RemoveInteractableState();
                return;
            }

            _isEating = true;
            _animatorVariables.PlantSpotComponent = plantSpotComponent;
            _animator.SetTrigger(_animatorVariables.Eat);
        }
示例#4
0
        private void ToTakeSeed(Collider2D collision)
        {
            PlantSpotComponent plantSpotComponent = this.HarvestPlnantValidatios(collision);

            if (plantSpotComponent == null)
            {
                return;
            }

            if (_inventoryComponent.InventoryIsFull())
            {
                return;
            }

            ItemDTO seeds = plantSpotComponent.TakeSeeds();

            _inventoryComponent.AddItem(seeds);
            plantSpotComponent.ResetPlantSpot();
            this.RemoveInteractableState();
        }
示例#5
0
        private void TakeFlower(Collider2D collision)
        {
            PlantSpotComponent plantSpotComponent = this.HarvestPlnantValidatios(collision);

            if (plantSpotComponent == null)
            {
                return;
            }

            if (_inventoryComponent.InventoryIsFull())
            {
                Debug.LogError("Inventory Is Full while tryng to harverst seeds!");
                return;
            }

            this.GetComponent <AudioComponent>().PlayAudio("harvest");

            ItemDTO flower = plantSpotComponent.TakeFlower();

            _inventoryComponent.AddItem(flower);
            plantSpotComponent.ResetPlantSpot();
            this.RemoveInteractableState();
        }