コード例 #1
0
        public void SpawnSkillUnits(string prefabPath, TeamType teamWith, int columnPoint)
        {
            GameObject tmp;

            tmp = (GameObject)Resources.Load(prefabPath);
            ScenePointBehavior spawnPoint  = null;
            ScenePointBehavior targetPoint = null;

            List <BattlefieldPathHandler> fieldPaths = BattlefieldPathManager.GetInstance.fieldPaths;

            switch (teamWith)
            {
            case TeamType.Neutral:     // MONSTERS SPAWNED, CAN be IMPROVED LATER ON
                int rand = UnityEngine.Random.Range(0, fieldPaths[columnPoint].scenePoints.Count);
                spawnPoint = fieldPaths[columnPoint].scenePoints[rand];
                if (rand < (fieldPaths[columnPoint].scenePoints.Count / 2))
                {
                    targetPoint = fieldPaths[columnPoint].attackerSpawnPoint;
                }
                else
                {
                    targetPoint = fieldPaths[columnPoint].defenderSpawnPoint;
                }

                break;

            case TeamType.Defender:
                spawnPoint  = fieldPaths[columnPoint].defenderSpawnPoint;
                targetPoint = fieldPaths[columnPoint].attackerSpawnPoint;
                break;

            case TeamType.Attacker:
                spawnPoint  = fieldPaths[columnPoint].attackerSpawnPoint;
                targetPoint = fieldPaths[columnPoint].defenderSpawnPoint;
                break;

            default:
                break;
            }

            tmp = GameObject.Instantiate(tmp, spawnPoint.transform.position, Quaternion.identity, null);
            BaseCharacter tmpCharacter = tmp.GetComponent <BaseCharacter>();


            tmpCharacter.SpawnInThisPosition(spawnPoint);
            tmpCharacter.SetupCharacter(unitStorage.GetUnitInformation(tmpCharacter.unitInformation.unitName));
            tmpCharacter.OrderMovement(targetPoint);
            tmpCharacter.isFighting = true;
            tmpCharacter.overheadHealthbar.gameObject.SetActive(true);
            tmpCharacter.overheadHealthbar.SetupHealthBar(tmpCharacter.unitInformation.curhealth, tmpCharacter.unitInformation.maxHealth);
            tmpCharacter.canReturnToCamp = false;
            tmpCharacter.teamType        = teamWith;

            switch (teamWith)
            {
            case TeamType.Defender:
                if (defendingCommander.spawnBuffsList != null && defendingCommander.spawnBuffsList.Count > 0)
                {
                    for (int i = 0; i < defendingCommander.spawnBuffsList.Count; i++)
                    {
                        tmpCharacter.AddBuff(defendingCommander.spawnBuffsList[i]);
                    }
                }
                defenderSpawnedUnits.Add(tmpCharacter);
                break;

            case TeamType.Attacker:
                if (attackingCommander.spawnBuffsList != null && attackingCommander.spawnBuffsList.Count > 0)
                {
                    for (int i = 0; i < attackingCommander.spawnBuffsList.Count; i++)
                    {
                        tmpCharacter.AddBuff(attackingCommander.spawnBuffsList[i]);
                    }
                }
                attackerSpawnedUnits.Add(tmpCharacter);
                break;

            default:
                break;
            }
        }
コード例 #2
0
        public void SpawnLeaderToBattle(TeamType thisTeamLeader, ScenePointBehavior spawnPoint, ScenePointBehavior targetPoint)
        {
            BaseCharacter thisLeader = null;

            switch (thisTeamLeader)
            {
            case TeamType.Defender:
                if (defenderHeroLeader == null)
                {
                    return;
                }

                thisLeader = defenderHeroLeader;

                if (defendingCommander.spawnBuffsList != null &&
                    defendingCommander.spawnBuffsList.Count > 0)
                {
                    thisLeader.unitInformation.buffList = new List <BaseBuffInformationData>();

                    for (int i = 0; i < defendingCommander.spawnBuffsList.Count; i++)
                    {
                        thisLeader.AddBuff(defendingCommander.spawnBuffsList[i]);
                    }
                }
                defenderSpawnedUnits.Add(thisLeader);
                break;

            case TeamType.Attacker:
                if (attackerHeroLeader == null)
                {
                    return;
                }

                thisLeader = attackerHeroLeader;

                if (attackingCommander.spawnBuffsList != null &&
                    attackingCommander.spawnBuffsList.Count > 0)
                {
                    thisLeader.unitInformation.buffList = new List <BaseBuffInformationData>();

                    for (int i = 0; i < attackingCommander.spawnBuffsList.Count; i++)
                    {
                        thisLeader.AddBuff(attackingCommander.spawnBuffsList[i]);
                    }
                }
                attackerSpawnedUnits.Add(thisLeader);
                break;

            case TeamType.Neutral:
            default:
                break;
            }

            if (thisLeader != null)
            {
                Debug.Log("This Leader Name:" + thisLeader.gameObject.name);
                thisLeader.SpawnInThisPosition(spawnPoint, true);
                thisLeader.isFighting = true;
                thisLeader.OrderMovement(targetPoint);
                thisLeader.canReturnToCamp = true;
                thisLeader.isFighting      = true;
                thisLeader.overheadHealthbar.gameObject.SetActive(true);
                thisLeader.overheadHealthbar.SetupHealthBar(thisLeader.unitInformation.curhealth, thisLeader.unitInformation.maxHealth);
                thisLeader.myRange.UpdateTotalRange();
            }
        }