// Update is called once per frame
    void Update()
    {
        // Bit shift the index of the layer (8) to get a bit mask
        int layerMask = 1 << 8;

        RaycastHit hit;

        // Does the ray intersect any objects excluding the player layer
        if (Physics.Raycast(transform.position,
                            transform.TransformDirection(Vector3.forward), out hit,
                            Mathf.Infinity, layerMask))
        {
            Debug.DrawRay(transform.position,
                          transform.TransformDirection(Vector3.forward) * hit.distance,
                          Color.yellow);
            // Debug.Log("Did Hit");

            GameObject     foundsParent = hit.transform.parent.gameObject;
            BurnableObject hsc          = foundsParent.GetComponent <BurnableObject>();
            if (hsc != null)
            {
                hsc.OnFire();
            }
        }
        else
        {
            Debug.DrawRay(transform.position,
                          transform.TransformDirection(Vector3.forward) * 1000,
                          Color.white);
            // Debug.Log("Did not Hit");
        }
    }
    private void BurnTarget(GameObject target)
    {
        BurnableObject hsc = target.GetComponent <BurnableObject>();

        if (hsc != null)
        {
            hsc.OnFire();
        }
    }
 private void OnCollisionStay2D(Collision2D collision)
 {
     if (powered)
     {
         if (collision.gameObject.GetComponent <BurnableObject>())
         {
             BurnableObject bObject = collision.gameObject.GetComponent <BurnableObject>();
             bObject.Burn();
         }
     }
 }
Esempio n. 4
0
    private int CountBurntBushes()
    {
        int total = 0;

        foreach (GameObject tree in GameObject.FindGameObjectsWithTag("Bush"))
        {
            BurnableObject burnable = tree.GetComponent <BurnableObject>();
            if (burnable.IsBurned())
            {
                total++;
            }
        }
        return(total);
    }
Esempio n. 5
0
    private void HandlerGroup51()
    {
        levelManager.InstantiatePortal("WarriorTeleporter", new Vector2(-49.273f, -1.56f), new Vector2(-20.7f, 0.5f), true, 1);
        BurnableObject treeToBurn = GameObject.Find("TreeAltarHolder").GetComponent <BurnableObject>();

        treeToBurn.Burn();

        GameObject mageFeedback = GameObject.Find("ActivateNPCForGreen2");

        if (mageFeedback)
        {
            Destroy(mageFeedback);
        }
    }
Esempio n. 6
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        ExitPortal portal = collider.GetComponent <ExitPortal>();

        if (portal)
        {
            AudioController.instance.PlayPortalSound();
            GameController.instance.PortalToScene(portal.sceneToLoad);
        }

        BurnableObject burnable = collider.GetComponent <BurnableObject>();

        if (burnable)
        {
            burnable.TryBeBurnedBy(this);
        }
        ConsumableObject consumable = collider.GetComponent <ConsumableObject>();

        if (consumable)
        {
            consumable.TryBeConsumedBy(this);
        }
    }
