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 ReadFrom(SerializationInfo data, string prefix)
    {
        unlocks.Clear();

        MinionTemplateManager mtm = Core.GetMinionTemplateManager();

        int count = data.GetInt32(prefix + "NumMinions");

        for (int i = 0; i < count; i++)
        {
            int            minionHash = data.GetInt32(prefix + "Minion" + i + ".Hash");
            MinionTemplate template   = mtm.GetTemplate(minionHash);
            if (template != null)
            {
                if (!unlocks.Contains(template))
                {
                    unlocks.Add(template);
                }
            }
        }

        count = data.GetInt32(prefix + "NumNew");
        for (int i = 0; i < count; i++)
        {
            int            minionHash = data.GetInt32(prefix + "New" + i + ".Hash");
            MinionTemplate template   = mtm.GetTemplate(minionHash);
            if (template != null)
            {
                if (!newList.Contains(template))
                {
                    newList.Add(template);
                }
            }
        }
    }
Esempio n. 3
0
    public void SelectMinion(int iSelection)
    {
        Minion oldMinion = Core.GetPlayerProfile().rosters [0].GetMinion(slot);

        if (oldMinion != null)
        {
            Destroy(oldMinion.gameObject);
        }

        MinionTemplateManager mtm = Core.GetMinionTemplateManager();
        Minion minion             = Core.GetPlayerProfile().rosters [0].SetMinion(slot, mtm.GetMinionList(slot.GetSlotType()) [iSelection]);

        icon.sprite      = minion.template.icon;
        description.text = minion.template.debugDescriptionText;

        if (slot.GetSlotType() != MinionSlotType.SUPPORT)
        {
            statBlock.text = "HP: " + minion.template.fMaxHealth + ", Damage: " + minion.template.damage.fAmount + ", Attack Speed: " + (1.0f / minion.template.fAttackInterval);
        }
    }
Esempio n. 4
0
    void Update()
    {
        MinionTemplateManager mtm  = Core.GetMinionTemplateManager();
        List <MinionTemplate> list = mtm.GetMinionList(slot.GetSlotType());

        MinionTemplate dropdownSelection = mtm.GetMinionList(slot.GetSlotType()) [minionSelector.value];
        Minion         currentSelection  = Core.GetPlayerProfile().rosters[0].minions [(int)slot];

        if (currentSelection.template != dropdownSelection)
        {
            for (int i = 0; i < list.Count; i++)
            {
                if (list [i] == currentSelection.template)
                {
                    minionSelector.value = i;
                    return;
                }
            }
        }
    }