Beispiel #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        collectable = collision.GetComponent <Collectable>();

        if (collectable)
        {
            collectable.Collect();
            OnCollected?.Invoke(collectable.value);
        }

        switch (collision.tag)
        {
        case "Danger":
            TakeDamage(25, collision);
            break;

        case "Respawn":
            respawnPoint = transform.position;
            break;

        case "JumpPad":
            GetComponent <Movement>().JumpUp(jumpPadJumpMultiplier);
            break;

        case "enemy":
            TakeDamage(20, collision);
            break;

        default:
            break;
        }
    }
Beispiel #2
0
    void OnTriggerEnter(Collider collider)
    {
        if (collider.transform.parent.tag == "Player")
        {
            return;
        }

        Collectable collectable = collider.transform.parent.GetComponent <Collectable> ();

        if (collectable != null)
        {
            collectable.Collect();
        }
        else
        {
            Destructable destructable = collider.transform.parent.GetComponent <Destructable> ();

            if (destructable != null)
            {
                destructable.Destruct();
            }
        }

        Destroy(gameObject);
    }
Beispiel #3
0
    protected void OnCollisionEnter2D(Collision2D collision)
    {
        Collectable collectable = collision.gameObject.GetComponent <Collectable>();

        if (collectable)
        {
            collectable.Collect();
        }
    }
Beispiel #4
0
    private void OnTriggerEnter(Collider other)
    {
        Collectable collectable = other.GetComponent <Collectable>();

        if (collectable)
        {
            collectable.Collect(gameObject);
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        Collectable collectable   = other.GetComponent <Collectable>();
        bool        isCollectable = collectable != null;

        if (isCollectable)
        {
            collectable.Collect();
        }
    }
    public void StartInteraction(GameObject root, GameObject other)
    {
        Collectable collectableItem = other.GetComponent <Collectable>();

        if (collectableItem != null)
        {
            collecter.Add();
            collectableItem.Collect();
        }
    }
Beispiel #7
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Collectable c = collision.GetComponent <Collectable>();

        if (c != null)
        {
            c.Collect();
            sound.PlayOneShot("Collect");
        }
    }
Beispiel #8
0
 private void TravelToCollectable()
 {
     if (LockedCollectable.PetCanCollect(Pet.GetOwner()) && !LockedCollectable.Disposed && LockedCollectable.Position != null && Pet.Position.DistanceTo(LockedCollectable.Position) <= 150)
     {
         CollectionStarted = DateTime.Now;
         LockedCollectable.Collect(Pet);
         LockedCollectable = null;
     }
     else
     {
         LockedCollectable = null;
     }
 }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.GetComponent <Collector>() == null)
        {
            return;
        }
        sceneDataSet.Add(uniqueID.ID);

        Debug.Log(uniqueID.ID + " removed and added to SceneDataSet");

        collectable.Collect(other.gameObject);
        Destroy(gameObject);
    }
Beispiel #10
0
    public IntString OnCatch = new IntString(); //questa è un'istanza di quell'evento personalizzato.

    void OnControllerColliderHit(ControllerColliderHit collision)
    {
        Collectable collo = collision.gameObject.GetComponent <Collectable>();

        if (collo == null)
        {
            return;
        }
        int hisscore = collo.Collect();

        score += hisscore;
        OnCatch.Invoke(hisscore, collo.gameObject.GetComponent <VectorCreature>().GetType().Name); //Sto chiamando l'evento personalizzato; tutti quelli che si sono registrati ricevono il segnale
    }
Beispiel #11
0
    private void OnTriggerEnter(Collider collider)
    {
        if (collider.transform.GetType().IsSubclassOf(typeof(Collectable)))
        {
            Collectable collectable = collider.GetComponent <Collectable>();
            collectable.Collect();
            GameManager.Instance.SetPullBack();
        }

        if (collider.transform.CompareTag("stick"))
        {
            GameManager.Instance.SetRotating();
        }
    }
Beispiel #12
0
    public void TriggerInteraction()
    {
        if (!CanTriggerInteraction())
        {
            return;
        }

        switch (sequenceType)
        {
        case SequenceType.SuddenDeath:
            BaseDeathTrigger baseDeathTrigger = GetComponent <BaseDeathTrigger>();
            baseDeathTrigger.TriggerDeath();
            break;

        case SequenceType.SuddenDeathSkill:
            SkillDeathTrigger skillDeathTrigger = GetComponent <SkillDeathTrigger>();
            skillDeathTrigger.TriggerDeath();
            break;

        case SequenceType.SuddenDeathCollectable:
            CollectableDeathTrigger collectableDeathTrigger = GetComponent <CollectableDeathTrigger>();
            collectableDeathTrigger.TriggerDeath();
            break;

        case SequenceType.Collectable:
            Collectable collectable = GetComponent <Collectable>();
            collectable.Collect();
            break;

        case SequenceType.AnimationThenDeath:
            break;

        case SequenceType.ChangeScene:
            ChangeLevel changleLevel = GetComponent <ChangeLevel>();
            changleLevel.LoadLevel();
            break;

        case SequenceType.OpenShop:
            Shop.Current.OpenShop();
            break;

        case SequenceType.CustomDeath:
            GetComponent <ICustomDeath>().Trigger();
            break;
        }
    }
