void Bounce(IsMergeable mergeScript)
    {
        Vector3 mergepos = mergeScript.gameObject.transform.position;
        Vector3 distance = new Vector3(mergepos.x - transform.position.x, mergepos.y - transform.position.y, 0).normalized;

        transform.position = mergepos + distance;
    }
示例#2
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        PlayerMerge mergeScript = null;

        try { mergeScript = coll.gameObject.GetComponent <PlayerMerge>(); }
        catch { }

        if (mergeScript != null)
        {
            Merge();
            if (UpdatedSize != null)
            {
                UpdatedSize(size);
            }
        }

        if (UpdatedSize != null)
        {
            UpdatedSize(size);
        }

        if (HitObject != null)
        {
            IsMergeable.HitObject(this, coll.gameObject);
        }
    }
示例#3
0
 void StopRunning(IsMergeable mergeScript, GameObject hitObject)
 {
     if (mergeScript.gameObject.tag == "Bull")
     {
         stopRunning = true;
     }
 }
示例#4
0
 //public function that starts the camera shaking.
 public void Shake(PlayerMerge x = null, IsMergeable y = null)
 {
     if (!isShacking)
     {
         isShacking = true;
         StartCoroutine(CameraShaking());
     }
 }
示例#5
0
    void Bounce(IsMergeable mergeScript)
    {
        Vector2 mergepos = (Vector2)mergeScript.gameObject.transform.position;
        Vector2 distance = (mergepos - (Vector2)transform.position);

        applyTranslation((Vector2)(mergepos + distance), -2);
        StartCoroutine(BounceCooldown());
    }
 void MergeHit(IsMergeable hitObj, GameObject gotHitObject)
 {
     if (hitObj.gameObject.tag == "Bull" && gotHitObject.gameObject == gameObject)
     {
         //play particles and stuff
         DestroyMe();
     }
 }
示例#7
0
    void PlayerMerged(IsMergeable mergeScript)
    {
        if (mergeScript.mergeMesh != null)
        {
            GameObject mergeStuff = Instantiate(mergeScript.mergeMesh) as GameObject;

            mergeStuff.transform.rotation = Random.rotation;


            mergeStuff.transform.parent   = gameObject.transform;
            mergeStuff.transform.position = Vector3.zero;
        }
    }
示例#8
0
    void MergeTexture(IsMergeable mergeScript)
    {
        Texture tex  = mergeScript.tex;
        texType type = mergeScript.type;

        if (tex != null)
        {
            myMaterial.mainTexture = MergeNewTex(
                myMaterial.mainTexture as Texture2D,
                tex as Texture2D,
                highlightTextures[(int)type] as Texture2D
                ) as Texture;
        }
    }
示例#9
0
    void MergeHappend(IsMergeable mergeScript)
    {
        //if (CanMerge == true) {
        float     otherSize    = mergeScript.size;
        Texture2D otherTexture = mergeScript.tex;

        if (size >= otherSize)
        {
            if (size < maxSize)
            {
                size += otherSize;
                if (IMerged != null)
                {
                    IMerged(mergeScript);
                }
                if (mergeScript.gameObject.tag == "HealthPack")
                {
                    ChangeHealth(1);
                }
            }
            mergeScript.DestroyMe();
        }     //grow(), merge and destroy other

        else if (size > minSize)
        {
            if (IFailedToMerge != null)
            {
                ChangeHealth(-1);
                if (IFailedToMerge != null)
                {
                    IFailedToMerge(this, mergeScript);
                }
            }
        } //Break into two()

        if (UpdatedSize != null)
        {
            UpdatedSize(size);
            foreach (Transform child in GetComponentInChildren <Transform>())
            {
                if (child.tag == "Waste")
                {
                    child.localScale = transform.localScale;
                }
            }
        }
        //}
    }
示例#10
0
    void SplitInTwo(PlayerMerge playerObject, IsMergeable otherMerge)
    {
        playerObject.size /= 2;

        GameObject playerWaste = Instantiate(playerObject.gameObject) as GameObject;

        StartCoroutine(CloneBall(playerWaste.GetComponent <CircleCollider2D>()));

        playerWaste.GetComponent <Rigidbody2D>().velocity = playerObject.GetComponent <Rigidbody2D>().velocity.normalized;

        foreach (MonoBehaviour script in playerWaste.GetComponents <MonoBehaviour>())
        {
            Destroy(script);
        }

        foreach (Transform child in playerWaste.GetComponentsInChildren <Transform>())
        {
            if (child.gameObject != playerWaste)
            {
                Destroy(child.gameObject);
            }
        }

        playerWaste.AddComponent <RotateAroundWorld>();
        IsMergeable mergeScript = playerWaste.AddComponent <IsMergeable>();

        mergeScript.size = playerObject.size;


        ChangeToSize sizeScript = playerWaste.AddComponent <ChangeToSize>();

        sizeScript.SizeMultiplier = playerObject.gameObject.GetComponent <ChangeToSize>().SizeMultiplier;

        playerWaste.AddComponent <DisplaySize>();

        sizeScript.UpdateSize(mergeScript.size);
    }
示例#11
0
 void Awake()
 {
     mergeScript = GetComponent <IsMergeable>();
 }
示例#12
0
 void SucceedsToMerge(IsMergeable temp)
 {
     Instantiate(mergeParticle, transform.position, Quaternion.identity);
 }
示例#13
0
 void FailingToMerge(PlayerMerge temp, IsMergeable otherMerge)
 {
     Instantiate(mergeFailParticle, transform.position, Quaternion.identity);
 }
示例#14
0
 void Awake()
 {
     rb          = GetComponent <Rigidbody2D>();
     mergeScript = GetComponent <IsMergeable>();
 }
示例#15
0
 public void PlayerMerged(PlayerMerge pMovement, IsMergeable mergeScript)
 {
     CancleDash();
     Bounce(mergeScript);
 }
示例#16
0
 public void PlayerMerged(PlayerMerge pMerge, IsMergeable mergeScript)
 {
     Bounce(mergeScript);
 }