示例#1
0
    public void AttachTentaclePlayer()
    {
        playerTentacle.gameObject.SetActive(true);

        playerTentacle.pullLength = 2f;
        playerTentacle.SetGrabbing(nurseGrabPoint.transform.parent.gameObject, nurseGrabPoint.transform.position);
        playerTentacle.AttachEnd(nurseGrabPoint.transform.parent.gameObject.GetComponent <Rigidbody2D>(), nurseGrabPoint.transform.position);

        GameManager.CopyTentSubSegments(tentacle, playerTentacle, 4, tentacle.segments - 1);
        //GameManager.CopyTentSegments(tentacle, playerTentacle);

        //playerTentacle.joints = tentacle.joints;
        //foreach(var joint in tentacle.joints) {

        //	joint.gameObject.transform.SetParent(playerTentacle.transform);
        //}
        //playerTentacle.baseSegment = tentacle.baseSegment;
        //playerTentacle.baseSegment.transform.SetParent(playerTentacle.basePoint);
        //playerTentacle.baseSegment.transform.localPosition = Vector3.zero;
        //
        //playerTentacle.baseSegment.transform.localPosition = Vector3.zero;
        //playerTentacle.baseSegment.GetComponent<StretchTo>().RecalculateStart();
        tentacleRipped.gameObject.SetActive(true);
        GameManager.CopyTentSubSegments(tentacle, tentacleRipped, 0, 4);
        tentacle.gameObject.SetActive(false);

        GameObject tentSegment = GetATentacleSegment();
        GameObject explosion   = Instantiate(bloodSplatterPrefab);

        explosion.transform.position   = tentSegment.transform.position;
        explosion.transform.localScale = new Vector3(-1, 1, 1);
        explosion.SetActive(true);

        GameObject player = GameManager.Instance.playerController.gameObject;
        //tentacle.AttachBase(player.GetComponent<Rigidbody2D>(), player.transform.position);
        //Transform tentIdle = nurse.transform.Find("Tentacle Idle");
        //tentacle.AttachEnd(tentIdle.GetComponent<Rigidbody2D>(), tentIdle.position);
        //tentacle.pullLength = 2f;
        //tentacle.SetGrabbing(nurseGrabPoint.transform.parent.gameObject, nurseGrabPoint.transform.position);
        //tentacle.AttachEnd(nurseGrabPoint.transform.parent.gameObject.GetComponent<Rigidbody2D>(), nurseGrabPoint.transform.position);

        Transform tentIdle2 = nurse.transform.Find("Tentacle Idle (1)");

        Rigidbody2D tentBody = tentIdle2.GetComponent <Rigidbody2D>();

        tentBody.bodyType            = RigidbodyType2D.Dynamic;
        tentIdle2.transform.position = player.transform.position;
        tentacleSecond.AttachEnd(tentBody, tentIdle2.position);
    }
示例#2
0
    public void Grapple(Rigidbody2D grappledBody, Vector3 grappledPoint, bool playSound = true)
    {
        if (grappledBody.gameObject.GetComponent <MessageOnGrab>())
        {
            grappledBody.gameObject.SendMessage("GetGrabbed", this);
        }
        Fungus.Flowchart.BroadcastFungusMessage("PlayerGrappling");
        //tentacle.endPoint.position = new Vector3(hit.point.x, hit.point.y, -5f);
        tentacle.SetGrabbing(grappledBody.gameObject, grappledPoint, playSound);
        tentacle.joint.distance = CommonUtils.Distance(transform.position, grappledPoint);

        tentacle.AttachEnd(grappledBody, grappledPoint);

        grappling = true;
    }
示例#3
0
    // Use this for initialization
    void Start()
    {
        myBody = GetComponentInParent <Rigidbody2D>();

        leftIdle  = transform.Find("LeftIdle");
        rightIdle = transform.Find("RightIdle");

        for (int i = 0; i < tentaclesPerSide; i++)
        {
            Tentacle tentacle = TentacleMaker.Basic(pack, 9);
            tentacle.transform.parent        = transform;
            tentacle.transform.localPosition = Vector2.zero;
            tentacle.AttachBase(myBody, myBody.transform.position);
            tentacle.AttachEnd(myBody, RightIdlePosition());
            rightSideTentacles.Add(tentacle);
        }

        for (int i = 0; i < tentaclesPerSide; i++)
        {
            Tentacle tentacle = TentacleMaker.Basic(pack, 9);
            tentacle.transform.parent        = transform;
            tentacle.transform.localPosition = Vector2.zero;
            tentacle.AttachBase(myBody, myBody.transform.position);
            tentacle.AttachEnd(myBody, LeftIdlePosition());
            leftSideTentacles.Add(tentacle);
        }
    }
