Exemple #1
0
    public void InitializeProjectileNormalBehavior(BaseCharacter spellCaster)
    {
        curTargetStat = TargetStats.health;
        curTargetType = TargetType.UnitOnly;
        curSkillOwner = spellCaster.teamType;

        skillInformation = new BaseSkillInformationData();
        skillInformation.targetInflictedCount = -UnityEngine.Random.Range(spellCaster.unitInformation.minDamage, spellCaster.unitInformation.maxDamage);
        skillInformation.targetStats          = TargetStats.health;
        skillInformation.targetType           = TargetType.UnitOnly;
        skillInformation.targetAlive          = true;

        targetPos = spellCaster.myMovements.currentTargetPoint.transform.position;

        if (targetPos.x > transform.position.x)
        {
            projectileVisualSprite.flipX = true;
        }
        else
        {
            projectileVisualSprite.flipX = false;
        }

        startMoving = true;
    }
Exemple #2
0
        public void SetAsSkill()
        {
            currentSkill = myController.currentHero.skillsList[skillIdx];

            if (currentSkill.isOnCooldown)
            {
                SetOnCooldown();
            }

            if (BattlefieldSpawnManager.GetInstance != null)
            {
                skillIcon.sprite = BattlefieldSpawnManager.GetInstance.unitStorage.GetSkillIcon(currentSkill.skillName);
            }
        }
Exemple #3
0
    public void InitializeTileUnitsTargetBehavior(TileConversionHandler newTargetTile, BaseSkillInformationData newSkillInformation, TeamType ownerTeam, TeamType newTargetTeam)
    {
        skillInformation = new BaseSkillInformationData();
        skillInformation = newSkillInformation;

        curSkillOwner = ownerTeam;
        targetTeam    = newTargetTeam;

        curTargetType = skillInformation.targetType;
        curTargetStat = skillInformation.targetStats;

        targetTile = newTargetTile;

        myAnim.Play();
    }
 public void SetupSkillSet(BaseSkillInformationData baseSkillInformationData)
 {
     if (baseSkillInformationData != null)
     {
         skillName.text   = baseSkillInformationData.skillName;
         skillDesc.text   = baseSkillInformationData.skillDescription;
         skillIcon.sprite = TransitionManager.GetInstance.unitStorage.GetSkillIcon(baseSkillInformationData.skillName);
     }
     else
     {
         skillName.text   = "No Skill";
         skillDesc.text   = "Empty";
         skillIcon.sprite = emptySkillIcon;
     }
 }
