internal void RefreshSphere(LevelSphere _temp) { if (SphereNum != _temp.SphereNum) { ObjectPool.Instance.Cando = true; Config.Instance.isMerga = true; return; } SetThisValue(SphereNum *= 2); transform.name = transform.name.Split('_')[0] + "_" + SphereNum; ObjectPool.Instance.Unspawn(_temp.gameObject); ObjectPool.Instance.Cando = false; if (SphereNum == 2048) { AudioMgr.Instance.PlayAudios("08"); } zhatexiao((int)SphereNum); if (gameObject != null && gameObject.activeSelf) { StartCoroutine(Merga((int)SphereNum)); } else { ObjectPool.Instance.Cando = true; } }
private void GetSaveValue() { for (int i = 0; i < DataManager.getSphereInfo.Count; i++) { SphereInfo info = DataManager.getSphereInfo[i]; LevelSphere sphere = Config.Instance.CreateSphere(m_SphereParent, info.num, new Vector2((float)info.pos[0], (float)info.pos[1])); sphere.id = -(info.id == 0 ? i : info.id); sphere.m_Rigidbody.constraints = RigidbodyConstraints2D.None; } }
internal LevelSphere CreateSphere(Transform parent, double value, Vector2 pos, LevelSphere.Type type = LevelSphere.Type.nomal) { LevelSphere Clone = ObjectPool.Instance.Spawn <LevelSphere>("m_Sphere", parent); Clone.m_Rigidbody.constraints = ~RigidbodyConstraints2D.FreezePositionX; Clone.SphereType = type; if (type == LevelSphere.Type.nomal) { Clone.SphereNum = (float)value; } id++; Clone.id = id; Clone.anchoredPosition3D(pos).localScale(1); Clone.name = "Sphere_" + value; return(Clone); }
public MergeEvent(LevelSphere sphereA, LevelSphere sphereB) { SphereA = sphereA; SphereB = sphereB; }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.transform.CompareTag("m_Sphere")) { LevelSphere sphere = collision.transform.GetComponent <LevelSphere>(); switch (SphereType) { case Type.nomal: //LogUtil.Error("stay 1", "名字-->" + SphereNum + "ID---->" + id + "名字2--->" + sphere.SphereNum + "ID2--------->" + sphere.id); if (sphere.SphereNum == SphereNum && (int)SphereNum < 2048) { if (id >= sphere.id && Config.Instance.isMerga) { //Debug.LogError("接触进入"); //Debug.LogError("st222" + "名字1" + "<" + SphereNum + "--" + id + ">" + "名字2" + "<" + sphere.SphereNum + "--" + sphere.id + ">"); // ObjectPool.Instance.MergeEvents.Enqueue(new MergeEvent(this, sphere)); // ObjectPool.Instance.CheckMerge(); RefreshSphere(sphere); if (Config.Instance.mList.Contains(id + "_" + sphere.id)) { Config.Instance.mList.Remove(id + "_" + sphere.id); } if (Config.Instance.mList.Contains(sphere.id + "_" + id)) { Config.Instance.mList.Remove(sphere.id + "_" + id); } } } break; case Type.redPacket: break; case Type.gravity: break; case Type.universal: if (sphere.sphereType == Type.universal) { Destroy(collision.gameObject); Destroy(this); } if (Config.Instance.isMerga) { ObjectPool.Instance.MergeEvents.Enqueue(new MergeEvent(this, sphere)); } break; case Type.Puzzle: if (sphere.sphereType == Type.Puzzle) { Destroy(collision.gameObject); Destroy(this); } if (Config.Instance.isMerga) { ObjectPool.Instance.MergeEvents.Enqueue(new MergeEvent(this, sphere)); } break; } } else if (collision.transform.tag == "Border") { if (sphereType == Type.gravity) { StartCoroutine(UnspawnGravity()); } } else if (collision.transform.tag == "Death") { Blood--; if (Blood <= 0) { PanelMgr.GetInstance.ShowPanel(PanelName.RestartPanel, false); Blood = 1; } } }
private void OnCollisionStay2D(Collision2D collision) { if (collision.transform.CompareTag("m_Sphere")) { LevelSphere sphere = collision.transform.GetComponent <LevelSphere>(); switch (SphereType) { case Type.nomal: if (sphere != null && sphere.SphereNum == SphereNum && (int)SphereNum < 2048) { if (Config.Instance.mList == null) { return; } if (Config.Instance.mList.Contains(id + "_" + sphere.id) || Config.Instance.mList.Contains(sphere.id + "_" + id)) { return; } if (id > sphere.id && Config.Instance.isMerga) { Config.Instance.isMerga = false; Config.Instance.mList.Add(id + "_" + sphere.id); RefreshSphere(sphere); if (Config.Instance.mList.Contains(id + "_" + sphere.id)) { Config.Instance.mList.Remove(id + "_" + sphere.id); } if (Config.Instance.mList.Contains(sphere.id + "_" + id)) { Config.Instance.mList.Remove(sphere.id + "_" + id); } } } break; case Type.redPacket: break; case Type.gravity: break; case Type.universal: if (Config.Instance.isMerga) { ObjectPool.Instance.MergeEvents.Enqueue(new MergeEvent(this, sphere)); } break; case Type.Puzzle: //if (Config.Instance.isMerga) //{ ObjectPool.Instance.MergeEvents.Enqueue(new MergeEvent(this, sphere)); //} break; } } }