Example #1
0
    IEnumerator CreateBattleHero()
    {
        BattleHero battleHero = null;

        yield return(StartCoroutine(GetHero(heroID, x => battleHero = x)));

        battleHero.gameObject.SetActive(true);

        HeroData hero = CreateHeroData();

        battleHero.team = BattleUnit.Team.Red;
        battleHero.Init(null, hero);
        battleHero.ReGen();
        battleHeroList.Add(battleHero);

        coroutine = null;
    }
Example #2
0
    //IEnumerator CloseAfterRun()
    //{

    //    for (int i = 0; i < heroSelectSlotList.Count; i++)
    //    {
    //        if (heroSelectSlotList[i].battleHero != null)
    //            heroSelectSlotList[i].battleHero.skeletonAnimation.state.SetAnimation(0, heroSelectSlotList[i].battleHero.runAnimation, true);
    //    }

    //    yield return new WaitForSeconds(1.7f);
    //}


    /// <summary> 영웅 출전 </summary>
    IEnumerator StartExploration()
    {
        bool isNewBattle = Battle.currentBattleGroup.battleType != battleGroupID;

        //던전 아이디
        //string dungeonID = Battle.currentBattleGroupID;

        //선택된 영웅을 해당 씬에 배치하면서 전투 시작
        if (selectedHeroDataList == null || selectedHeroDataList.Count == 0)
        {
            Debug.Log("선택한 영웅이 없습니다.");
            yield break;
        }

        for (int i = 0; i < heroSelectSlotList.Count; i++)
        {
            if (heroSelectSlotList[i].battleHero != null)
            {
                heroSelectSlotList[i].battleHero.skeletonAnimation.state.SetAnimation(0, heroSelectSlotList[i].battleHero.spineAnimationRun /*runAnimation*/, true);
            }
        }


        //yield return new WaitForSeconds(2.2f);

        for (int i = 0; i < selectedHeroDataList.Count; i++)
        {
            HeroData d = HeroManager.heroDataDic[selectedHeroDataList[i].id];
            d.battleGroupID = battleGroupID;
            //d.isUsing = true;
        }

        //리스트 새로 만들어서 배틀그룹 생성
        List <HeroData> heroList = new List <HeroData>(selectedHeroDataList);

        if (isNewBattle)
        {
            UIFadeController.FadeOut(1f);

            while (!UIFadeController.isFinishFadeOut)
            {
                yield return(null);
            }
        }

        //Battle.CreateBattleGroup(battleGroupID, heroList);

        BattleGroup battleGroup = Battle.battleGroupList.Find(x => x.battleType == battleGroupID);

        //새로운 배틀그룹 생성
        if (!battleGroup)
        {
            Battle.CreateBattleGroup(battleGroupID, heroList);

            battleGroup = Battle.battleGroupList.Find(x => x.battleType == battleGroupID);

            while (!battleGroup.isInitialized)
            {
                yield return(null);
            }
        }
        //기본 배틀그룹의 멤버 변경
        else
        {
            //기존 멤버중 없던애는 배틀 그룹에 새로 추가 & 스폰
            for (int i = 0; i < heroList.Count; i++)
            {
                //기존 멤버는 가만히 냅둠
                if (battleGroup.originalMember.Find(x => x.heroData == heroList[i]))
                {
                    continue;
                }

                BattleHero battleHero = null;
                yield return(StartCoroutine(actorPool.Instance.GetActor(heroList[i].heroID, x => battleHero = x)));

                if (!battleHero)
                {
                    continue;
                }

                battleHero.team = BattleUnit.Team.Red;
                battleHero.Init(battleGroup, heroList[i]);
                battleHero.gameObject.SetActive(true);
                battleHero.ReGen();

                battleGroup.redTeamList.Add(battleHero);
                battleGroup.originalMember.Add(battleHero);
            }

            //기존 멤버 중 제외된 애는 배틀그룹에서 제외
            for (int i = battleGroup.originalMember.Count - 1; i >= 0; i--)
            {
                HeroData heroData = heroList.Find(x => x == battleGroup.originalMember[i].heroData);
                if (heroData != null)
                {
                    continue;
                }

                BattleHero h = battleGroup.originalMember[i];
                h.heroData.battleGroupID = string.Empty;
                h.Despawn();
                //battleGroup.originalMember[i].SetBattleGroup(null);
                //battleGroup.originalMember[i].gameObject.SetActive(false);
                battleGroup.originalMember.Remove(h);
                battleGroup.redTeamList.Remove(h);

                //h.heroData.battleGroupID = string.Empty;
                //h.Despawn();
            }

            //데이타 저장
            Battle.SaveStageInfo(battleGroup);
        }


        //Battle.ShowBattle(battleGroupID);

        //이렇게 안 하면 가장 마지막에 봤던 전투그룹으로 돌아가서 출전 후 다른 전투그룹이 비쳐짐
        Battle.lastBattleGroupID = battleGroupID;

        //전투 화면으로 돌아가고 창 닫기
        SceneLobby.Instance.SceneChange(LobbyState.Battle);
        Close();

        //한프레임 쉬어야 프리킹 현상 없음
        yield return(null);

        //페이드 인
        if (isNewBattle)
        {
            UIFadeController.FadeIn(1f);
        }
    }
