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; }
void SetupMySide() { foreach (var ele in playerInven.field) { if (transform.parent.gameObject == ele.champion) { mySide = MySide.PLAYER; enemyList = computerInven.field; unit = playerInven.FindChampFromInstance(unitObj); unit.VisibleHpBar(true); unit.hpBar.color = Color.green; unit.hpBar.fillAmount = 1.0f; break; } } foreach (var ele in computerInven.field) { if (transform.parent.gameObject == ele.champion) { mySide = MySide.COMPUTER; enemyList = playerInven.field; unit = computerInven.FindChampFromInstance(unitObj); unit.VisibleHpBar(true); unit.hpBar.color = Color.red; unit.hpBar.fillAmount = 1.0f; break; } } }
IEnumerator LevelUpPlay(ChampInstance target) { target.levelUp.Play(); yield return(new WaitForSeconds(1.0f)); target.levelUp.Stop(); }
ChampInstance FindQualityUpChamp() { ChampInstances sameList = default; ChampInstance result = default; bool findOk = false; foreach (var ele in inven) { sameList = FindSimilarChamps(ele); if (sameList.Count >= 3) { result = ele; findOk = true; break; } }// loop: 같은 챔프가 3 이상 있으면 탐색을 종료한다. if (findOk) { foreach (var ele in sameList) { if (ele.standingTile.type == TileHandler.TileType.HEXAGON) { result = ele; break; } } }// if: 필드에 있는 것을 우선 리턴한다. return(result); }
ChampInstances FindSimilarChamps(ChampInstance target) { ChampInstances similarList = default; if (target != default) { similarList = new ChampInstances(); foreach (var ele in inven) { if (IsSimilarChamp(target, ele)) { similarList.Add(ele); } } foreach (var ele in field) { if (IsSimilarChamp(target, ele)) { similarList.Add(ele); } } similarList.Add(target); } return(similarList); }
private void OnTriggerEnter(Collider other) { if (other.gameObject.layer == LayerMask.NameToLayer("Unit")) { foreach (var ele in enemyList) { if (other.transform.parent.parent.gameObject == ele.champion) { isEnemyInRange = true; switch (mySide) { case MySide.COMPUTER: target = playerInven.FindChampFromInstance( other.transform.parent.parent.gameObject); break; case MySide.PLAYER: target = computerInven.FindChampFromInstance( other.transform.parent.parent.gameObject); break; } break; } } } }
IEnumerator AttackTarget() { while ((target != default && target.hp > 0) && (unit != default && unit.hp > 0)) { unitObj.transform.LookAt(target.champion.transform); myAni.SetTrigger("Attack"); if (unit.champType == ChampionPool.ChampType.WIZZARD) { unit.wizzardEffect.Play(); StartCoroutine(StopWizzardEffect()); } yield return(new WaitForSeconds(1.0f)); try { target.Hit(unit.damage); } catch (System.NullReferenceException e) { break; } } // 피가 다 닳면 죽는다. if (target != default && target.hp <= 0) { SetupTarget(); }// if: 적이 죽음 else { target = default; }// if: 내가 죽음 }
private void Start() { benchmarkPos = tileHandler.squareInstances[4].tile.transform.position; tileFinder = tileFinderObj.GetComponent <TileFinder>(); inven = MyFunc.GetObject(MyFunc.ObjType.INVENTORY).GetComponent <Inventory>(); unit = inven.FindChampFromInstance(unitObj); }
public void MoveChamp(GameObject champion, TileInfo landingTile) { ChampInstance sour = FindChampFromInstance(champion); ChangeChampTransform(sour, landingTile); }
static void SetupChampType(ChampInstance champ) { string key = champ.name.Split(' ')[1]; switch (key) { case "Archer": champ.champType = ChampType.ARCHER; champ.maxHp = 100; champ.hp = champ.maxHp; champ.range = 10; champ.damage = 5; break; case "Wizzard": champ.champType = ChampType.WIZZARD; champ.maxHp = 100; champ.hp = champ.maxHp; champ.range = 5; champ.damage = 10; break; case "Knight": champ.champType = ChampType.KNIGHT; champ.maxHp = 200; champ.hp = champ.maxHp; champ.range = 2; champ.damage = 5; break; } }
private void OnMouseDown() { unit = inven.FindChampFromInstance(unitObj); if (unit != default && unit.isClickOk) { tileFinderObj.SetActive(true); } }
public void SwapChamp(TileInfo landingTile, TileInfo standingTile) { ChampInstance sour = FindChampFromTile(standingTile); ChampInstance dest = FindChampFromTile(landingTile); ChangeChampTransform(sour, landingTile); ChangeChampTransform(dest, standingTile); }
bool ChangeFieldList(ChampInstance champ) { foreach (var ele in field) { if (ele == champ) { field.Remove(ele); return(true); } } field.Add(champ); return(true); }
public void SellChampToList(ChampInstance champ) { switch (champ.standingTile.type) { case TileHandler.TileType.SQUARE: RemoveChampToList(champ, inven); break; case TileHandler.TileType.HEXAGON: RemoveChampToList(champ, field); break; } gold.AddGold(2); }
// 켜지는 순간 target을 정하고 걸어간다. private void Awake() { playerInven = MyFunc.GetObject(MyFunc.ObjType.INVENTORY).GetComponent <Inventory>(); computerInven = MyFunc.GetObject(MyFunc.ObjType.ENEMY). transform.Find("Inventory").GetComponent <Inventory>(); target = default; enemyList = default; unitObj = transform.parent.gameObject; unit = default; myAni = transform.parent.Find("character").GetComponent <Animator>(); isEnemyInRange = false; moveSpeed = 1.0f; attackSpeed = 1.0f; }
bool ChangeInvenList(ChampInstance champ) { foreach (var ele in inven) { if (ele == champ) { inven.Remove(ele); return(true); } }// loop: 존재하면 지운다. // 없으면 추가한다. inven.Add(champ); return(true); }
public bool IsQualityUpPossible() { ChampInstance champ = default; champ = FindQualityUpChamp(); if (champ != default) { return(true); } else { return(false); } }
public bool IntoInventory(string champName, bool isClickOk = false) { ChampInstance champ = default; if (IsRemainInven() == false) { return(false); } // 풀에서 요청 -> 인벤에 삽입 champ = ChampionPool.instance.GetChamp(champName); champ.champion.transform.parent = invenObj.transform; champ.isClickOk = isClickOk; CollocateChamp(champ); inven.Add(champ); return(true); }
/// <summary> /// 챔피언 구매시 빈 인벤토리 슬롯에 챔프를 배치하는 함수 /// </summary> /// <param name="champ">상점에서 구입한 챔프</param> void CollocateChamp(ChampInstance champ) { UnitHandler unitHandler = champ.champion.GetComponentInChildren <UnitHandler>(); // 빈 인벤토리 슬롯 찾아서 챔프를 옮긴다. foreach (var ele in _squareTiles) { if (ele.isEmpty) { champ.champion.transform.position = ele.tile.transform.position; champ.standingTile = ele; champ.standingTile.isEmpty = false; champ.champion.SetActive(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: 현재 필드가 모자라다면 }
static void SetupAttackType(ChampInstance champ) { string key = champ.name.Split(' ')[0]; switch (key) { case "Fire": champ.attackType = AttackType.FIRE; break; case "Frost": champ.attackType = AttackType.FROST; break; case "Nature": champ.attackType = AttackType.NATURE; break; } }
void RemoveChampToList(ChampInstance champ, ChampInstances list) { ChampInstance returnChamp = default; foreach (var ele in list) { if (ele == champ) { returnChamp = ele; list.Remove(ele); break; } } if (unitCount.objList != default) { unitCount.UpdateFieldCnt(field.Count); } ChampionPool.instance.GetBackChamp(returnChamp); }
public void QualityUpChampion() { ChampInstance target = default; ChampInstances sameList = default; target = FindQualityUpChamp(); sameList = FindSimilarChamps(target); if (target != default) { int count = 0; foreach (var ele in sameList) { if (target == ele) { } else { if (count >= 2) { break; } else { if (ele.standingTile.type == TileHandler.TileType.HEXAGON) { RemoveChampToList(ele, field); } else if (ele.standingTile.type == TileHandler.TileType.SQUARE) { RemoveChampToList(ele, inven); } count++; } }// if: 필드에 있는 유닛을 우선 타겟팅한다. } QualityUp(target); } }
void SetupTarget() { if (enemyList != default && enemyList.Count > 0) { foreach (var ele in enemyList) { if (ele.hp > 0) { target = ele; break; } } } else { target = default; } if (target.hp <= 0) { target = default; } }
bool QualityUp(ChampInstance target) { GameObject character = default; GameObject tileFinder = default; if (target == default) { return(false); } if (target.quality < 3) { // 능력치가 좋아짐 target.maxHp *= 2; target.hp = target.maxHp; target.damage *= 2; // 크기가 커짐 float multiple = 1.5f; // 얼마나 커지는지 Vector3 scale = default; character = target.champion.transform.Find("character").gameObject; tileFinder = target.champion.transform.Find("TileFinder").gameObject; scale = character.transform.localScale; scale = new Vector3( scale.x * Mathf.Pow(multiple, target.quality), scale.y * Mathf.Pow(multiple, target.quality), scale.z * Mathf.Pow(multiple, target.quality)); character.transform.localScale = scale; target.quality++; // 파티클 재생 StartCoroutine(LevelUpPlay(target)); return(true); } return(false); }
void RotationY(ChampInstance champ) { champ.champion.transform.Rotate(new Vector3(0, 180, 0)); }
static public void SetupChampInfo(ChampInstance champ) { SetupChampType(champ); SetupAttackType(champ); }