/// <summary> /// 杂草增长 /// </summary> public static void Grow() { List <Slot> slots = new List <Slot> (); Weed weed = null; for (int i = 0; i < all.Count; i++) { weed = all[i]; for (int j = 0; j < Utils.straightSides.Length; j++) { Side side = Utils.straightSides[j]; if (weed.slot[side] && !weed.slot[side].Block) // && !(weed.slot[side].GetChip() && weed.slot[side].GetChip().chipType == "SugarChip")) { slots.Add(weed.slot[side]); } } } while (seed > 0) { if (slots.Count == 0) { return; } Slot target = slots[Random.Range(0, slots.Count)]; slots.Remove(target); if (target.GetChip()) { target.GetChip().HideChip(false); } Weed newWeed = FightMgr.Instance.LoadAndInstantiate(FightDefine.Prefab_Weed).GetComponent <Weed>(); newWeed.transform.position = target.transform.position; newWeed.name = "New_Weed"; newWeed.transform.SetParent(target.transform, false); target.SetBlock(newWeed); newWeed.slot = target; #if !FightTest MusicManager.Instance.PlaySoundEff("Music/WeedCreate"); #endif newWeed.Initialize(); seed--; } }
/// <summary> /// 随机出一个木块 /// </summary> public void CreateOneBlock(Slot s) { if (s != null && s.GetChip() && !s.Block && !s.IsGenerator) { int x = s.Point.X; int y = s.Point.Y; s.GetChip().HideChip(false); field.blocks[x, y] = 2; GameObject o = FightMgr.Instance.LoadAndInstantiate(FightDefine.Prefab_Block);; o.name = "Block_" + x + "x" + y; // o.transform.parent = s.transform; o.transform.SetParent(s.transform, false); o.transform.position = s.transform.position; Block b = o.GetComponent <Block>(); s.SetBlock(b); b.slot = s; b.level = field.blocks[x, y]; b.Initialize(); } }