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); }
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); }
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); }
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(); }
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(); }