Example #3
0
    public IEnumerator InitCoroutine(BattleGroup battleGroup, BattleUnit.Team team = BattleUnit.Team.Red, List <HeroData> heroList = null)
    {
        while (actorList.Count > 0)
        {
            actorList[0].onDie -= OnDie;
            actorList[0].Despawn();
            yield return(null);
        }
        deadTeamMemberCount = 0;
        teamMemberCount     = 0;

        if (heroList == null)
        {
            yield break;
        }
        teamMemberCount = heroList.Count;

        for (int i = 0; i < teamMemberCount; i++)
        {
            BattleHero battleHero = null;
            yield return(StartCoroutine(actorPool.Instance.GetActor(heroList[i].heroID, x => battleHero = x)));

            if (!battleHero)
            {
                continue;
            }

            battleHero.team = team;
            if (battleGroup.battleType == BattleGroup.BattleType.PvP)
            {
                battleHero.InitPvP(battleGroup, heroList[i]);
            }
            else if (battleGroup.battleType == BattleGroup.BattleType.Normal)
            {
                battleHero.Init(battleGroup, heroList[i]);
            }

            battleHero.gameObject.SetActive(true);
            battleHero.ReGen();
            battleHero.onDie += OnDie;

            actorList.Add(battleHero);
        }


        //스테이지 시작 trigger인 버프 적용하기
        for (int i = 0; i < actorList.Count; i++)
        {
            BattleHero hero = actorList[i];
            for (int a = 0; a < hero.buffController.buffList.Count; a++)
            {
                Buff buff = hero.buffController.buffList[a];
                if (buff.baseData.trigger != "OnStartStage")
                {
                    continue;
                }

                if (buff.triggerProbability < UnityEngine.Random.Range(1, 10001))
                {
                    continue;
                }

                BattleUnit target = null;
                if (buff.baseData.triggerTarget == "SkillTarget")
                {
                    target = hero;
                }
                else if (buff.baseData.triggerTarget == "BuffTarget")
                {
                    target = hero;
                }

                if (target && !target.isDie)
                {
                    target.buffController.AttachBuff(hero, buff.baseData.triggerBuff, 1, buff);
                }
            }
        }
    }
