Esempio n. 1
0
    private void SpawnRandomGroup()
    {
        if (pendingSpawns.Count == 0)
        {
            Debug.Assert(false, "Ran out of spawns");
            return;
        }
        int iPick = Random.Range(0, pendingSpawns.Count);

        MinionTemplate template = pendingSpawns [iPick];

        pendingSpawns.RemoveAt(iPick);

        Vector3 spawnPos = GetBestSpawnPoint();

        {
            // Create new game object
            GameObject go = new GameObject("EnemyMinion_" + template.name);

            // Create a minion and attach it to the actor's game object. Enemy minions are less permanent data structures than player ones, so they can just be chucked into the battlefield
            MinionTemplateManager mtm = Core.GetMinionTemplateManager();
            Minion minion             = mtm.CreateMinion(template);
            minion.transform.SetParent(go.transform);
            minion.transform.localPosition = Vector3.zero;

            // Fill it with actor components
            Actor_Enemy actor = go.AddComponent <Actor_Enemy>();
            actor.InitFromMinion(minion);
            actor.iWave = iCurrentWave;
            aiNumSpawnedPerWave [iCurrentWave]++;
            Vector2 randomOffset = Random.insideUnitCircle * Random.Range(0.0f, 0.5f);
            actor.transform.position = spawnPos + new Vector3(randomOffset.x, 0.0f, randomOffset.y);
            // Push the next member of the group back a bit
            spawnPos = new Vector3(spawnPos.x + 1.0f, spawnPos.y, spawnPos.z);

            // Add renderer to actor
            RenderActor render = Instantiate <RenderActor>(template.render);
            render.transform.SetParent(actor.transform);
            render.transform.localPosition = Vector3.zero;
            render.Init(actor);
            actor.render = render;

            // Add audio sources
            actor.soundEffect                       = go.AddComponent <AudioSource>();
            actor.soundEffect.clip                  = minion.template.soundEffect;
            actor.soundEffect.playOnAwake           = false;
            actor.soundEffect.outputAudioMixerGroup = Core.GetAudioManager().soundEffectGroup;

            // Add healthbar
            Healthbar healthbar = Instantiate <Healthbar>(mtm.healthbarPrefab);
            healthbar.transform.SetParent(actor.transform);
            healthbar.transform.localPosition = new Vector3(0.0f, template.fHeight - 1.0f, 0.0f);
            actor.healthbar = healthbar;

            actor.CalculateMyAggregateBuffs();

            // Store a reference for later
            enemyActors.Add(actor);
        }
    }
Esempio n. 2
0
    public void UpdatePreview()
    {
        foreach (RenderActor ra in renderers)
        {
            Destroy(ra.gameObject);
        }
        renderers.Clear();

        for (int i = 0; i < (int)MinionSlot.NUM_MINION_SLOTS; i++)
        {
            RenderActor renderActor = Instantiate <RenderActor>(roster.minions [i].template.render);
            renderActor.transform.SetParent(playerSpawnPoints [i]);
            renderActor.transform.localPosition = Vector3.zero;
            renderActor.transform.localScale    = new Vector3(-10.0f, 10.0f, 10.0f);
            renderActor.SetAnimState(AnimState.IDLE, true);
            renderers.Add(renderActor);
        }
    }
