void ChangeChampTransform(ChampInstance champ, TileInfo landingTile) { switch (landingTile.type) { case TileHandler.TileType.SQUARE: champ.champion.transform.parent = invenObj.transform; break; case TileHandler.TileType.HEXAGON: champ.champion.transform.parent = fieldObj.transform; break; }// switch: 부모 오브젝트를 바꾼다. // 리스트 요소를 바꾼다. if (champ.standingTile.type == landingTile.type) { } else { ChangeInvenList(champ); ChangeFieldList(champ); }// if: [인벤 -> 필드, 필드 -> 인벤] 같은 경우에는 리스트를 옮긴다. // 필드 카운트를 업데이트 한다. if (unitCount.objList != default) { unitCount.UpdateFieldCnt(field.Count); } // 위치를 바꾼다. champ.champion.transform.position = landingTile.tile.transform.position; champ.standingTile.isEmpty = true; champ.standingTile = landingTile; champ.standingTile.isEmpty = false; }
private void Awake() { tileHandler = MyFunc.GetObject(MyFunc.ObjType.TILE_CONTAINER).GetComponent <TileHandler>(); detectedTile = new TileHandler.TileInfo(); isChest = false; }
public void MoveChamp(GameObject champion, TileInfo landingTile) { ChampInstance sour = FindChampFromInstance(champion); ChangeChampTransform(sour, landingTile); }
public void SwapChamp(TileInfo landingTile, TileInfo standingTile) { ChampInstance sour = FindChampFromTile(standingTile); ChampInstance dest = FindChampFromTile(landingTile); ChangeChampTransform(sour, landingTile); ChangeChampTransform(dest, standingTile); }
private void Awake() { unitObj = transform.parent.parent.gameObject; tileHandler = MyFunc.GetObject(MyFunc.ObjType.TILE_CONTAINER).GetComponent <TileHandler>(); landingTile = new TileHandler.TileInfo(); tileFinderObj = unitObj.transform.Find("TileFinder").gameObject; posCorrectionZ = 2.4f; posCorrectionX = 1.5f; cameraCorrectionX = 0.05f; cameraCorrectionZ = 0.0415f; }
void DetectTile(Collider other) { switch (LayerMask.LayerToName(other.gameObject.layer)) { case "InvenTile": detectedTile = tileHandler.FindTile(invenTiles, other.transform.parent.gameObject); break; case "FieldTile": detectedTile = tileHandler.FindTile(fieldTiles, other.transform.parent.gameObject); break; case "Shop": isChest = true; break; } }
public IEnumerator AutoReturnChamp(bool isReverse = false) { int loopCnt = 0; ChampInstance returnChamp = new ChampInstance(); TileInfo emptyInven = new TileInfo(); if (unitCount.currentField > unitCount.maxUnit) { loopCnt = unitCount.currentField - unitCount.maxUnit; for (int i = 0; i < loopCnt; i++) { emptyInven = default; yield return(new WaitForSeconds(Time.deltaTime)); foreach (var ele in field) { returnChamp = ele; break; } foreach (var ele in _squareTiles) { if (ele.isEmpty) { emptyInven = ele; break; } } // 인벤을 다 찾아도 빈곳이 없다면 챔피언을 강제로 판다 if (emptyInven != default) { if (isReverse) { RotationY(returnChamp); } MoveChamp(returnChamp.champion, emptyInven); } else { SellChampToList(returnChamp); } } // loop: 넘치는 만큼 챔피언을 인벤에 되돌린다. } // if: 현재 필드가 넘친다면 }
public IEnumerator AutoThrowChampToField(bool isReverse = false) { int loopCnt = 0; ChampInstance throwChamp = default; TileInfo emptyField = new TileInfo(); if (field.Count < unitCount.maxUnit) { loopCnt = unitCount.maxUnit - field.Count; for (int i = 0; i < loopCnt; i++) { throwChamp = default; yield return(new WaitForSeconds(Time.deltaTime)); foreach (var ele in inven) { throwChamp = ele; break; } foreach (var ele in _hexaTiles) { if (ele.isEmpty) { emptyField = ele; break; } } // 인벤을 다 찾아도 챔피언이 없다면 break if (throwChamp != default) { if (isReverse) { RotationY(throwChamp); } MoveChamp(throwChamp.champion, emptyField); } else { break; } } // loop: 모자란 만큼 챔피언을 필드에 던진다. } // if: 현재 필드가 모자라다면 }
void SetupLandingTile() { landingTile = tileFinder.detectedTile; }
private void OnTriggerExit(Collider other) { detectedTile = default; isChest = false; }