Esempio n. 7
0
    protected virtual void OnTriggerEnter2D(Collider2D other)
    {
        if (other.GetComponent <DamagingObject>())
        {
            if (!levelManager.GetMage().ProtectedByShield(gameObject))
            {
                for (int i = 0; i < playerControllers.Length; i++)
                {
                    if (playerControllers[i] != null)
                    {
                        PlayerController playerToRelease = playerControllers[i];
                        playerControllers[i] = null;
                        playerToRelease.ResetTransform();
                        playerToRelease.TakeDamage(10, new Vector2(150f, 15f));
                        playerToRelease.parent = null;
                    }
                }
                Destroy(parasiteParticle.gameObject);
                Destroy(gameObject);
            }
        }

        if (other.GetComponent <DestroyableObject>())
        {
            if (levelManager.GetWarrior().IsWarriored(gameObject))
            {
                DestroyableObject destroyable = other.GetComponent <DestroyableObject>();
                destroyable.DestroyMe(true);
            }
            else
            {
                for (int i = 0; i < playerControllers.Length; i++)
                {
                    if (playerControllers[i] != null)
                    {
                        PlayerController playerToRelease = playerControllers[i];
                        playerControllers[i] = null;
                        playerToRelease.ResetTransform();
                        playerToRelease.TakeDamage(10, new Vector2(150f, 15f));
                        playerToRelease.parent = null;
                    }
                }
                Destroy(parasiteParticle.gameObject);
                Destroy(gameObject);
            }
        }

        if (other.GetComponent <BurnableObject>())
        {
            if (levelManager.GetWarrior().IsWarriored(gameObject))
            {
                BurnableObject burnable = other.GetComponent <BurnableObject>();
                burnable.Burn();
            }
            else
            {
                for (int i = 0; i < playerControllers.Length; i++)
                {
                    if (playerControllers[i] != null)
                    {
                        PlayerController playerToRelease = playerControllers[i];
                        playerControllers[i] = null;
                        playerToRelease.ResetTransform();
                        playerToRelease.TakeDamage(10, new Vector2(150f, 15f));
                        playerToRelease.parent = null;
                    }
                }
                Destroy(parasiteParticle.gameObject);
                Destroy(gameObject);
            }
        }

        if (other.GetComponent <KillingObject>() && other.GetComponent <KillingObject>().activated)
        {
            if (!other.GetComponent <DarkElectricity>())
            {
                if (levelManager.GetMage().ProtectedByShield(gameObject))
                {
                    for (int i = 0; i < playerControllers.Length; i++)
                    {
                        if (playerControllers[i] != null)
                        {
                            PlayerController playerSaved = playerControllers[i];
                            Physics2D.IgnoreCollision(playerSaved.GetComponent <BoxCollider2D>(), other.GetComponent <Collider2D>(), true);
                        }
                    }
                }

                else if (!levelManager.GetMage().ProtectedByShield(gameObject))
                {
                    for (int i = 0; i < playerControllers.Length; i++)
                    {
                        if (playerControllers[i] != null)
                        {
                            PlayerController playerToRelease = playerControllers[i];
                            playerControllers[i] = null;
                            playerToRelease.ResetTransform();
                            playerToRelease.parent = null;
                        }
                    }
                    Destroy(parasiteParticle.gameObject);
                    Destroy(gameObject);
                }
            }
            else if (other.GetComponent <DarkElectricity>())
            {
                if (levelManager.GetEngineer().IsElectrified(gameObject))
                {
                    for (int i = 0; i < playerControllers.Length; i++)
                    {
                        if (playerControllers[i] != null)
                        {
                            PlayerController playerSaved = playerControllers[i];
                            Physics2D.IgnoreCollision(playerSaved.GetComponent <BoxCollider2D>(), other.GetComponent <Collider2D>(), true);
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < playerControllers.Length; i++)
                    {
                        if (playerControllers[i] != null)
                        {
                            PlayerController playerToRelease = playerControllers[i];
                            playerControllers[i]   = null;
                            playerToRelease.parent = null;
                            playerToRelease.ResetTransform();
                        }
                    }
                    Destroy(parasiteParticle.gameObject);
                    Destroy(gameObject);
                }
            }
        }
    }
Esempio n. 8
0
    protected override void OnCollisionEnter2D(Collision2D other)
    {
        if (GameObjectIsPlayer(other.gameObject))
        {
            DealDamage(other.gameObject);
            DestroyMeAndParticles();
        }

        if (GameObjectIsEnemy(other.gameObject))
        {
            if (CheckIfImWarriored(gameObject))
            {
                KillEnemy(other.gameObject);
                DestroyMeAndParticles();
            }

            if (CheckIfImMaged())
            {
                GetThisEnemyMaged(other.gameObject);
                DestroyMeAndParticles();
            }

            DestroyMeAndParticles();
        }

        if (GameObjectIsDestroyable(other.gameObject))
        {
            if (CheckIfImWarriored(gameObject))
            {
                DestroyableObject destroyable = other.gameObject.GetComponent <DestroyableObject>();
                destroyable.DestroyMe(true);
                DestroyMeAndParticles();
            }

            DestroyMeAndParticles();
        }

        if (GameObjectIsDeactivableKillPlane(other.gameObject))
        {
            if (CheckIfImWarriored(gameObject))
            {
                KillingObject kObject = other.gameObject.GetComponent <KillingObject>();
                kObject.HitByPoweredDamaging();
                DestroyMeAndParticles();
            }

            if (CheckIfImMaged())
            {
                KillingObject kObject = other.gameObject.GetComponent <KillingObject>();
                kObject.HitByPoweredDamaging();
                DestroyMeAndParticles();
            }
        }

        if (GameObjectIsBurnable(other.gameObject))
        {
            if (CheckIfImWarriored(gameObject))
            {
                BurnableObject bObject = other.gameObject.GetComponent <BurnableObject>();
                bObject.Burn();
                DestroyMeAndParticles();
            }
            DestroyMeAndParticles();
        }
    }
    protected void BurnObject(GameObject burnableObject)
    {
        BurnableObject bObject = burnableObject.GetComponent <BurnableObject>();

        bObject.Burn();
    }