コード例 #1
0
    public void SetMinion(MinionTemplate temp)
    {
        template = temp;

        icon.sprite       = template.icon;
        highlight.enabled = false;
    }
コード例 #2
0
 public void SetMinion(MinionTemplate template, MinionSlot setSlot = MinionSlot.NUM_MINION_SLOTS)
 {
     slot = setSlot;
     if (template == null)
     {
         background.sprite = emptyBackground;
         title.text        = "";
         desc.text         = "";
         health.text       = "";
     }
     else
     {
         background.sprite = elementalBackgrounds [(int)template.element];
         title.text        = LocalizationManager.GetLoc(template.unlocName);
         desc.text         = LocalizationManager.GetLoc(template.unlocDesc);
         if (template.GetSlotType() == MinionSlotType.SUPPORT)
         {
             health.text = "-";
         }
         else
         {
             string hpString = LocalizationManager.GetLoc("HP");
             health.text = string.Format(hpString, Mathf.FloorToInt(template.fMaxHealth));
         }
     }
 }
コード例 #3
0
    public Minion CreateMinion(MinionTemplate template)
    {
        Minion newMinion = Instantiate <Minion>(minionPrefab);

        newMinion.InitFromTemplate(template);
        return(newMinion);
    }
コード例 #4
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);
                }
            }
        }
    }
コード例 #5
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);
        }
    }
コード例 #6
0
    public void ApplyFilters(Filters filters)
    {
        bool bElementalFilterActive = filters.IsAnyElementalFilterActive();
        bool bSlotTypeFilterActive  = filters.IsAnySlotTypeFilterActive();

        int index = 0;

        foreach (MinionPoolGUIEntry entry in allEntries)
        {
            MinionTemplate template = entry.template;
            bool           bAllowed = (!bElementalFilterActive || filters.abElementalFilters [(int)template.element]) &&
                                      (!bSlotTypeFilterActive || filters.abSlotTypeFilters [(int)template.GetSlotType()]) &&
                                      (entry.bAvailable || filters.bShowLocked) &&
                                      (!filters.bShowNewOnly || entry.bNew);
            if (bAllowed)
            {
                entry.SetIndex(index);
                index++;
            }
            else
            {
                entry.SetIndex(-1);
            }
        }

        int numRows = (index + 5) / 6;

        contentBox.sizeDelta = new Vector2(contentBox.sizeDelta.x, 128.0f * numRows + 16.0f);
        ScrollbarValueChanged();
    }
コード例 #7
0
    void Start()
    {
        LevelController level = Core.GetLevel();

        if (level == null)
        {
            Debug.Assert(false, "Level is null");
            return;
        }

        for (int i = 0; i < 3; i++)
        {
            MinionTemplate unlock = level.location.unlocks [i];
            if (unlock == null)
            {
                unlockIcons [i].enabled      = false;
                unlockHighlights [i].enabled = false;
            }
            else
            {
                unlockIcons [i].sprite = unlock.icon;
                // Check for already unlocked
                if (Core.GetPlayerProfile().pool.unlocks.Contains(unlock))
                {
                    unlockHighlights [i].sprite = unlockedSprite;
                }
            }
        }
    }
コード例 #8
0
    public void AddMinion(MinionTemplate template)
    {
        if (unlocks.Contains(template))
        {
            return;
        }


        unlocks.Add(template);
        newList.Add(template);

        UpdateMinionAchievement();
    }
コード例 #9
0
ファイル: TeamRoster.cs プロジェクト: jamioflan/Minimancer
    public Minion SetMinion(MinionSlot slot, MinionTemplate template)
    {
        Minion minion = Core.GetMinionTemplateManager().CreateMinion(template);

        minion.transform.SetParent(transform);
        minion.transform.localPosition = Vector3.zero;
        minion.slot = slot;

        minions [(int)slot] = minion;
        RecalculateHealths();
        bDirty = true;

        return(minion);
    }
コード例 #10
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;
                }
            }
        }
    }
コード例 #11
0
 public Minion(byte ownerIndex, MinionTemplate minionTemplate) : base(ownerIndex)
 {
     template = minionTemplate;
     Health   = minionTemplate.MaxHealth;
 }
