Esempio n. 1
0
    public void SetUpButtonForSpawner(Spawner spawner, AIUnitData vinculationData, Sprite relationedSprite)
    {
        ResetButton();

        this.spawner     = spawner;
        spawnerSpawnUnit = vinculationData;
        image.sprite     = relationedSprite;
    }
    public bool TrySpawnUnit(AIUnitData unitData, out AIUnit newUnit)
    {
        AIUnit unitPrefab = unitDictionary.dictionary[unitData];

        Debug.Assert(unitPrefab != null, "the key doen't have any value");

        newUnit      = LeanPool.Spawn(unitPrefab, spawningPosition, Quaternion.identity);
        newUnit.team = team;

        return(true);
    }
    public void SetReinforcementMode(AIUnitData data, UnitManager unitManager)
    {
        ResetSpawner();

        currentUnitData = data;
        currentReinforcementCompatibleUnits = unitManager.FindUnits(data, Team);
        foreach (IKillable unit in currentReinforcementCompatibleUnits)
        {
            unit.OnDeath += OnReinforcementUnitDeath;
        }
    }
    public void ResetSpawner()
    {
        if (!OnReinforcementMode)
        {
            return;
        }

        foreach (IKillable unit in currentReinforcementCompatibleUnits)
        {
            unit.OnDeath -= OnReinforcementUnitDeath;
        }
        currentReinforcementCompatibleUnits = null;
        currentUnitData = null;
    }
    private void SetUpAndShowGridButtonsForSpawnerSelectionView(Spawner selected, UISelectionMenuManager caller)
    {
        for (int i = 0; i < STATIC_PANEL_SPACES; i++)
        {
            AIUnitData spawnerSpawnOption = selected.spawnOptions[i];
            if (spawnerSpawnOption == null)
            {
                continue;
            }


            Debug.Assert(caller.portraitDictionary.dictionary.TryGetValue(spawnerSpawnOption, out Sprite sprite),
                         $"portrait dictionary doesn't have a value for {spawnerSpawnOption}");

            gridButtons[i].SetUpButtonForSpawner(selected, spawnerSpawnOption, sprite);
            gridButtons[i].gameObject.SetActive(true);
        }
    }
    private void UpdateReinforcementButtons(Spawner spawner, AIUnitData data)
    {
        Debug.Assert(selectionMenuManager.portraitDictionary.dictionary.TryGetValue(data, out Sprite buttonSprite), "update the portrait dictionary!");
        if (spawner.currentReinforcementCompatibleUnits == null)
        {
            return;
        }

        for (int i = 0; i < spawner.currentReinforcementCompatibleUnits.Count; i++)
        {
            AIUnit currUnit = spawner.currentReinforcementCompatibleUnits[i];
            ReinforcementButton currButton = reinforcementButtons[i];
            Debug.Assert(currUnit && currButton != null);



            currButton.UpdateButton(currUnit, spawner, buttonSprite);
        }
    }
Esempio n. 7
0
    public List <AIUnit> FindUnits(AIUnitData data, Team team)
    {
        if (allActiveUnits == null || allActiveUnits.Count == 0)
        {
            return(new List <AIUnit>());
        }

        List <AIUnit> returnUnits = new List <AIUnit>();

        foreach (AIUnit unit in allActiveUnits)
        {
            if (unit.Data == data && unit.team == team)
            {
                returnUnits.Add(unit);
            }
        }

        //if (returnUnits.Count == 0) return null;
        //else
        return(returnUnits);
    }
Esempio n. 8
0
 public void UpdateButton(Spawner spawner, AIUnitData data, Sprite sprite)
 {
     currSpawner    = spawner;
     currentData    = data;
     imgComp.sprite = sprite;
 }
 public void ShowAndSetReinforcementView(Spawner spawner, AIUnitData data)
 {
     spawner.SetReinforcementMode(data, unitManager);
     ShowReinforcementView(spawner);
 }
Esempio n. 10
0
 public void UpdateButton(AIUnitData data, Spawner spawner)
 {
     currData       = data;
     currentSpawner = spawner;
 }
Esempio n. 11
0
    //el boton al ser apretado debe saber que hacer.
    //en el caso de ser apretado en por un spawner. Este debe modificar al spawner al cual esta vinculado.

    //por ahora los botones van ha hacer mucha pega


    //private void ResetButtonMode()
    //{
    //    unit = null;
    //    builder = null;
    //    spawner = null;
    //}

    private void ResetButton()
    {
        spawner          = null;
        spawnerSpawnUnit = null;
    }