public scr_Interactable_Result Interact(GameObject trigger, scr_Stats.ObjectType itemInInventory)
 {
     return(new scr_Interactable_Result(
                scr_Stats.Interaction.Drag,
                true,
                draggable: this));
 }
Example #2
0
    public scr_Interactable_Result Interact(GameObject trigger, scr_Stats.ObjectType itemInInventory)
    {
        rotateTowardsDirection = scr_Tilemap.Get.GetDirectionFromTo(this.gameObject.transform.position, trigger.transform.position);
        rotateTowardsVector    = scr_Tilemap.Get.DirectionToVector(rotateTowardsDirection);
        timeToNextRandom       = _MaxRandomRotationTime;

        return(new scr_Interactable_Result(scr_Stats.Interaction.TalkToHuman, true));
    }
Example #3
0
    public scr_Interactable_Result Interact(GameObject trigger, scr_Stats.ObjectType itemInInventory)
    {
        scr_Interactable_Result result = new scr_Interactable_Result(scr_Stats.Interaction.TalkToHuman, false);

        if (locInteractCDCounter >= locInteractCD)
        {
            locInteractCDCounter = 0;
            Debug.Log(TextResponse);
            GenerateTalkBubble();
            //result.InteractionSuccessfull = true;
            result = new scr_Interactable_Result(scr_Stats.Interaction.TalkToHuman, true);
        }
        return(result);
    }
Example #4
0
    public scr_Interactable_Result Interact(GameObject trigger, scr_Stats.ObjectType itemInInventory)
    {
        on = !on;

        if (on)
        {
            changeColorOn.GetComponent <Renderer>().material.color = Color.green;
        }
        else
        {
            changeColorOn.GetComponent <Renderer>().material.color = Color.red;
        }

        return(new scr_Interactable_Result(scr_Stats.Interaction.ChangeSwitch, true));
    }
    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 void Animator_OnPickup(object sender)
 {
     if (pickup_SomethingInHand)
     {
         pickup_Object.transform.position = _PickupTransform.transform.position;
         pickup_Object.transform.SetParent(_PickupTransform);
         pickup_Object.GetComponent <BoxCollider>().enabled = false;
     }
     else
     {
         pickup_Object.transform.SetParent(null);
         pickup_Object.transform.position = scr_Tilemap.Get.GetNextTile(move_LookAtDirection, this.transform.position);
         pickup_Object.transform.rotation = Quaternion.identity;
         pickup_Object.GetComponent <BoxCollider>().enabled = true;
         pickup_Object     = null;
         pickup_ObjectType = scr_Stats.ObjectType.None;
     }
 }
    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);
    }
    public scr_Interactable_Result Interact(GameObject trigger, scr_Stats.ObjectType itemInInventory)
    {
        bool successfull = itemInInventory == scr_Stats.ObjectType.Axe && stats.Health > 0;

        return(new scr_Interactable_Result(scr_Stats.Interaction.ChopTree, successfull, damagable: this));
    }
Example #9
0
 public scr_Interactable_Result Interact(GameObject trigger, scr_Stats.ObjectType itemInInventory)
 {
     return(new scr_Interactable_Result(scr_Stats.Interaction.Pickup, true, scr_Stats.ObjectType.Axe));
 }