コード例 #12
0
ファイル: TeamBuilder.cs プロジェクト: jamioflan/Minimancer
    void OnGUI()
    {
        // Set up drag-drop cursor
        Vector3 v = GUIUtility.ScreenToGUIPoint(Event.current.mousePosition);

        dragDrop.rectTransform.position = new Vector3(v.x, Screen.height - v.y, v.z);
        dragDrop.enabled = (dragDropSelection != null);
        if (dragDropSelection != null)
        {
            dragDrop.sprite = dragDropSelection.icon;
        }

        // Listen for events
        if (Event.current.isMouse)
        {
            switch (Event.current.type)
            {
            case EventType.MouseDown:
            {
                Debug.Assert(dragDropSelection == null, "How can we be clicking when we already have a selection?");
                if (hoveringOverPoolEntry != null && hoveringOverPoolEntry.bAvailable)
                {
                    dragDropSelection = hoveringOverPoolEntry.template;
                    foreach (MinionIcon icon in minionIcons)
                    {
                        icon.SetSlotDroppable(dragDropSelection.GetSlotType() == icon.index.GetSlotType());
                    }
                    Core.GetAudioManager().PlayPickupMinion();
                }
                break;
            }

            case EventType.MouseUp:
            {
                if (dragDropSelection != null)
                {
                    if (hoveringOverMinion == MinionSlot.NUM_MINION_SLOTS)
                    {
                        // Meh, do nothing. It returns to the pool automatically
                    }
                    else
                    {
                        if (hoveringOverMinion.GetSlotType() == dragDropSelection.GetSlotType())
                        {
                            currentRoster.SetMinion(hoveringOverMinion, dragDropSelection);
                            Core.GetAudioManager().PlayDropMinion();
                            UpdateMinionIcons();
                            SetComparisonType(currentlyComparing);
                        }
                        else
                        {
                            Core.GetAudioManager().PlayGUIReject();
                        }
                    }

                    //hoverBlock.SetMinion(null);
                    dragDropSelection = null;
                    foreach (MinionIcon icon in minionIcons)
                    {
                        icon.SetSlotDroppable(true);
                    }
                }
                break;
            }
            }
        }
    }
コード例 #13
0
ファイル: Minion.cs プロジェクト: jamioflan/Minimancer
 public void InitFromTemplate(MinionTemplate newTemplate)
 {
     template       = newTemplate;
     fCurrentHealth = fMaxHealthPreBuffs = fMaxHealthPostBuffs = template.fMaxHealth;
     isZombified    = false;
 }
コード例 #14
0
 public void SetNotNew(MinionTemplate template)
 {
     newList.Remove(template);
 }
コード例 #15
0
 public bool IsNew(MinionTemplate template)
 {
     return(newList.Contains(template));
 }
コード例 #16
0
    void Update()
    {
        LevelController level = Core.GetLevel();

        if (level == null)
        {
            return;
        }

        for (int i = 0; i < 3; i++)
        {
            if (!wavesCompleted [i] && level.GetWaveCompletion(i) >= 1.0f)
            {
                wavesCompleted [i] = true;

                MinionTemplate unlock = level.location.unlocks [i];
                if (unlock != null && unlockHighlights[i].sprite != unlockedSprite)
                {
                    unlockHighlights [i].sprite = unlockedSprite;
                    fUnlockBoxAppearTime        = 0.0f;
                    unlockBoxIcon.sprite        = unlock.icon;
                    for (int j = 0; j < 2; j++)
                    {
                        unlockBoxName[j].text = LocalizationManager.GetLoc(unlock.unlocName);
                    }
                }
            }
        }

        unlockBox.alpha = Mathf.Clamp(2 - fUnlockBoxAppearTime * 0.25f, 0.0f, 1.0f);

        fUnlockBoxAppearTime += Core.GetDeltaTime();

        /*
         * float fProgress = level.GetParametricProgress();
         * for (int i = 0; i < 3; i++)
         * {
         *      if (fProgress < i / 3.0f)
         *      {
         *              progressBar [i].fillAmount = 0.0f;
         *      }
         *      else if (fProgress > (i + 1) / 3.0f)
         *      {
         *              progressBar [i].fillAmount = 1.0f;
         *      }
         *      else
         *      {
         *              progressBar [i].fillAmount = fProgress * 3.0f - i;
         *      }
         * }
         */

        int iCurrentWave = level.iCurrentWave;

        if (level.fGracePeriodDuration < level.location.gracePeriodDuration && iCurrentWave < level.location.numWaves)
        {
            for (int i = 0; i < 2; i++)
            {
                timeToNextWave [i].text = string.Format(LocalizationManager.GetLoc("TIME_TO_NEXT_WAVE"), Mathf.CeilToInt(level.location.gracePeriodDuration - level.fGracePeriodDuration));
            }
            startNextWaveButton.interactable = true;
            iCurrentWave--;
        }
        else
        {
            for (int i = 0; i < 2; i++)
            {
                timeToNextWave [i].text = "";
            }
            startNextWaveButton.interactable = false;
        }

        for (int i = 0; i < 3; i++)
        {
            if (iCurrentWave >= i)
            {
                waveActiveImage [i].enabled = true;
            }

            progressBar [i].fillAmount = level.GetWaveCompletion(i);
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            StartNextWave();
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            FastForward(true);
        }
        else if (Input.GetKeyUp(KeyCode.Space))
        {
            FastForward(false);
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            AbortLevel();
        }
    }