示例#4
0
 public void Grapple(Tentacle tentacle, Rigidbody2D grappledBody, Vector3 grappledPoint, bool playSound = true)
 {
     //StartCoroutine(_waitForTentEndToGrab(tentacle, grappledBody, grappledPoint, playSound));
     tentacle.SetGrabbing(grappledBody.gameObject, grappledPoint, playSound);
     tentacle.joint.distance = CommonUtils.Distance(tentacle.transform.position, grappledPoint);
     tentacle.AttachEnd(grappledBody, grappledPoint);
 }
示例#5
0
    public void UpdateTent(Tentacle tentacle, Vector3 idle)
    {
        Vector2 n = CommonUtils.NormalVector(transform.position, tentacle.endPoint.position);
        //float theta = CommonUtils.ThetaBetween(n, climbDirection);
        float nAsAngle        = CommonUtils.VectorToAngle(n);
        float dAsAngle        = CommonUtils.VectorToAngle(climbDirection);
        float angleDifference = dAsAngle - nAsAngle;
        // TODO: account for values that are pointing left/west, that either give -pi or pi
        float d = CommonUtils.Distance(transform.position, tentacle.endPoint.position);

        if (tentacle.Grabbing)
        {
            if (d > reach * 0.5f && Mathf.Abs(angleDifference) > Mathf.PI * 2f / 4f)
            {
                tentacle.StopGrabbing();
                tentacle.AttachEnd(myBody, idle);
            }
            else
            {
                if (d > 1.0f)
                {
                    if (Mathf.Abs(angleDifference) < Mathf.PI * 0.5f)
                    {
                        tentacle.joint.distance -= stretchSpeed + speedBoostActual;
                    }
                    else
                    {
                        tentacle.joint.distance += stretchSpeed + speedBoostActual;
                    }
                }
            }
        }
    }
示例#6
0
    public void SetNurseDanglingFromMecha()
    {
        Transform tentAttachPoint = nurse.transform.Find("TentacleAttachPoint");

        nurseTentacle.AttachBase(nurse.GetComponent <Rigidbody2D>(), tentAttachPoint.position);
        nurseRippedTentacle.AttachBase(nurse.GetComponent <Rigidbody2D>(), tentAttachPoint.position);

        nurseTentacle.pullLength = 7f;
        nurseTentacle.length     = 5f;
        nurseTentacle.SetGrabbing(mechHand, mechHand.transform.position);
        nurseTentacle.AttachEnd(mechHand.GetComponent <Rigidbody2D>(), mechHand.transform.position);
        nurseTentacle.ClearSegments();
        nurseTentacle.GenerateSegments();

        Rigidbody2D nurseBody = nurse.GetComponent <Rigidbody2D>();

        nurseBody.mass = 30.0f;

        nurseRippedTentacle.AttachEnd(nurseBody, nurse.transform.position);

        nurse.transform.position = mechHand.transform.position;
        //nurseTentacle.basePoint.transform.position = nurse.transform.position;
        nurseTentacle.TeleportToBase();

        nurseTentacle.endPoint.transform.position = mechHand.transform.position;
    }
示例#7
0
    public void AttachTentacleToNurse()
    {
        Transform tentAttachPoint = nurse.transform.Find("TentacleAttachPoint");

        tentacle.AttachBase(nurse.GetComponent <Rigidbody2D>(), tentAttachPoint.position);
        tentacleSecond.AttachBase(nurse.GetComponent <Rigidbody2D>(), tentAttachPoint.position);
        tentacleRipped.gameObject.SetActive(true);
        tentacleRipped.AttachBase(nurse.GetComponent <Rigidbody2D>(), tentAttachPoint.position);
        tentacleRipped.gameObject.SetActive(false);
        Transform tentIdle = nurse.transform.Find("Tentacle Idle");

        tentacle.AttachEnd(tentIdle.GetComponent <Rigidbody2D>(), tentIdle.position);

        Transform tentIdle2 = nurse.transform.Find("Tentacle Idle (1)");

        tentacleSecond.AttachEnd(tentIdle2.GetComponent <Rigidbody2D>(), tentIdle2.position);
    }
示例#8
0
    bool TryAttachToPlayer(Tentacle tentacle)
    {
        if (!tentacle.Grabbing)
        {
            PlayerController pc          = GameManager.Instance.playerController;
            Rigidbody2D      playersBody = pc.gameObject.GetComponent <Rigidbody2D>();

            Vector2 grabPoint = pc.transform.position;

            StartCoroutine(_waitForTentEndToGrabPlayer(tentacle, playersBody, grabPoint, true));
            tentacle.AttachEnd(playersBody, grabPoint);

            return(true);
        }
        return(false);
    }
示例#9
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);
    }