コード例 #1
0
    public override void OnHeartCollide(float heartVal, DetachedPiece thisHeart)
    {
        if (catchingIsStopped == false)
        {
            if (NextPosFree())
            {
                health += heartVal;
                if (health > maxHealth)
                {
                    health = maxHealth;
                }
                BlockHealthCheck();
                SetHighlight();
                thisHeart.collidedOnce = true;

                LookAtObject newBoiFace   = playerBlockParent.GetChild((int)health - 1).GetComponentInChildren <LookAtObject>();
                LookAtObject looseBoiFace = thisHeart.GetComponentInChildren <LookAtObject>();
                newBoiFace.randomizeFace = false;
                if (!newBoiFace.alreadyGotSpecialFace)
                {
                    newBoiFace.GetComponent <SpriteRenderer>().sprite = looseBoiFace.GetComponent <SpriteRenderer>().sprite;
                }
                else if (latestFaceProfile != null)
                {
                    if (!looseBoiFace.alreadyGotSpecialFace)
                    {
                        newBoiFace.SetRandomFace(latestFaceProfile); //asign the lipstick on attachment now i guess
                    }
                    else
                    {
                        newBoiFace.GetComponent <SpriteRenderer>().sprite = looseBoiFace.GetComponent <SpriteRenderer>().sprite;
                    }
                }

                Destroy(thisHeart.gameObject);

                // play Get Piece sound
                fModGetPieceEvent.start();

                if (health > 1 && rotationIndicatorIcon.activeSelf == false)
                {
                    rotationIndicatorIcon.SetActive(true);
                }

                PlayerPieceAnimatorManager animationManager = GetComponent <PlayerPieceAnimatorManager>();
                if (animationManager)
                {
                    //animationManager.ActivateAnimatorTrigger("Catch");
                }
            }
        }
    }
コード例 #2
0
    GameObject SetUpAutomatedThrowing(Transform stopPos, Vector2 positionThrown)
    {
        GameObject pieceThrown = Instantiate(pieceToThrow, positionThrown, Quaternion.identity);

        foreach (Transform child in pieceThrown.transform)
        {
            child.gameObject.layer = LayerMask.NameToLayer("NoPlayerCollision");
        }
        DetachedPiece detachedPieceComp = pieceThrown.GetComponent <DetachedPiece>();

        detachedPieceComp.IgnoreColl(playerMoveComp.pieceColliders, true);
        detachedPieceComp.RevertCollision();

        // SET UP POSITION TO LERP TO
        Vector3 midPos = new Vector3();

        midPos.x = stopPos.position.x + (positionThrown.x - stopPos.position.x) / 2;
        midPos.y = stopPos.position.y + 3f;

        Vector3[] positions = new Vector3[] { positionThrown, midPos, stopPos.position };

        // Set the detatched pieces stopping point
        detachedPieceComp.SetStoppingDestination(positions);

        //Rigidbody2D pieceRigidBody = pieceThrown.GetComponent<Rigidbody2D>();
        //pieceRigidBody.gravityScale = 0; //temporarily turn off the normal gravity in order to do it manually for the throws


        //set the face of the new loose boi
        LookAtObject looseBoiFace = pieceThrown.GetComponentInChildren <LookAtObject>();

        looseBoiFace.randomizeFace = false;
        LookAtObject newBoiFace = playerHealthComp.playerBlockParent.GetChild((int)playerHealthComp.health - 1).GetComponentInChildren <LookAtObject>();

        looseBoiFace.GetComponent <SpriteRenderer>().sprite = newBoiFace.GetComponent <SpriteRenderer>().sprite;
        if (newBoiFace.alreadyGotSpecialFace)
        {
            looseBoiFace.alreadyGotSpecialFace = true;
        }
        //make them look at the one who dropped them (can change)
        looseBoiFace.autofindLookTarget = false;
        looseBoiFace.targetLook         = transform;

        playerHealthComp.OnThrow(); //ENABLE TO DETATCH PIECES

        return(pieceThrown);
    }
