Exemplo n.º 1
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        //AcidDamage(collision.gameObject);
        GameObject go = collision.gameObject;

        if (go.tag == "Player")
        {
            ExplosionManager.BloodSplatter(go.transform.position, 2, 90);

            PlayerController playerController = GameManager.Instance.playerController;
            Vector2          v = CommonUtils.NormalVector(transform.position, playerController.transform.position);
            playerController.Damage(1, v, 20);
            //playerController.Damage(1);

            //Fungus.Flowchart.BroadcastFungusMessage(message);
        }
        else
        {
            DieFromAcid die = go.GetComponent <DieFromAcid>();
            if (die != null)
            {
                die.Die();
            }
        }
    }
Exemplo n.º 2
0
    public static void SeverTentacle(Tentacle tentacle)
    {
        int severPoint = (int)Mathf.Ceil(tentacle.segments * Random.Range(0.2f, 0.5f));

        Tentacle baseHalf = Ungenerated();

        CopyTentSubSegments(tentacle, baseHalf, 0, severPoint);
        baseHalf.AttachBase(tentacle.connectBody);
        Transform endPoint = baseHalf.transform.Find("EndPoint");

        MakeEndDangling(endPoint);
        SpringJoint2D endSpringJoint = endPoint.GetComponent <SpringJoint2D>();

        endSpringJoint.connectedBody = tentacle.connectBody;
        endSpringJoint.distance      = tentacle.length * ((float)severPoint / (float)tentacle.segments) * 0.5f;

        Tentacle endHalf = Ungenerated();

        CopyTentSubSegments(tentacle, endHalf, severPoint, tentacle.segments - 1);
        MakeEndDangling(endHalf.transform);
        if (tentacle.Grabbing)
        {
            endHalf.AttachEnd(tentacle.endAttachSpring.connectedBody, tentacle.GetEndPosition());
        }
        else
        {
            Transform endHalfEndPoint = endHalf.transform.Find("EndPoint");
            MakeEndDangling(endHalfEndPoint);
            SpringJoint2D endHalfEndSpring = endHalfEndPoint.gameObject.GetComponent <SpringJoint2D>();
            endHalfEndSpring.enabled = false;

            Rigidbody2D endBody = endHalf.gameObject.GetComponent <Rigidbody2D>();
            endBody.gravityScale = 1;
            Rigidbody2D endPointBody = endHalfEndPoint.gameObject.GetComponent <Rigidbody2D>();
            endPointBody.gravityScale = 1;
        }
        SpringJoint2D spring = endHalf.gameObject.GetComponent <SpringJoint2D>();

        spring.connectedBody = endHalf.transform.Find("EndPoint").gameObject.GetComponent <Rigidbody2D>();
        spring.distance      = (tentacle.length - endSpringJoint.distance) * 0.5f;

        ExplosionManager.BloodSplatter(tentacle.tentJoints[severPoint].transform.position, 3, 0);

        tentacle.StopGrabbing();
        GameObject.Destroy(tentacle.gameObject);
    }