Esempio n. 3
0
    public void StartLevel(TeamRoster selectedRoster)
    {
        // This oddly named object points to all sorts of useful things that exist in all levels
        instance = FindObjectOfType <PlayerRig>();

        if (instance == null)
        {
            instance = Instantiate <PlayerRig>(Core.theCore.playerRigPrefab);
            instance.transform.position = Vector3.zero;
        }

        GameObject sunObject = GameObject.Find("Directional Light");

        if (sunObject != null)
        {
            sun            = sunObject.GetComponent <Light>();
            originalSunPos = sun.transform.rotation;
        }

        instance.gameObject.SetActive(true);

        Range[] ranges = new Range[2] {
            Range.WIDE, Range.WIDE
        };

        bool bAgainstElement = false;

        fMeleeZoneSize = 1.0f;

        Core.theCore.fEnemyTimescale  = 1.0f;
        Core.theCore.fPlayerTimescale = 1.0f;

        // Spawn the player's minions immediately. Then give a countdown to start the game

        roster = selectedRoster;
        for (int i = 0; i < (int)MinionSlot.NUM_MINION_SLOTS; i++)
        {
            Transform spawnPoint = instance.playerSpawnPoints [i];
            Minion    minion     = roster.minions [i];
            if (spawnPoint != null && minion != null)
            {
                // Create new game object
                GameObject go = new GameObject("PlayerMinion_" + i + "_" + minion.template.name);

                // Fill it with actor components
                Actor_Player actor = go.AddComponent <Actor_Player>();
                actor.InitFromMinion(minion);
                actor.transform.position = spawnPoint.position;

                // Add renderer to actor
                RenderActor render = Instantiate <RenderActor>(minion.template.render);
                render.transform.SetParent(actor.transform);
                render.transform.localPosition = Vector3.zero;
                render.transform.localScale    = new Vector3(-1.0f, 1.0f, 1.0f);
                render.Init(actor);
                actor.render = render;

                // Add audio sources
                actor.soundEffect                       = go.AddComponent <AudioSource>();
                actor.soundEffect.clip                  = minion.template.soundEffect;
                actor.soundEffect.playOnAwake           = false;
                actor.soundEffect.outputAudioMixerGroup = Core.GetAudioManager().soundEffectGroup;

                // And combo numbers
                if ((minion.template.canCombo || minion.template.bDeathtoll || minion.template.bRelentless) && minion.template.comboNumbers != null)
                {
                    ComboNumbers combo = Instantiate <ComboNumbers>(minion.template.comboNumbers);
                    combo.transform.SetParent(actor.transform);
                    combo.transform.localPosition = new Vector3(-0.17f, 0.215f, -0.13f);
                    actor.comboNumbers            = combo;
                }

                // Save a reference for later
                playerActors [i] = actor;

                //
                if (((MinionSlot)i).GetSlotType() == MinionSlotType.RANGED && (minion.template is Minion_Ranged))
                {
                    ranges [i == (int)MinionSlot.RANGED_1 ? 0 : 1] = ((Minion_Ranged)minion.template).range;
                }

                if (minion.template is Minion_Support && ((Minion_Support)(minion.template)).bWalls)
                {
                    bWalls = true;
                }

                foreach (Resurrection res in minion.template.resurrectionTriggers)
                {
                    singleUseResurrections.Add(new Resurrection(res));
                }

                if (minion.template.element.GetDamageMultiplier(location.element) < 1.0f && ((MinionSlot)i).GetSlotType() != MinionSlotType.SUPPORT)
                {
                    bAgainstElement = true;
                }

                Core.theCore.fEnemyTimescale  += minion.GetBuff(Stat.ENEMY_TIMESCALE);
                Core.theCore.fPlayerTimescale += minion.GetBuff(Stat.PLAYER_TIMESCALE);

                fMeleeZoneSize += minion.GetBuff(Stat.MELEEZONE_SIZE);
            }
        }

        roster.bHasThreeResurrectsAvailable = singleUseResurrections.Count == 6;
        roster.bHasActiveCollector          = false;

        // After ALL player minions are created, then calculate their passive buffs and store them off.
        for (int i = 0; i < (int)MinionSlot.NUM_MINION_SLOTS; i++)
        {
            if (playerActors [i] != null)
            {
                playerActors [i].CalculateMyAggregateBuffs();
                playerActors [i].SetMaxHealthFromBuffs();
                playerActors [i].minion.ResetTemporaryData();
            }
        }

        roster.RecalculateHealths();

        fRangedZoneMin = Ranges.GetMinRangeForPair(ranges [0], ranges [1]);
        fRangedZoneMax = Ranges.GetMaxRangeForPair(ranges [0], ranges [1]);
        fLaneWidth     = bWalls ? 4.0f : 6.0f;
        InitZones(bWalls);

        aiNumKilledPerWave  = new int[location.numWaves];
        aiNumSpawnedPerWave = new int[location.numWaves];
        abNewlyUnlocked     = new bool[location.numWaves];


        iCurrentWave = -1;
        AdvanceWave();
        fGracePeriodDuration = location.gracePeriodDuration;

        instance.elementalHint.enabled = bAgainstElement;
        if (bAgainstElement)
        {
            instance.elementalHint.text = LocalizationManager.GetLoc(location.element.GetHintText());
        }

        Core.GetAudioManager().SetLevelMusic(location.music);

        RequestState(LevelState.PLAYING);
    }