public scr_Interactable_Result( scr_Stats.Interaction interaction, bool interactionSuccessfull, scr_Stats.ObjectType pickupObjectType = scr_Stats.ObjectType.None, i_Draggable draggable = null, i_Damageable damagable = null) { this.Interaction = interaction; this.InteractionSuccessfull = interactionSuccessfull; this.PickupObjectType = pickupObjectType; this.Dragable = draggable; this.Damagable = damagable; Validate(); }
private scr_Stats.Interaction Interact() { scr_Stats.Interaction?firstInteraction = null; KeyValuePair <GameObject, i_Interactable>[] interactables = GetInteractable(); foreach (KeyValuePair <GameObject, i_Interactable> interactable in interactables) { scr_Interactable_Result result = interactable.Value.Interact(this.gameObject, pickup_ObjectType); if (!result.InteractionSuccessfull) { continue; } scr_Stats.Interaction interaction = result.Interaction; if (!firstInteraction.HasValue) { firstInteraction = interaction; } if (result.Dragable != null) { Drag(result.Dragable, interactable.Key); } if (result.PickupObjectType != scr_Stats.ObjectType.None && this.pickup_Object == null && pickup_ObjectType == scr_Stats.ObjectType.None) { pickup_Object = interactable.Key; pickup_ObjectType = result.PickupObjectType; pickup_SomethingInHand = true; animator.Pickup(); waitForAnimationFinished = true; } if (result.Damagable != null) { damage_ObjectToDamage = result.Damagable; switch (interaction) { case scr_Stats.Interaction.ChopTree: damage_DamageStrength = stats.ChopTreeStrength; break; } animator.Attack(); waitForAnimationFinished = true; } } if (!firstInteraction.HasValue && pickup_Object != null) { Vector3 position = scr_Tilemap.Get.GetNextTile(move_LookAtDirection, this.transform.position); if (scr_Tilemap.Get.IsTileFree(position, new Vector3(0.5f, 0.5f, 0.5f))) { pickup_SomethingInHand = false; animator.Pickup(); waitForAnimationFinished = true; } } return(firstInteraction.HasValue ? firstInteraction.Value : scr_Stats.Interaction.None); }