IEnumerator LadybirdsMixRoutine(Chip secondary) { chip.busy = true; chip.destroyable = false; yield return(0); List <Chip> ladies = new List <Chip>(); int count = 3; if (secondary.chipType == "Ladybird") { count = 5; } if (chip.slot.jam) { chip.jamType = chip.slot.jam.type; } for (int i = 0; i <= count; i++) { Chip l = ContentAssistant.main.GetItem <Chip>("Ladybird" + Chip.chipTypes[Random.value > 0.5f ? chip.id : secondary.id]); l.destroyable = false; l.transform.position = chip.slot.transform.position; l.transform.localScale = Vector3.one; l.transform.SetParent(Slot.folder); l.transform.Find("LadybirdBody").rotation = Quaternion.Euler(0, 0, Random.Range(0f, 360f)); l.jamType = chip.jamType; if (secondary.chipType != "Ladybird") { l.GetComponent <Ladybird>().seed = secondary.chipType; } ladies.Add(l); } chip.Minimize(); SessionAssistant.main.EventCounter(); foreach (Chip l in ladies) { if (l == null) { continue; } Animation a = l.GetComponent <Animation>(); while (a.isPlaying) { yield return(0); } l.destroyable = true; l.jamType = chip.jamType; l.DestroyChip(); } chip.busy = false; chip.HideChip(false); }
// Crush block function public void BlockCrush(int2 coord, bool radius, bool force = false) { IBlock block = null; Slot slot = null; Chip chip = null; StoneChip stone = null; if (radius) { foreach (Side side in Utils.straightSides) { block = null; slot = null; chip = null; stone = null; slot = Slot.GetSlot(coord + side); if (!slot) { continue; } block = slot.block; if (block && block.CanBeCrushedByNearSlot()) { block.BlockCrush(force); } if (slot) { chip = slot.chip; } if (chip) { stone = chip.GetComponent <StoneChip>(); } if (stone) { chip.DestroyChip(); } } } slot = Slot.GetSlot(coord); if (slot) { block = slot.block; } if (block) { block.BlockCrush(force); } }
public void CmdShoot() { if (!isServer) { return; } if (Time.time > nextFire) { nextFire = Time.time + fireRate; GameObject chip = Instantiate(this.chip); Chip chipScript = chip.GetComponent <Chip>(); if (isAbility) { chipScript.chipType = (ConstantsDictionary.CHIP_TYPE)Random.Range(1, 3); chipScript.abilityDamage = abilityDamage; isAbility = false; } else { chipScript.chipType = ConstantsDictionary.CHIP_TYPE.Normal; chipScript.attackDamage = basicAttackDamage; } chip.SetActive(false); chipScript.GetComponent <SpriteRenderer>().sprite = chipSprites[(int)chipScript.chipType]; chip.SetActive(true); chip.transform.position = transform.position + ((enemyController.target.position - transform.position).normalized * 0.5f); Vector2 direction = enemyController.target.position - transform.position; chip.GetComponent <Rigidbody2D>().velocity = chipVelocity * direction.normalized; NetworkServer.Spawn(chip); CmdChipRotation(direction, chip); } }
void OnEnable() { chip = (Chip)target; chip_id = serializedObject.FindProperty("id"); logic = chip.GetComponent <IChipLogic>(); if (logic != null) { chip.chipType = logic.GetChipType(); chip_type = serializedObject.FindProperty("chipType"); } IAnimateChip[] components = chip.GetComponents <IAnimateChip>(); List <Clip> clips = new List <Clip>(); foreach (IAnimateChip component in components) { clips.AddRange(component.GetClipNames().Select(x => new Clip(x)).ToList()); } foreach (Clip clip in clips) { if (!chip.clips_serialized.Contains(clip)) { chip.clips_serialized.Add(clip); } } foreach (Clip clip in new List <Clip>(chip.clips_serialized)) { if (!clips.Contains(clip) && chip.clips_serialized.Contains(clip)) { chip.clips_serialized.Remove(clip); } } chip.clips_serialized.Sort((Clip a, Clip b) => { return(string.CompareOrdinal(a.name, b.name)); }); }
// Use this for initialization void Start() { SpriteRenderer sprite = DefaultTile.GetComponent <SpriteRenderer>(); if (gameObject.GetComponent <CsvReader>() == null) { MapData = gameObject.AddComponent <CsvReader>(); } else { MapData = gameObject.GetComponent <CsvReader>(); } connectSet = gameObject.AddComponent <TileConnectSet>(); MapData.CsvResource = MapResourceCSS; MapData.ReadData(); //CSSファイルから読み出し MapLength = MapData.csvDatas[0].Length; MapHeight = MapData.csvDatas.Count; GameObject System = GameObject.Find("Systems"); System.GetComponent <StageScript>().MapHeight = MapHeight; //マップの高さと長さをCSVファイルから読み取る GameObject Room = gameObject; GameObject[] Terrains = new GameObject[MapChips.Length]; int ChipRooms = 0; foreach (GameObject Chip in MapChips) { if (!Chip) { ChipRooms++; } else { GameObject Terrain = new GameObject("Terrain " + ChipRooms); Terrains[ChipRooms] = Terrain; Terrains[ChipRooms].AddComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Static; CompositeCollider2D CpCol2D = Terrains[ChipRooms].AddComponent <CompositeCollider2D>(); CpCol2D.geometryType = CompositeCollider2D.GeometryType.Polygons; CpCol2D.vertexDistance = 0.16f; if (Chip.GetComponent <TileGenerate>()) { CpCol2D.sharedMaterial = Chip.GetComponent <TileGenerate>().property.physicMaterials; } Terrains[ChipRooms].layer = Chip.layer; Terrains[ChipRooms].transform.parent = Room.transform; ChipRooms++; } } //設定した地形ごとに親を設定してコンポジットコリダーを作る。 maps = new GameObject[MapLength, MapHeight]; if (setMapGlobalSize) { Camera.main.GetComponent <CameraToScript>().WorldSize = new Vector2Int(MapLength, MapHeight); } for (int height = 0; height < MapHeight; height++) { for (int lengths = 0; lengths < MapLength; lengths++) { if (Convert.ToInt32(MapData.csvDatas[height][lengths]) != -1) { Vector2 Worldpos = new Vector2((lengths - MapLength / 2f) * sprite.bounds.size.x, (MapHeight / 2f - height) * sprite.bounds.size.y); maps[lengths, height] = Instantiate(MapChips[Convert.ToInt32(MapData.csvDatas[height][lengths])], new Vector3(Worldpos.x, Worldpos.y, 5), Quaternion.Euler(0, 0, 0));; if (maps[lengths, height].GetComponent <TileGenerate>() != null) { maps[lengths, height].GetComponent <TileGenerate>().WorldPositions = new Vector2Int(lengths, height); } connectSet.SetTileConnections(maps, lengths, height, MapLength, MapHeight); maps[lengths, height].transform.parent = Terrains[Convert.ToInt32(MapData.csvDatas[height][lengths])].transform; //マップのチップごとに生成して設定。 } } } GameObject Borders = Resources.Load("PhisicallyBorder") as GameObject; GameObject DeadBorders = Resources.Load("DeadBorder") as GameObject; Vector2 Borders_Size = Borders.GetComponent <BoxCollider2D>().size; Instantiate(Borders, new Vector2(-((MapLength + 1) / 2f) * sprite.bounds.size.x - Borders_Size.x / 2, (MapHeight / 2f) * sprite.bounds.size.y), Quaternion.Euler(0, 0, 0), gameObject.transform); Instantiate(Borders, new Vector2(((MapLength - 1) / 2f) * sprite.bounds.size.x + Borders_Size.x / 2, (MapHeight / 2f) * sprite.bounds.size.y), Quaternion.Euler(0, 0, 0), gameObject.transform); Instantiate(Borders, new Vector2(0f, ((MapHeight + 1) / 2f) * sprite.bounds.size.y + Borders_Size.y / 2), Quaternion.Euler(0, 0, 0), gameObject.transform); Instantiate(DeadBorders, new Vector2(0f, -((MapHeight + 1) / 2f) * sprite.bounds.size.y - DeadBorders.GetComponent <BoxCollider2D>().size.y / 2), Quaternion.Euler(0, 0, 0), gameObject.transform); //右、左、上にボーダー生成。 下にはデッドラインボーダーを生成。 Camera.main.GetComponent <CameraToScript>().CameraInstaTransit (GameObject.Find("Systems").GetComponent <StageScript>().TransitTo, new Vector2(MapLength, MapHeight)); //カメラの即時移動。 if (IfMakeFirst_posset.x != 0 && IfMakeFirst_posset.y != 0) { GameObject.Find("Systems").GetComponent <StageScript>().TransitTo = IfMakeFirst_posset; } }
IEnumerator LightningBranch(string powerup = "") { yield return(new WaitForSeconds(0.1f)); Slot currentSlot = chip.slot; Chip nextChip; Slot nextSlot; Lightning lightning = null; int iter = 10; int count = 10; List <Chip> branch = new List <Chip>(); while (true) { if (iter <= 0 || count <= 0) { break; } nextSlot = currentSlot.nearSlot.Values.Where(x => x != null).ToList().GetRandom(); if (!nextSlot) { iter--; continue; } nextChip = nextSlot.chip; if (!nextChip || nextChip.destroying) { iter--; continue; } if (!currentSlot.chip) { iter--; continue; } if (chips.Contains(nextChip) || branch.Contains(nextChip)) { iter--; continue; } chips.Add(nextChip); branch.Add(nextChip); int id = nextChip.id; if (lightning != null) { lightning.Remove(); } lightning = Lightning.CreateLightning(0, currentSlot.chip.transform, nextChip.transform, id == Mathf.Clamp(id, 0, 5) ? Chip.colors[id] : Color.white); count--; currentSlot.chip.SetScore(0.3f); currentSlot.chip.jamType = chip.jamType; currentSlot.chip.DestroyChip(); currentSlot = nextSlot; yield return(new WaitForSeconds(0.02f)); } if (powerup != "") { bool dontDestroy = powerup == "RainbowHeart" || powerup == "UltraColorBomb"; Chip pu = FieldAssistant.main.AddPowerup(currentSlot.coord, powerup); //if (!dontDestroy) // pu.can_move = false; pu.transform.localPosition = Vector3.zero; yield return(0); while (!dontDestroy && pu != null && pu.GetComponent <Animation>().isPlaying) { yield return(0); } if (pu != null && !dontDestroy) { SessionAssistant.main.EventCounter(); pu.jamType = chip.jamType; pu.DestroyChip(); } } if (lightning != null) { lightning.Remove(); if (currentSlot.chip) { currentSlot.chip.jamType = chip.jamType; currentSlot.chip.DestroyChip(); } } branchCount--; while (branchCount > 0) { yield return(0); } yield return(0); branchCount = -1; //yield return new WaitForSeconds(0.02f); //for (int i = 0; i < branch.Count; i++) { // yield return new WaitForSeconds(0.03f); // if (branch[i].destroing || !branch[i].parentSlot) // continue; // branch[i].SetScore(0.1f); // FieldAssistant.main.BlockCrush(branch[i].parentSlot.slot.x, branch[i].parentSlot.slot.y, true); // FieldAssistant.main.JellyCrush(branch[i].parentSlot.slot.x, branch[i].parentSlot.slot.y); // if (branch[i] != chip) // branch[i].DestroyChip(); //} //branchCount--; //while (branchCount > 0) // yield return 0; //branchCount = -1; }