Beispiel #13
0
    private void OnPointer(Vector2 cameraPosition, Vector2 worldPosition, RaycastHit2D[] raycast = null)
    {
        Collectable collectable = null;

        if (raycast != null)
        {
            foreach (RaycastHit2D hit in raycast)
            {
                if (hit.collider && hit.collider.tag == Tags.COLLECTABLE)
                {
                    collectable = hit.collider.gameObject.GetComponent <Collectable>();
                }
            }
        }

        if (collectable != null)
        {
            collectable.Collect();
        }
    }
Beispiel #14
0
    void OnTriggerStay(Collider other)
    {
        if (other.gameObject.tag == "Collectable")
        {
            Collectable collectable = other.gameObject.GetComponent <Collectable>();
            if (!(currentCompacity + collectable.weight > maxCompacity))
            {
                uiManager.interactText.text = "E to pickup";
                if (clickPickup)
                {
                    pickupTimer = 0;
                    clickPickup = false;

                    collectables.Add(collectable);
                    currentCompacity += collectable.weight;
                    currency         += collectable.value;
                    collectable.Collect();
                }
            }
            else
            {
                uiManager.interactText.text = "Not enough carry compacity";
            }
        }
        else if (other.gameObject.tag == "Shop")
        {
            if (clickPickup)
            {
                Debug.Log("called");
                pickupTimer = 0;
                clickPickup = false;
                CashIn();
            }
            uiManager.interactText.text = "E to deposit salvage";
        }
        else
        {
            uiManager.interactText.text = "";
        }
    }
Beispiel #15
0
    //Class is turned off when no TriggerCollision
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Collectable")
        {
            collectableRef = other.GetComponent <Collectable>();
            collectableRef.Collect(player);
        }
        if (other.tag == "Interactable")
        {
            interactableRef        = other.GetComponent <Interactable>();
            isTouchingInteractable = true;
        }

        else if (other.tag == "Enemy")
        {
            enemy_Base = other.GetComponent <Enemy_Base>();
            player.player_Actions.KnockedBack(enemy_Base.GetKnockbackAmount(), other.gameObject);
            player.TakeDamage(enemy_Base.GetCollsionDamage());
        }
        else if (other.tag == "NPC_Trader")
        {
            isTouchingTrader = true;
        }
    }
Beispiel #16
0
 protected void OnMouseDown()
 {
     _collectable.Collect();
 }
Beispiel #17
0
    void Update()
    {
        StatusText    statusText  = FindObjectOfType <StatusText>(); // TODO: UIHandler?
        PlayerHandler player      = FindObjectOfType <PlayerHandler>();
        GameObject    currentTile = player.GetCurrentTile();
        Inventory     inventory   = player.GetInventory();

        if (player.IsBusy())
        {
            return;              // Skip the rest if we are "busy"
        }
        if (!interactionCooldown)
        {
            status = "Overworld";
        }

        // Handle teleporting
        // TODO: Move
        if (currentTile && currentTile.tag == "Traversable")
        {
            status = "Press f to traverse!";

            if (Input.GetKey("f"))
            {
                Traversable traversable = currentTile.GetComponent <Traversable>();
                traversable.Traverse();
            }
        }

        // Handle collecting
        if (currentTile && !interactionCooldown && currentTile.tag == "Collectable")
        {
            status = "Press f to pick up!";

            if (Input.GetKey("f"))
            {
                Collectable collectable = currentTile.GetComponent <Collectable>();
                Item        drop        = collectable.Collect();

                if (drop != null)
                {
                    status = "Picked up item!";
                    inventory.addItem(drop);
                }
                else
                {
                    status = "You can't pick that up!";
                }
            }
        }

        // Handle attacking
        if (currentTile && !interactionCooldown && currentTile.tag == "Attackable")
        {
            status = "Press f to attack!";

            if (Input.GetKey("f"))
            {
                Attackable attackable = currentTile.GetComponent <Attackable>();
                Item       drop       = attackable.Attack();

                if (drop != null)
                {
                    status = "They dropped an item!";
                    inventory.addItem(drop);
                }
                else
                {
                    status = "Not dead yet!";
                }
            }
        }

        // Handle mining
        if (currentTile && !interactionCooldown && currentTile.tag == "Mineable")
        {
            status = "Press f to mine!";

            if (Input.GetKey("f"))
            {
                // Start cooldown timer
                StartCoroutine(InteractCooldown(0.2f));
                interactionCooldown = true;

                status = "Mining!";

                Mineable mineable = currentTile.GetComponent <Mineable>();
                Item     drop     = mineable.mine();

                if (drop != null)
                {
                    status = "Mining succeeded!";
                    inventory.addItem(drop);
                }
                else
                {
                    status = "Mining failed!";
                }
            }
        }

        // Handle interacting
        if (currentTile && !interactionCooldown && currentTile.tag == "Interactable")
        {
            status = "Press f to talk!";

            if (Input.GetKey("f"))
            {
                // Start cooldown timer
                StartCoroutine(InteractCooldown(1.0f));
                interactionCooldown = true;

                Interactable interactable = currentTile.GetComponent <Interactable>();

                if (interactable.Interact())
                {
                    status = "Talking... (Press Space to Continue)";
                }
                else
                {
                    status = "They don't seem to have much to say...";
                }
            }
        }

        // Update status
        statusText.SetStatusText(status);
    }