private void CreateTotems() { for (int i = 0; i < cols; i++) { Transform newTotemTF = Instantiate(totem, new Vector3(i * totemSpacing, 0, 0), Quaternion.LookRotation(Vector3.back)) as Transform; Totem newTotem = newTotemTF.gameObject.GetComponent <Totem> (); newTotem.Init(this, rows, i); } }
override public void TriggerEffect() { //풀링 안되어 있으면 함. GameObject summonObj = Battle.GetObjectInPool(skillEvent.summonObject.name); if (!summonObj) { summonObj = GameObject.Instantiate(skillEvent.summonObject, skill.owner.transform.position, Quaternion.identity, skill.owner.transform.parent) as GameObject; summonObj.transform.localPosition = Vector3.zero; summonObj.name = skillEvent.summonObject.name; //summonObj.GetComponent<Totem>().Init(owner); if (!summonObj.GetComponent <BattleGroupElement>()) { summonObj.AddComponent <BattleGroupElement>(); } Battle.AddObjectToPool(summonObj); } if (!summonObj) { return; } summonObj.SetActive(false); //랜덤한 위치, 배경에서 삐져나가지 않게 스폰 float posX = UnityEngine.Random.Range(-1f, 1f); float posY = UnityEngine.Random.Range(-1f, 1f); Vector3 pos = skill.owner.transform.position + new Vector3(posX, posY, skill.owner.transform.position.z); BoxCollider unitArea = skill.owner.battleGroup.GetComponentInChildren <BoxCollider>(); pos.y = Mathf.Clamp(pos.y, unitArea.bounds.min.y, unitArea.bounds.max.y); summonObj.transform.position = pos; if (skill.castTarget) { summonObj.transform.position = skill.castTarget.transform.position; } Totem t = summonObj.GetComponent <Totem>(); if (t) { t.lifeTime = skill.skillData.summonTime; t.Init(skill.owner); } bool isNecromancy = skill.skillData.summonID.Contains("Skeleton"); bool isDoppelganger = skill.skillData.summonID.Contains("Ninja"); BattleHero hero = summonObj.GetComponent <BattleHero>(); if (hero) { hero.team = skill.owner.team; HeroData hData = null; if (!string.IsNullOrEmpty(skill.skillData.summonID) && HeroManager.heroBaseDataDic.ContainsKey(skill.skillData.summonID)) { hData = new HeroData(HeroManager.heroBaseDataDic[skill.skillData.summonID]); } Stat attackPower = skill.owner.stats.GetParam(StatType.AttackPower); //강령술 하드코딩. 시전자 공격력에 영향 받아서 hp, 공격력 결정 if (isNecromancy) { hero.master = skill.owner; hData.baseData.maxHP = 1; /*attackPower.value * 2*/; // (int)(skill.owner.attackPower * 2f); hData.baseData.attackPower = (int)(attackPower.value * 0.1f); // (int) (skill.owner.attackPower * 0.1f); //강령술로 소환한 애들은 부활 불가 hero.canResurrect = false; //강령술 대상이 된 애들도 부활 불가 if (skill.castTarget) { skill.castTarget.canResurrect = false; } } hero.lifeTime = skill.skillData.summonTime; hero.Init(skill.owner.battleGroup, hData, skill.owner.team); Stat statMaxHP = hero.stats.GetParam(StatType.MaxHP); if (statMaxHP != null) { statMaxHP.baseValue = attackPower.value * 2; } Stat statCurHP = hero.stats.GetParam(StatType.CurHP); statCurHP.value = statMaxHP.value; if (!isNecromancy) { hero.isFinishSpawned = true; } if (isDoppelganger) { hero.master = skill.owner; statMaxHP.value = 1d; statCurHP.value = statMaxHP.value; Stat statAttackPower = hero.stats.GetParam(StatType.AttackPower); statAttackPower.value = attackPower.value; hero.canResurrect = false; } //소환물 설정 hero.isSummonded = true; } //소환된 애 오브젝트 활성 summonObj.SetActive(true); summonObj.GetComponent <BattleGroupElement>().SetBattleGroup(skill.owner.battleGroup); if (hero) { if (hero.team == BattleUnit.Team.Red) { skill.owner.battleGroup.redTeamList.Add(hero); } else if (hero.team == BattleUnit.Team.Blue) { skill.owner.battleGroup.blueTeamList.Add(hero); } if (isNecromancy) { hero.skeletonAnimation.enabled = true; //Debug.Log(hero.skeletonAnimation.state.GetCurrent(0)); hero.skeletonAnimation.state.ClearTrack(0); hero.skeletonAnimation.state.SetAnimation(0, "Resurrect", false); //hero.skeletonAnimation.state.Interrupt += OnInterruptResurrect; hero.skeletonAnimation.state.AddAnimation(0, hero.idleAnimation, true, 0f); //hero.StartCoroutine(CheckFinishResurrect(hero)); } if (isDoppelganger) { //분신 위치 조정 if (skill.owner.summonCount > 0) { Vector3 summonPos = skill.owner.transform.position; summonPos.x += -3f; summonObj.transform.position = summonPos; } else { Vector3 summonPos = skill.owner.transform.position; summonPos.x += 3f; summonObj.transform.position = summonPos; } hero.skeletonAnimation.enabled = true; hero.skeletonAnimation.state.ClearTrack(0); hero.skeletonAnimation.state.SetAnimation(0, "Skill_Clone", false); hero.skeletonAnimation.state.AddAnimation(0, hero.idleAnimation, true, 0f); hero.spineAnimationDie = hero.skeletonAnimation.SkeletonDataAsset.GetAnimationStateData().skeletonData.FindAnimation("Die_Clone"); } } skill.owner.summonCount += 1; if (skill.onTriggerEvent != null) { skill.onTriggerEvent(skill, skillEvent); } }