Esempio n. 1
0
    void OnCollisionEnter(Collision other)
    {
        DirtStats  otherDirtValues  = other.gameObject.GetComponent <DirtStats>();
        CloudStats otherCloudValues = other.gameObject.GetComponent <CloudStats>();
        StoneStats otherStoneValues = other.gameObject.GetComponent <StoneStats>();

        if (RaycastScript.isThrown == true && gameObject.tag == "PickedUpObject")
        {
            if (other.gameObject.tag == "Dirt")
            {
                otherDirtValues.dirtHP -= cloudATK;

                gameObject.tag         = "Cloud";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Stone")
            {
                otherStoneValues.stoneHP -= cloudATK;

                gameObject.tag         = "Cloud";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Cloud")
            {
                otherCloudValues.cloudHP -= cloudATK;

                gameObject.tag         = "Cloud";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Player")
            {
                gameObject.tag         = "Cloud";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Player2")
            {
                gameObject.tag         = "Cloud";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Player3")
            {
                gameObject.tag         = "Cloud";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Player4")
            {
                gameObject.tag         = "Cloud";
                RaycastScript.isThrown = false;
            }
        }
    }
Esempio n. 2
0
    void OnCollisionEnter2D(Collision2D other)
    {
        DirtStats  otherDirtValues  = other.gameObject.GetComponent <DirtStats>();
        CloudStats otherCloudValues = other.gameObject.GetComponent <CloudStats>();
        StoneStats otherStoneValues = other.gameObject.GetComponent <StoneStats>();

        if (gameObject.tag == "PickedUpObject")
        {
            gameObject.GetComponent <BarrelStats>().barrelHP -= 2;
        }
    }
Esempio n. 3
0
    void OnCollisionEnter2D(Collision2D other)
    {
        DirtStats   otherDirtValues   = other.gameObject.GetComponent <DirtStats>();
        CloudStats  otherCloudValues  = other.gameObject.GetComponent <CloudStats>();
        StoneStats  otherStoneValues  = other.gameObject.GetComponent <StoneStats>();
        TreeStats   otherTreeValues   = other.gameObject.GetComponent <TreeStats>();
        PlayerStats otherPlayerValues = other.gameObject.GetComponent <PlayerStats>();
        BarrelStats otherBarrelValues = other.gameObject.GetComponent <BarrelStats>();

        if (gameObject.tag == "PickedUpObject")
        {
            particleManager.SpawnBigSpark(this.transform.position);

            if (other.gameObject.tag == "Dirt")
            {
                otherDirtValues.dirtHP -= stoneATK;

                gameObject.tag         = "Stone";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Stone")
            {
                otherStoneValues.stoneHP -= stoneATK;

                gameObject.tag         = "Stone";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Cloud")
            {
                otherCloudValues.cloudHP -= stoneATK;

                gameObject.tag         = "Stone";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Tree")
            {
                otherTreeValues.treeHP -= stoneATK;

                gameObject.tag         = "Stone";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Wood")
            {
                otherTreeValues.treeHP -= stoneATK;

                gameObject.tag         = "Stone";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Barrel")
            {
                otherBarrelValues.barrelHP -= stoneATK;

                gameObject.tag         = "Stone";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Player")
            {
                otherPlayerValues.TakeDamage(stoneATK);

                gameObject.tag         = "Stone";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Player2")
            {
                otherPlayerValues.TakeDamage(stoneATK);

                gameObject.tag         = "Stone";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Player3")
            {
                otherPlayerValues.TakeDamage(stoneATK);

                gameObject.tag         = "Stone";
                RaycastScript.isThrown = false;
            }

            if (other.gameObject.tag == "Player4")
            {
                otherPlayerValues.TakeDamage(stoneATK);

                gameObject.tag         = "Stone";
                RaycastScript.isThrown = false;
            }
        }
    }
Esempio n. 4
0
    void OnTriggerEnter2D(Collider2D col)
    {
        Rigidbody2D colRigidbody      = col.gameObject.GetComponent <Rigidbody2D>();
        DirtStats   otherDirtValues   = col.gameObject.GetComponent <DirtStats>();
        CloudStats  otherCloudValues  = col.gameObject.GetComponent <CloudStats>();
        StoneStats  otherStoneValues  = col.gameObject.GetComponent <StoneStats>();
        TreeStats   otherTreeValues   = col.gameObject.GetComponent <TreeStats>();
        PlayerStats otherPlayerValues = col.gameObject.GetComponent <PlayerStats>();
        BarrelStats otherBarrelValues = col.gameObject.GetComponent <BarrelStats>();

        if (exploded == true)
        {
            if (colRigidbody != null)
            {
                Vector2 target = col.gameObject.transform.position;
                Vector2 bomb   = gameObject.transform.position;

                Vector2 direction = 200f * (target - bomb);

                colRigidbody.AddForce(direction);

                particleManager.SpawnExplosion(this.transform.position);
            }

            if (col.gameObject.tag == "Dirt")
            {
                otherDirtValues.dirtHP -= barrelATK;
            }

            if (col.gameObject.tag == "Stone")
            {
                otherStoneValues.stoneHP -= barrelATK;
            }

            if (col.gameObject.tag == "Cloud")
            {
                otherCloudValues.cloudHP -= barrelATK;
            }

            if (col.gameObject.tag == "Tree")
            {
                otherTreeValues.treeHP -= barrelATK;
            }

            if (col.gameObject.tag == "Barrel")
            {
                otherBarrelValues.barrelHP -= barrelATK;
            }

            if (col.gameObject.tag == "Player")
            {
                otherPlayerValues.TakeDamage(barrelATK);
            }

            if (col.gameObject.tag == "Player2")
            {
                otherPlayerValues.TakeDamage(barrelATK);
            }

            if (col.gameObject.tag == "Player3")
            {
                otherPlayerValues.TakeDamage(barrelATK);
            }

            if (col.gameObject.tag == "Player4")
            {
                otherPlayerValues.TakeDamage(barrelATK);
            }
        }
    }