예제 #1
0
        void Awake()
        {
            grid = tileManager.grid;
            for (int numUnits = 0; numUnits < 3; numUnits++)
            {
                IEnemy enemyData = Enemy.GetEnemyFromTier(1);

                GameObject             unit           = Instantiate(playerPrefab, new Vector3(numUnits, 1.5f, 5), Quaternion.identity);
                UniqueCreature         uniqueCreature = unit.GetComponent <UniqueCreature>();
                UnitAbilitiesContainer abilities      = unit.GetComponent <UnitAbilitiesContainer>();
                UnitStats stats = unit.GetComponent <UnitStats>();
                CinemachineVirtualCamera cam   = uniqueCreature.currentCamera;
                BrainManager             brain = unit.GetComponent <BrainManager>();
                MovementSystem           ms    = unit.GetComponent <MovementSystem>();
                camManager.cameras.Add(cam.gameObject);
                turnManager.units.Add(unit);
                //turnManager.activePlayer = brain;
                Animator anim = unit.GetComponent <Animator>();
                RuntimeAnimatorController currentAi = Resources.Load <RuntimeAnimatorController>("Ai/StrikerBrain");
                anim.runtimeAnimatorController = currentAi;
                brain.manager = turnManager;

                //UniqueCreature
                uniqueCreature.creatureName = enemyData.Name;
                uniqueCreature.health       = enemyData.Stats.Current_HP;
                uniqueCreature.maxHealth    = enemyData.Stats.Max_HP;
                uniqueCreature.maxMovement  = enemyData.Stats.Movement;
                uniqueCreature.isEnemy      = true;

                //Movement
                ms.grid = grid;

                //Abilities
                foreach (IAbility dataAbility in enemyData.Abilities)
                {
                    abilities.abilities.Add(new Ability(dataAbility));
                }


                //stats
                stats.health          = enemyData.Stats.Current_HP;
                stats.maxHealth       = enemyData.Stats.Max_HP;
                stats.physicalAttack  = enemyData.Stats.Physical_Attack;
                stats.magicAttack     = enemyData.Stats.Magic_Attack;
                stats.physicalDefense = enemyData.Stats.Physical_Defense;
                stats.magicDefense    = enemyData.Stats.Magic_Defense;
                stats.movement        = enemyData.Stats.Movement;
                stats.speedIntit      = enemyData.Stats.Initiative;

                //brain
                brain.tileIndictor = indicator;
                //brain.startCoordinates = new Vector2(25 - numUnits * 2, 27);
                brain.startCoordinates = new Vector2(startCoords.x + numUnits, startCoords.y);

                unit.transform.parent = unitHolder;

                turnManager.enemies.Add(unit);
            }
        }
예제 #2
0
        void Awake()
        {
            AssertHelper.Assert(SceneSharing.squadID != -1, "No squad ID set, defaulting to all units", this);
            List <IUnit> unitIDs = (SceneSharing.squadID != -1) ? new Squad(SceneSharing.squadID).Units : Unit.GetAllUnits();

            grid = tileManager.grid;
            int numUnits = 0;

            foreach (IUnit dataUnit in unitIDs)
            {
                GameObject             unit           = Instantiate(playerPrefab, new Vector3(numUnits, 1.5f, 0), Quaternion.identity);
                UniqueCreature         uniqueCreature = unit.GetComponent <UniqueCreature>();
                UnitAbilitiesContainer abilities      = unit.GetComponent <UnitAbilitiesContainer>();
                UnitStats                stats        = unit.GetComponent <UnitStats>();
                BrainManager             brain        = unit.GetComponent <BrainManager>();
                MovementSystem           ms           = unit.GetComponent <MovementSystem>();
                CinemachineVirtualCamera cam          = uniqueCreature.currentCamera;
                Animator anim = unit.GetComponent <Animator>();
                RuntimeAnimatorController currentAi = Resources.Load <RuntimeAnimatorController>("Ai/PlayerBrain");
                anim.runtimeAnimatorController = currentAi;
                camManager.cameras.Add(cam.gameObject);
                turnManager.units.Add(unit);
                turnManager.playerUnits.Add(unit);
                turnManager.activePlayer = brain;
                uniqueCreature.isEnemy   = false;

                //UniqueCreature
                uniqueCreature.creatureName = dataUnit.Name;
                uniqueCreature.maxHealth    = dataUnit.Stats.Max_HP;
                uniqueCreature.health       = dataUnit.Stats.Current_HP;
                uniqueCreature.maxMovement  = dataUnit.Stats.Movement;
                uniqueCreature.myUnit       = dataUnit;

                //Movement
                ms.grid = grid;

                //stats
                stats.health          = dataUnit.Stats.Current_HP;
                stats.maxHealth       = dataUnit.Stats.Max_HP;
                stats.physicalAttack  = dataUnit.Stats.Physical_Attack;
                stats.magicAttack     = dataUnit.Stats.Magic_Attack;
                stats.physicalDefense = dataUnit.Stats.Physical_Defense;
                stats.magicDefense    = dataUnit.Stats.Magic_Defense;
                stats.movement        = dataUnit.Stats.Movement;
                stats.speedIntit      = dataUnit.Stats.Initiative;
                stats.role            = dataUnit.Role.Name;

                //Abilities
                foreach (IAbility dataAbility in dataUnit.Abilities)
                {
                    abilities.abilities.Add(new Ability(dataAbility));
                }

                //brain
                brain.tileIndictor = indicator;
                indicator.GetComponentInChildren <Renderer>().enabled = false;
                //brain.startCoordinates = new Vector2(numUnits * 2 + 25, 25);
                brain.startCoordinates = new Vector2(startCoords.x + numUnits, startCoords.y);
                brain.manager          = turnManager;
                unit.transform.parent  = unitHolder;

                numUnits += 2;
            }
        }