Exemple #5
0
    public void InitializeUnitOnlyTargetBehavior(List <BaseCharacter> newTargetUnits, BaseSkillInformationData newSkillInformation, TeamType ownerTeam, TeamType newTargetTeam)
    {
        skillInformation = new BaseSkillInformationData();
        skillInformation = newSkillInformation;

        curSkillOwner = ownerTeam;
        targetTeam    = newTargetTeam;

        curTargetType = skillInformation.targetType;
        curTargetStat = skillInformation.targetStats;

        targetUnits = new List <BaseCharacter>();
        targetUnits.AddRange(newTargetUnits);

        myAnim.Play();
    }
    public void UpdatePlayerHero()
    {
        BaseHeroInformationData playerAsHero = new BaseHeroInformationData();

        playerAsHero = TransitionManager.GetInstance.unitStorage.ObtainHeroBaseInformation(temporaryKingdom.wieldedWeapon);
        playerAsHero.unitInformation.unitName       = "Player";
        playerAsHero.unitInformation.prefabDataPath = "Assets/Resources/Prefabs/Unit and Items/Player.prefab";

        temporaryKingdom.myHeroes     = new List <BaseHeroInformationData>();
        temporaryKingdom.tavernHeroes = new List <BaseHeroInformationData>();

        BaseHeroInformationData tmp = new BaseHeroInformationData();

        tmp.unitInformation = playerAsHero.unitInformation;
        tmp.heroLevel       = playerAsHero.heroLevel;
        tmp.heroRarity      = playerAsHero.heroRarity;

        tmp.healthGrowthRate = playerAsHero.healthGrowthRate;
        tmp.damageGrowthRate = playerAsHero.damageGrowthRate;
        tmp.speedGrowthRate  = playerAsHero.speedGrowthRate;


        tmp.skillsList = new List <BaseSkillInformationData>();
        for (int i = 0; i < playerAsHero.skillsList.Count; i++)
        {
            BaseSkillInformationData tmpSkill = new BaseSkillInformationData();
            tmpSkill = playerAsHero.skillsList[i];
            tmp.skillsList.Add(tmpSkill);
        }

        if (!TransitionManager.GetInstance.isNewGame)
        {
            temporaryKingdom.myHeroes.Add(tmp);
        }
        else
        {
            temporaryKingdom.myHeroes.Add(tmp);
            PlayerGameManager.GetInstance.playerData.myHeroes = new List <BaseHeroInformationData>();
            PlayerGameManager.GetInstance.playerData.myHeroes.Add(tmp);
        }
    }
        public void ShortcutTest()
        {
            PlayerGameManager.GetInstance.ReceiveTroops(25, "Recruit");
            PlayerGameManager.GetInstance.ReceiveTroops(15, "Archer");
            PlayerGameManager.GetInstance.ReceiveTroops(20, "Swordsman");
            PlayerGameManager.GetInstance.ReceiveTroops(20, "Spearman");

            ResourceInformationController.GetInstance.UpdateCurrentPanel();

            BaseHeroInformationData playerAsHero = new BaseHeroInformationData();

            playerAsHero = TransitionManager.GetInstance.unitStorage.ObtainHeroBaseInformation(WieldedWeapon.Spear);
            playerAsHero.unitInformation.unitName       = "Player";
            playerAsHero.unitInformation.prefabDataPath = "Assets/Resources/Prefabs/Unit and Items/Player.prefab";

            PlayerGameManager.GetInstance.playerData.myHeroes     = new List <BaseHeroInformationData>();
            PlayerGameManager.GetInstance.playerData.tavernHeroes = new List <BaseHeroInformationData>();

            BaseHeroInformationData tmp = new BaseHeroInformationData();

            tmp.unitInformation = playerAsHero.unitInformation;
            tmp.heroLevel       = playerAsHero.heroLevel;
            tmp.heroRarity      = playerAsHero.heroRarity;

            tmp.healthGrowthRate = playerAsHero.healthGrowthRate;
            tmp.damageGrowthRate = playerAsHero.damageGrowthRate;
            tmp.speedGrowthRate  = playerAsHero.speedGrowthRate;


            tmp.skillsList = new List <BaseSkillInformationData>();
            for (int i = 0; i < playerAsHero.skillsList.Count; i++)
            {
                BaseSkillInformationData tmpSkill = new BaseSkillInformationData();
                tmpSkill = playerAsHero.skillsList[i];
                tmp.skillsList.Add(tmpSkill);
            }

            PlayerGameManager.GetInstance.playerData.myHeroes.Add(tmp);
        }
        public void ActivateThisSkill(int idx)
        {
            if (currentHero.skillsList == null || currentHero.skillsList.Count <= 0)
            {
                return;
            }

            if (idx > (currentHero.skillsList.Count - 1))
            {
                Debug.Log("idx is greater than skillslist");
                return;
            }

            if (!BattlefieldSystemsManager.GetInstance.dayInProgress)
            {
                Debug.Log("Day Still In Progress");
                return;
            }

            BaseSkillInformationData thisSkill = new BaseSkillInformationData();

            thisSkill = currentHero.skillsList[idx];

            if (skillSlotList[idx].cdCounter.gameObject.activeInHierarchy)
            {
                Debug.Log("Skill is in Cooldown");
                return;
            }
            Debug.Log("-------------------[ ACTIVATING INDEX SKILL #" + idx + " RIGHT NOW! ]---------------------------------");

            // Place Where The Skill was Activated
            int columnPoint = myController.curColumnIdx;
            int rowPoint    = myController.curRowIdx;


            // GET AFFECTED UNITS
            List <ScenePointBehavior> targetTiles = new List <ScenePointBehavior>();
            List <BaseCharacter>      targetUnits = new List <BaseCharacter>();
            TeamType targetTeam = TeamType.Neutral;

            switch (thisSkill.skillType)
            {
            case SkillType.Offensive:
            case SkillType.OffensiveBuff:     // All Enemies on the boar
                if (myController.teamType == TeamType.Attacker)
                {
                    targetTeam = TeamType.Defender;
                }
                else
                {
                    targetTeam = TeamType.Attacker;
                }
                break;

            case SkillType.Defensive:
            case SkillType.DefensiveBuff:     // All Allies on the board
                targetTeam = myController.teamType;

                break;

            default:
                break;
            }

            if (thisSkill.targetType == TargetType.UnitOnTiles)
            {
                // GET AFFECTED AREA
                switch (thisSkill.affectedArea)
                {
                case AreaAffected.Single:
                    ScenePointBehavior tileSkillUsedOn = BattlefieldPathManager.GetInstance.ObtainPath(columnPoint, rowPoint);
                    targetTiles.Add(tileSkillUsedOn);
                    break;

                case AreaAffected.Row:
                    List <ScenePointBehavior> rowPath = BattlefieldPathManager.GetInstance.ObtainWholeRowPath(rowPoint);
                    targetTiles.AddRange(rowPath);
                    break;

                case AreaAffected.Column:
                    List <ScenePointBehavior> columnPath = BattlefieldPathManager.GetInstance.ObtainWholeColumnPath(columnPoint);

                    targetTiles.AddRange(columnPath);
                    break;

                case AreaAffected.Nearby:
                    List <ScenePointBehavior> nearestPath = BattlefieldPathManager.GetInstance.ObtainNearbyTiles(columnPoint, rowPoint, thisSkill.maxRange);
                    targetTiles.AddRange(nearestPath);
                    break;

                case AreaAffected.All:
                    for (int i = 0; i < BattlefieldPathManager.GetInstance.fieldPaths.Count; i++)
                    {
                        targetTiles.AddRange(BattlefieldPathManager.GetInstance.fieldPaths[i].scenePoints);
                    }
                    break;

                case AreaAffected.Aimed:
                    targetTiles.AddRange(BattlefieldPathManager.GetInstance.ObtainTilesWithThisUnits(thisSkill.maxRange, targetTeam));
                    break;

                default:
                    break;
                }

                // GET ALL TARGETED UNITS
                for (int i = 0; i < targetTiles.Count; i++)
                {
                    targetUnits.AddRange(targetTiles[i].battleTile.characterStepping.FindAll(x => x.teamType == targetTeam));
                }
            }
            else if (thisSkill.targetType == TargetType.UnitOnly)
            {
                switch (targetTeam)
                {
                case TeamType.Defender:
                    if (thisSkill.targetAlive)
                    {
                        targetUnits.AddRange(BattlefieldSpawnManager.GetInstance.defenderSpawnedUnits.FindAll(x => x.unitInformation.curhealth > 0));
                    }
                    else
                    {
                        targetUnits.AddRange(BattlefieldSpawnManager.GetInstance.defenderSpawnedUnits.FindAll(x => x.unitInformation.curhealth <= 0));
                    }
                    break;

                case TeamType.Attacker:
                    if (thisSkill.targetAlive)
                    {
                        targetUnits.AddRange(BattlefieldSpawnManager.GetInstance.attackerSpawnedUnits.FindAll(x => x.unitInformation.curhealth > 0));
                    }
                    else
                    {
                        targetUnits.AddRange(BattlefieldSpawnManager.GetInstance.attackerSpawnedUnits.FindAll(x => x.unitInformation.curhealth <= 0));
                    }
                    break;

                case TeamType.Neutral:
                default:
                    break;
                }

                Debug.Log("Target Unit Count: " + targetUnits.Count);
            }

            if (thisSkill.spawnPrefab)
            {
                GameObject tmp = null;
                BaseVisualSkillBehavior skillBehavior;

                string skillPath = thisSkill.prefabStringPath.Split('.')[0];
                skillPath = skillPath.Replace("Assets/Resources/", "");


                switch (thisSkill.affectedArea)
                {
                case AreaAffected.Single:
                    tmp = GameObject.Instantiate((GameObject)Resources.Load(skillPath, typeof(GameObject)), targetTiles[0].transform.position, Quaternion.identity, null);

                    skillBehavior          = tmp.GetComponent <BaseVisualSkillBehavior>();
                    skillBehavior.myParent = targetTiles[0].battleTile;

                    switch (thisSkill.targetType)
                    {
                    case TargetType.UnitOnly:
                        skillBehavior.InitializeUnitOnlyTargetBehavior(targetUnits, thisSkill, myController.teamType, targetTeam);
                        break;

                    case TargetType.UnitOnTiles:
                        skillBehavior.InitializeTileUnitsTargetBehavior(targetTiles[0].battleTile, thisSkill, myController.teamType, targetTeam);
                        break;

                    case TargetType.TilesOnly:
                        skillBehavior.InitializeTileBuffsTargetBehavior(targetTiles[0].battleTile, thisSkill.buffList, myController.teamType, targetTeam);
                        break;

                    default:
                        break;
                    }

                    targetTiles[0].battleTile.AddSkillOnTile(skillBehavior);
                    break;

                case AreaAffected.Row:
                case AreaAffected.Column:
                case AreaAffected.Nearby:
                case AreaAffected.All:
                case AreaAffected.Aimed:
                    Debug.Log("Skill is Aimed!");
                    switch (thisSkill.targetType)
                    {
                    case TargetType.UnitOnly:
                        for (int i = 0; i < thisSkill.maxRange; i++)
                        {
                            if (i <= (targetUnits.Count - 1))
                            {
                                tmp = GameObject.Instantiate((GameObject)Resources.Load(skillPath, typeof(GameObject)), targetUnits[i].transform.position, Quaternion.identity, null);

                                skillBehavior = tmp.GetComponent <BaseVisualSkillBehavior>();

                                List <BaseCharacter> temp = new List <BaseCharacter>();
                                temp.Add(targetUnits[i]);

                                skillBehavior.InitializeUnitOnlyTargetBehavior(temp, thisSkill, myController.teamType, targetTeam);
                            }
                        }
                        break;

                    case TargetType.UnitOnTiles:
                        for (int i = 0; i < targetTiles.Count; i++)
                        {
                            tmp = GameObject.Instantiate((GameObject)Resources.Load(skillPath, typeof(GameObject)), targetTiles[i].transform.position, Quaternion.identity, null);

                            skillBehavior          = tmp.GetComponent <BaseVisualSkillBehavior>();
                            skillBehavior.myParent = targetTiles[0].battleTile;
                            skillBehavior.InitializeTileUnitsTargetBehavior(targetTiles[i].battleTile, thisSkill, myController.teamType, targetTeam);

                            targetTiles[i].battleTile.AddSkillOnTile(skillBehavior);
                        }
                        break;

                    case TargetType.TilesOnly:
                        for (int i = 0; i < targetTiles.Count; i++)
                        {
                            tmp = GameObject.Instantiate((GameObject)Resources.Load(skillPath, typeof(GameObject)), targetTiles[i].transform.position, Quaternion.identity, null);

                            skillBehavior          = tmp.GetComponent <BaseVisualSkillBehavior>();
                            skillBehavior.myParent = targetTiles[0].battleTile;
                            skillBehavior.InitializeTileBuffsTargetBehavior(targetTiles[i].battleTile, thisSkill.buffList, myController.teamType, targetTeam);
                        }
                        break;

                    default:
                        break;
                    }
                    break;

                default:
                    break;
                }
            }
            else if (thisSkill.skillType == SkillType.SummonUnits)
            {
                int pathCount = BattlefieldPathManager.GetInstance.fieldPaths.Count;

                string unitPath = thisSkill.prefabStringPath.Split('.')[0];
                unitPath = unitPath.Replace("Assets/Resources/", "");

                for (int i = 0; i < pathCount; i++)
                {
                    BattlefieldSpawnManager.GetInstance.SpawnSkillUnits(unitPath, myController.teamType, i);
                }
            }
            else
            {
                switch (thisSkill.skillType)
                {
                case SkillType.Offensive:     // Direct Damage
                    for (int i = 0; i < thisSkill.maxRange; i++)
                    {
                        if (i <= (targetUnits.Count - 1))
                        {
                            targetUnits[i].ReceiveDamage(thisSkill.targetInflictedCount, UnitAttackType.SPELL, thisSkill.targetStats);
                        }
                    }
                    break;

                case SkillType.Defensive:     // Direct Attack
                    for (int i = 0; i < thisSkill.maxRange; i++)
                    {
                        if (i <= (targetUnits.Count - 1))
                        {
                            targetUnits[i].ReceiveHealing(thisSkill.targetInflictedCount, UnitAttackType.SPELL, thisSkill.targetStats);
                        }
                    }
                    break;

                case SkillType.OffensiveBuff:
                case SkillType.DefensiveBuff:
                    foreach (BaseCharacter item in targetUnits)
                    {
                        for (int i = 0; i < thisSkill.buffList.Count; i++)
                        {
                            item.unitInformation.AddBuff(thisSkill.buffList[i]);
                            item.UpdateStats();
                        }
                    }
                    break;

                default:
                    break;
                }
            }
            skillSlotList[idx].SetOnCooldown();
        }