Example #4
0
    override public void TriggerEffect()
    {
        //타겟 고르기
        skill.CollectTargets();
        //Debug.Log("타겟 초기화");
        if (skill.targetList == null || skill.targetList.Count == 0)
        {
            if (skill.onTriggerEvent != null)
            {
                skill.onTriggerEvent(skill, skillEvent);
            }

            return;
        }

        for (int i = 0; i < skill.targetList.Count; i++)
        {
            BattleHero target = skill.targetList[i];

            //타격 이펙트
            if (skillEvent != null && skillEvent.hitEffect)
            {
                GameObject hitEffectObj = Battle.GetObjectInPool(skillEvent.hitEffect.name);

                //풀링 안되어 있으면 함.
                if (!hitEffectObj)
                {
                    hitEffectObj      = GameObject.Instantiate(skillEvent.hitEffect, target.transform.position, Quaternion.identity, skill.owner.transform.parent) as GameObject;
                    hitEffectObj.name = skillEvent.hitEffect.name;
                    //hitEffectObj.AddComponent<SelfDestroyParticle>();
                    hitEffectObj.SetActive(false);
                    hitEffectObj.AddComponent <BattleGroupElement>();

                    Battle.AddObjectToPool(hitEffectObj);
                }

                if (hitEffectObj)
                {
                    //Vector3 hitPos = target.GetClosestPoint(skill.owner.transform.position);
                    Vector3 hitPos = target.collider.transform.position;// .GetClosestPoint(skill.owner.transform.position);
                    hitEffectObj.transform.position = hitPos;
                    if (skillEvent.attachToTarget)
                    {
                        hitEffectObj.transform.SetParent(target.transform);
                    }

                    hitEffectObj.transform.localScale = Vector3.one;

                    //캐릭터 위치에 따라 뒤집기
                    if (skill.owner is BattleHero)
                    {
                        BattleHero h      = skill.owner as BattleHero;
                        bool       isFlip = h.flipX;
                        float      x      = isFlip ? -1f : 1f;
                        hitEffectObj.transform.localScale = new Vector3(x, 1f, 1f);
                    }


                    //히트 파티클 오브젝트 활성
                    hitEffectObj.SetActive(true);
                    hitEffectObj.GetComponent <BattleGroupElement>().SetBattleGroup(skill.owner.battleGroup);

                    OrderController orderControllerA = hitEffectObj.GetComponent <OrderController>();
                    OrderController orderControllerB = target.GetComponent <OrderController>();
                    if (orderControllerA)
                    {
                        if (orderControllerB)
                        {
                            orderControllerA.parent = orderControllerB;
                        }
                        else
                        {
                            orderControllerA.parent = null;
                        }
                    }

                    ParticleSystem p = hitEffectObj.GetComponentInChildren <ParticleSystem>();
                    if (p)
                    {
                        p.Play();
                    }

                    Animation anim = hitEffectObj.GetComponentInChildren <Animation>();
                    if (anim)
                    {
                        anim.Play();
                    }
                }
            }

            bool isSuccessHit = false;

            //대상한테 데미지 적용. 힐은 피 채워줌
            if (!string.IsNullOrEmpty(skill.skillData.power))
            {
                double damageModifyType = 0d;
                if (skill.skillData.damageType == SkillBase.DamageType.Physical)
                {
                    damageModifyType = skill.owner.master.stats.GetValueOf(StatType.AttackPowerPhysical);
                }
                else if (skill.skillData.damageType == SkillBase.DamageType.Magical)
                {
                    damageModifyType = skill.owner.master.stats.GetValueOf(StatType.AttackPowerMagical);
                }

                double damageModifyRange = 0d;
                if (skill.skillData.rangeType == SkillBase.RangeType.Melee)
                {
                    damageModifyRange = skill.owner.master.stats.GetValueOf(StatType.AttackPowerMelee);
                }
                else if (skill.skillData.rangeType == SkillBase.RangeType.Range)
                {
                    damageModifyRange = skill.owner.master.stats.GetValueOf(StatType.AttackPowerRange);
                }

                double power = skill.GetPower(target) * (1 + damageModifyType * 0.0001d) * (1 + damageModifyRange * 0.0001d);

                //if (skill.owner.master.heroData.baseData.id.Contains("Centaur"))
                //    Debug.Log(power + ", " + skill.GetPower(target) + ", " + damageModifyType + ", " + damageModifyRange);

                if (skill.skillData.effectType == "Heal")
                {
                    target.Damage(skill.owner.master, -power, SkillBase.DamageType.Pure, skill, "Heal");
                }
                else if (skill.skillData.effectType == "Resurrect")
                {
                    target.Damage(skill.owner.master, -power, SkillBase.DamageType.Pure, skill, "Resurrect");
                    BattleHero h = target as BattleHero;
                    h.ReGen(true);
                }
                else
                {
                    //콜라 - 수호자 버프 처리
                    List <Buff> buffGuardList = target.buffController.buffList.FindAll(x => x.id == "Buff_Knight_Passive" &&
                                                                                       x.target == target && x.owner != target && !x.owner.isDie);
                    if (buffGuardList != null && buffGuardList.Count > 0)
                    {
                        int count = buffGuardList.Count;
                        for (int a = 0; a < count; a++)
                        {
                            //수호자들끼리 30%만큼 피해를 나눠서 받음
                            buffGuardList[a].owner.Damage(skill.owner.master, power * 0.3d * 1 / count, skill.skillData.damageType, skill, "Guard");
                        }

                        //직접 얻어 맞은애는 70%
                        isSuccessHit = target.Damage(skill.owner.master, power * 0.7d, skill.skillData.damageType, skill);
                    }
                    else
                    {
                        isSuccessHit = target.Damage(skill.owner.master, power, skill.skillData.damageType, skill);
                    }

                    //대상 흔들림
                    if (isSuccessHit && skill.skillData.forceType == SkillBase.ForceType.Shake)
                    {
                        target.Shake(0.4f, 0.15f, 0.03f);
                    }
                }
            }

            if (skill.skillData.effectType == "Trail_End")
            {
                skill.owner.GetComponentInChildren <EffectTrail>().OffEffect();
            }


            if (skill.skillData.forceType == SkillBase.ForceType.Dash)
            {
                if (skill.skillData.forcePower != 0f)
                {
                    float force = skill.skillData.forcePower;

                    Vector2 point = new Vector2(target.transform.position.x + force, target.transform.position.y);
                    target.Dash(point, 1);
                }
            }

            // 밀기
            if (skill.skillData.forceType == SkillBase.ForceType.Push)
            {
                if (skill.skillData.forcePower != 0f)
                {
                    float force = skill.skillData.forcePower;

                    //대상이 왼쪽에 있는 경우 반대로 함
                    if (target.transform.position.x < skill.transform.position.x)
                    {
                        force = -force;
                    }

                    //Debug.Log("force : " + force);
                    target.addedForce += (Vector3.right * force);
                    //Debug.Log("force : " + force);
                }
                //target.Knockback2(skill, skill.skillData.forcePower);
            }

            if (skill.skillData.forceType == SkillBase.ForceType.Pull)
            {
                float force = skill.skillData.forcePower;
                float filp  = Random.Range(2.5f, 3.5f);
                float y     = Random.Range(-1f, 1f);
                //대상이 왼쪽에 있는 경우 반대로 함
                if (target.transform.position.x < skill.transform.position.x)
                {
                    filp = -filp;
                }
                Vector2 point = new Vector2(skill.owner.master.transform.position.x + filp, skill.owner.master.transform.position.y + y);
                //Debug.Log(target.heroData.heroName + " 끌려옴");
                target.Pull(point, 1);
            }
            else if (skill.skillData.forceType == SkillBase.ForceType.Knockback)
            {
                // 표현이 넉백에 가까움..
                //밀어내기/당기기 효과
                if (skill.skillData.forcePower != 0f)
                {
                    float force = skill.skillData.forcePower;

                    //대상이 왼쪽에 있는 경우 반대로 함
                    if (target.transform.position.x < skill.transform.position.x)
                    {
                        force = -force;
                    }

                    target.addedForce += Vector3.right * force;
                }
            }
            else if (skill.skillData.forceType == SkillBase.ForceType.Knockback2)
            {
                target.Knockback2(skill, skill.skillData.forcePower);
            }
            else if (skill.skillData.forceType == SkillBase.ForceType.Airborne)
            {
                target.Airborne(skill, skill.skillData.forcePower);
            }
            else if (skill.skillData.forceType == SkillBase.ForceType.FallDown)
            {
                target.FallingDown(skill, skill.skillData.forcePower);
            }

            //버프 적용
            int r = UnityEngine.Random.Range(0, 10000);
            if (r <= skill.skillData.buffProbability)
            {
                target.buffController.AttachBuff(skill.owner.master, skill.skillData.buffID, skill.skillData.buffStack);
            }


            if (!isSuccessHit)
            {
                continue;
            }
        }

        if (skill.onTriggerEvent != null)
        {
            skill.onTriggerEvent(skill, skillEvent);
        }

        OnTrailEnd();
    }