コード例 #3
0
    // THIS IS THE OLD PREFAB FIREING FOR THE CAMPFIRE DELETE LATER ------------------------------------------------------------------
    GameObject ShootProjectile(Throw directionalThrow, Transform stopPos, Vector2 positionThrown)
    {
        //if grounded
        //Vector2 positionThrown = playerHealthComp.playerBlockParent.GetChild((int)playerHealthComp.health - 1).transform.position;
        //if (positionThrown.y % 2 == 0)
        //{
        //    positionThrown.y = Mathf.RoundToInt(positionThrown.y) + .5f;
        //}

        GameObject pieceThrown = Instantiate(pieceToThrow, positionThrown, Quaternion.identity);

        foreach (Transform child in pieceThrown.transform)
        {
            child.gameObject.layer = LayerMask.NameToLayer("NoPlayerCollision");
        }
        DetachedPiece detachedPieceComp = pieceThrown.GetComponent <DetachedPiece>();

        detachedPieceComp.IgnoreColl(playerMoveComp.pieceColliders, true);
        detachedPieceComp.RevertCollision();

        // Set the detatched pieces stopping point
        //detachedPieceComp.SetStoppingDestination(stopPos);

        //Get the Vectpr to fire the piece from
        //Transform playerHead = playerHealthComp.playerBlockParent.GetChild((int)playerHealthComp.health - 1);
        //Vector3 fireDirectionVector = (rotationIndicatorIcon.transform.position - playerHead.position).normalized;

        //CalculateThrow(); // Calculate the shot velocity and gravity depending on the incial launch angle


        Rigidbody2D pieceRigidBody = pieceThrown.GetComponent <Rigidbody2D>();

        pieceRigidBody.velocity     = new Vector2(directionalThrow.startingVelocity.x, directionalThrow.startingVelocity.y);
        pieceRigidBody.gravityScale = 0; //temporarily turn off the normal gravity in order to do it manually for the throws
        detachedPieceComp.gravity   = directionalThrow.gravity;
        detachedPieceComp.hasLanded = false;

        playerHealthComp.OnThrow(); //ENABLE TO DETATCH PIECES

        // Play Throw Sound
        fModThrowPieceEvent.start();

        return(pieceThrown);
    }
コード例 #4
0
ファイル: IHealth.cs プロジェクト: JohnLeeErg/TrailMix
 public virtual void OnHeartCollide(float heartVal, DetachedPiece thisHeart) //when collided with a heart
 {
 }
コード例 #5
0
    GameObject ShootProjectile()
    {
        // Generate the object to shot from the player
        //Vector2 positionThrown = playerHealthComp.playerBlockParent.GetChild((int)playerHealthComp.health - 1).transform.position;
        //positionThrown.y = Mathf.RoundToInt(positionThrown.y) + .5f;

        //if grounded
        Vector2 positionThrown = playerHealthComp.playerBlockParent.GetChild((int)playerHealthComp.health - 1).transform.position;

        //positionThrown = Movement.RoundVectorToPoint5s(positionThrown);
        //if (positionThrown.y % 1 == 0)
        //{
        //    positionThrown.y += .5f;
        //    print("on the line");
        //}
        positionThrown.y = Mathf.Round(positionThrown.y + .5f) - .5f;


        GameObject pieceThrown = Instantiate(pieceToThrow, positionThrown, Quaternion.identity);

        //set the face of the new loose boi
        LookAtObject looseBoiFace = pieceThrown.GetComponentInChildren <LookAtObject>();

        looseBoiFace.randomizeFace = false;
        LookAtObject newBoiFace = playerHealthComp.playerBlockParent.GetChild((int)playerHealthComp.health - 1).GetComponentInChildren <LookAtObject>();

        looseBoiFace.GetComponent <SpriteRenderer>().sprite = newBoiFace.GetComponent <SpriteRenderer>().sprite;
        if (newBoiFace.alreadyGotSpecialFace)
        {
            looseBoiFace.alreadyGotSpecialFace = true;
        }
        //make them look at the one who dropped them (can change)
        looseBoiFace.autofindLookTarget = false;
        looseBoiFace.targetLook         = transform;

        DetachedPiece detachedPieceComp = pieceThrown.GetComponent <DetachedPiece>();

        detachedPieceComp.IgnoreColl(playerMoveComp.pieceColliders, true);
        detachedPieceComp.RevertCollision();

        //Get the Vectpr to fire the piece from
        Transform playerHead          = playerHealthComp.playerBlockParent.GetChild((int)playerHealthComp.health - 1);
        Vector3   fireDirectionVector = (rotationIndicatorIcon.transform.position - playerHead.position).normalized;

        CalculateThrow(); // Calculate the shot velocity and gravity depending on the incial launch angle


        Rigidbody2D pieceRigidBody = pieceThrown.GetComponent <Rigidbody2D>();

        pieceRigidBody.velocity     = new Vector2(currentThrow.startingVelocity.x * rotationIndicatorInput.x, currentThrow.startingVelocity.y * Mathf.Sign(rotationIndicatorInput.y));
        pieceRigidBody.gravityScale = 0; //temporarily turn off the normal gravity in order to do it manually for the throws
        detachedPieceComp.gravity   = currentThrow.gravity;
        detachedPieceComp.hasLanded = false;
        if (currentThrow == throwingProfile.horizontals)
        {
            detachedPieceComp.SetTimeFromSpeedAndDistance(currentThrow.xDistance);
        }
        playerHealthComp.OnThrow(); //ENABLE TO DETATCH PIECES

        // Play Throw Sound
        fModThrowPieceEvent.start();
        //throwScreamEvent.start();
        return(pieceThrown);
    }