Exemple #9
0
        public void ComputerPlayerSkillControl(bool disregardSummon = false)
        {
            if (currentCommander.heroesCarried == null ||
                currentCommander.heroesCarried.Count <= 0)
            {
                return;
            }

            if (!BattlefieldSystemsManager.GetInstance.dayInProgress)
            {
                return;
            }

            for (int i = 0; i < currentCommander.heroesCarried[0].skillsList.Count; i++)
            {
                BaseSkillInformationData thisSkill = currentCommander.heroesCarried[0].skillsList[i];

                if (skillSlotHandler.skillSlotList[i].cdCounter.gameObject.activeInHierarchy)
                {
                    continue;
                }

                switch (thisSkill.skillType)
                {
                // SKILLS THAT REQUIRE KNOWLEDGE
                case SkillType.Defensive:
                case SkillType.DefensiveBuff:
                    if (thisSkill.targetType == TargetType.UnitOnTiles)
                    {
                        // Check how many Tiles have units on it.
                        int tileWithAllies = 0;
                        switch (teamType)
                        {
                        case TeamType.Defender:
                            tileWithAllies = BattlefieldPathManager.GetInstance.pathsWithDefender.Count;
                            break;

                        case TeamType.Attacker:
                            tileWithAllies = BattlefieldPathManager.GetInstance.pathsWithAttacker.Count;
                            break;

                        default:
                            break;
                        }

                        int halfOfMaxTarget = (thisSkill.maxRange / 2);
                        if (tileWithAllies > halfOfMaxTarget)
                        {
                            skillSlotHandler.curSkillIdx = i;
                            skillSlotHandler.ActivateThisSkill(i);
                        }
                    }
                    else if (thisSkill.targetType == TargetType.UnitOnly)
                    {
                        int unitsLeft = BattlefieldSpawnManager.GetInstance.CountSpawnedUnits(isAttacker, false);
                        if (unitsLeft > 0)
                        {
                            skillSlotHandler.curSkillIdx = i;
                            skillSlotHandler.ActivateThisSkill(i);
                        }
                    }
                    else
                    {
                        skillSlotHandler.curSkillIdx = i;
                        skillSlotHandler.ActivateThisSkill(i);
                    }
                    break;

                case SkillType.Offensive:
                case SkillType.OffensiveBuff:
                    if (thisSkill.targetType == TargetType.UnitOnTiles)
                    {
                        // Check how many Tiles have units on it.
                        int tilesWithEnemies = 0;
                        switch (teamType)
                        {
                        case TeamType.Neutral:
                            tilesWithEnemies = BattlefieldPathManager.GetInstance.pathsWithAttacker.Count + BattlefieldPathManager.GetInstance.pathsWithDefender.Count;
                            break;

                        case TeamType.Defender:
                            tilesWithEnemies = BattlefieldPathManager.GetInstance.pathsWithAttacker.Count;
                            break;

                        case TeamType.Attacker:
                            tilesWithEnemies = BattlefieldPathManager.GetInstance.pathsWithDefender.Count;
                            break;

                        default:
                            break;
                        }

                        int halfOfMaxTarget = (thisSkill.maxRange / 2);
                        if (tilesWithEnemies > halfOfMaxTarget)
                        {
                            skillSlotHandler.curSkillIdx = i;
                            skillSlotHandler.ActivateThisSkill(i);
                        }
                    }
                    else if (thisSkill.targetType == TargetType.UnitOnly)
                    {
                        int unitsLeft = BattlefieldSpawnManager.GetInstance.CountSpawnedUnits(!isAttacker, false);
                        if (unitsLeft > 0)
                        {
                            skillSlotHandler.curSkillIdx = i;
                            skillSlotHandler.ActivateThisSkill(i);
                        }
                    }
                    else
                    {
                        skillSlotHandler.curSkillIdx = i;
                        skillSlotHandler.ActivateThisSkill(i);
                    }
                    break;



                    break;

                // SKILL THAT CAN BE QUICK CASTED.
                case SkillType.SummonUnits:

                    skillSlotHandler.curSkillIdx = i;
                    skillSlotHandler.ActivateThisSkill(i);

                    break;

                default:
                    break;
                }
            }

            if (!disregardSummon)
            {
                ComputerPlayerControl();
            }
            ComputerSummonLeaderControl();
        }