コード例 #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.transform.parent == null)
        {
            return;
        }

        if (!cooldown && collision.transform.parent.gameObject.CompareTag("Player"))//&& collision.transform.parent.GetComponent<Goop>() != null)
        {
            interactiveGoop = collision.transform.parent.GetComponent <Goop>();

            if (hit_reactivateLaunch && !hit_boostInDirection)
            {
                interactiveGoop.canLaunch = true;
            }

            if (hit_bump)
            {
                Bump();
            }

            if (hit_boostInDirection)
            {
                if (hit_reactivateLaunch)
                {
                    interactiveGoop.Launch(boostVelocity, .25f);
                }
                else
                {
                    interactiveGoop.Launch(boostVelocity, true);
                }
            }

            if (hit_normalizeBoost)
            {
                interactiveGoop.rb.velocity = interactiveGoop.rb.velocity.normalized * normalizeBoostForce;
            }

            if (hit_clone)
            {
                GameObject clone         = Instantiate(interactiveGoop.gameObject, interactiveGoop.transform.position, Quaternion.identity);
                Vector2    cloneVelocity = interactiveGoop.rb.velocity;
                cloneVelocity.x = -cloneVelocity.x;
                clone.GetComponent <Rigidbody2D>().velocity = cloneVelocity;
                clone.GetComponent <Goop>().canLaunch       = hit_reactivateLaunch;
            }

            StartCoroutine(Cooldown(cooldownTimer));
        }
    }
コード例 #2
0
    public void OnGoop(Goop goop)
    {
        PlayerController player = transform.parent.gameObject.GetComponent <PlayerController>();

        player.OnGoop(goop);
    }
コード例 #3
0
ファイル: PlayerController.cs プロジェクト: netguy204/ld40
 public void OnGoop(Goop goop)
 {
     Destroy(goop.gameObject);
     transform.localScale += new Vector3(0.5f, 0.5f, 0.5f);
 }
コード例 #4
0
ファイル: GoopRender.cs プロジェクト: thanthemannn/Goop
 // Start is called before the first frame update
 void Start()
 {
     rend    = GetComponent <SpriteRenderer>();
     rb      = transform.parent.GetComponent <Rigidbody2D>();
     parGoop = transform.parent.GetComponent <Goop>();
 }