public void InitBombExplode(EExplodeEffectType bomb_type, int index, float life_time) { mIndex = index; mLifeTime = life_time; mBombType = bomb_type; mEnd = false; // BombExplode 생성 시점은 Bomb과 같음, 랜더링은 나중에 this.GetComponent<SpriteRenderer>().enabled = false; }
GameObject StartBombEffect(int index, EExplodeEffectType bomb_type, float life_time) { // ObjectPool 할당 GameObject obj = Push(BombExplode); // 생성된 Object를 "ExpectedMap"에 미리 맵에 등록 if (!mExpectedBomExplodebMap.ContainsKey(index)) { mExpectedBomExplodebMap[index] = new List <BombExplode>(); } mExpectedBomExplodebMap[index].Add(obj.GetComponent <BombExplode>()); // 위치 Vector3 pos = TileMap.IndexToPos(index); obj.transform.position = pos; // 초기화 ("Run" 아님) obj.SetActive(true); obj.GetComponent <BombExplode>().InitBombExplode(bomb_type, index, life_time); return(obj); }
void SetDirBombEffect(int center_index, EDirection dir, int bomb_size, float life_time) { bool encounter_obstacle = false; for (int i = 1; i <= bomb_size; i++) { int index = center_index; int rot = 0; switch (dir) { case EDirection.Left: index = center_index - i; if (index / Const.TileCntX != center_index / Const.TileCntX) { return; // 가로 폭탄은 같은 층에서만 } rot = 270; break; case EDirection.Right: index = center_index + i; if (index / Const.TileCntX != center_index / Const.TileCntX) { return; // 가로 폭탄은 같은 층에서만 } rot = 90; break; case EDirection.UP: index = center_index + Const.TileCntX * i; rot = 0; break; case EDirection.Down: index = center_index - Const.TileCntX * i; rot = 180; break; } // 막힌 구간 만나면 더이상 Bomb Eplode를 생성하지 않는다. if (SystemManager.GetComponent <TileMap>().IsBlocked(index)) { return; } // 가장자리 애니메이션 적용 여부 EExplodeEffectType bomb_type = EExplodeEffectType.BombDir; if (i == bomb_size) { bomb_type = EExplodeEffectType.BombEnd; } // BombEffect 생성 GameObject obj = StartBombEffect(index, bomb_type, life_time); if (obj == null) { return; } // 방향 obj.transform.rotation = Quaternion.Euler(0, 0, rot); } }