void OnTownSelected(MapTown a_Town, int a_Index)
    {
        m_SelectedTown = a_Town;
        m_SelectedHero = null;

        int _TownCount = m_LocalOwnership.GetTownCount();

        // High res
        if (a_Index >= m_TownUIIndex + 7 ||
            a_Index < m_TownUIIndex)
        {
            m_TownUIIndex = a_Index;

            if (m_TownUIIndex > _TownCount - 7)
            {
                m_TownUIIndex = _TownCount - 7;
            }
        }

        // Low res
        if (a_Index >= m_TownUIIndexLowRes + 5 ||
            a_Index < m_TownUIIndexLowRes)
        {
            m_TownUIIndexLowRes = a_Index;

            if (m_TownUIIndexLowRes > _TownCount - 5)
            {
                m_TownUIIndexLowRes = _TownCount - 5;
            }
        }

        UpdateTownDisplay();
    }
예제 #2
0
    public IEnumerator EnterHeroEditMode(MapHero mapHero)
    {
        Debug.Log("Enter hero edit mode.");
        mapHero.DimmLabel();
        // Trigger on mapobject exit to Hide label(s - + hide hero's lable, if it is in city)
        // verify if MapObject's labe is still active and mouse over it
        if (mapHero.GetComponent <MapObject>().Label.GetComponent <Text>().raycastTarget&& mapHero.GetComponent <MapObject>().Label.IsMouseOver)
        {
            // disable it
            mapHero.GetComponent <MapObject>().OnPointerExit(null);
        }
        // Block mouse input
        // InputBlocker inputBlocker = transform.root.Find("MiscUI/InputBlocker").GetComponent<InputBlocker>();
        InputBlocker.SetActive(true);
        // Wait for all animations to finish
        // this depends on the labelDimTimeout parameter in MapObject, we add additional 0.1f just in case
        yield return(new WaitForSeconds(mapHero.GetComponent <MapObject>().LabelDimTimeout + 0.1f));

        // Unblock mouse input
        InputBlocker.SetActive(false);
        // Deactivate map manager with map
        MapManager.Instance.gameObject.SetActive(false);
        // Deactivate this map menu
        gameObject.SetActive(false);
        // Note: everything below related to mapManager or mapScreen will not be processed, because map manager is disabled
        // Activate hero edit menu
        transform.root.GetComponentInChildren <UIManager>().GetComponentInChildren <EditPartyScreen>(true).SetEditPartyScreenActive(mapHero.LHeroParty);
    }
    void OnHeroSelected(MapHero a_Hero, int a_Index)
    {
        if (a_Hero.HasPath)
        {
            m_MoveHeroHighRes.interactable = true;
            m_MoveHeroLowRes.interactable  = true;
        }

        a_Hero.OnPathCreated   += OnPathCreated;
        a_Hero.OnPathRemoved   += OnPathRemoved;
        a_Hero.OnStartMovement += OnStartMovement;

        m_SelectedHero = a_Hero;

        m_SleepHeroHighRes.interactable = true;
        m_SleepHeroLowRes.interactable  = true;
        m_WakeHeroHighRes.interactable  = true;
        m_WakeHeroLowRes.interactable   = true;

        m_SpellbookHighRes.interactable = true;
        m_SpellbookLowRes.interactable  = true;

        m_SleepHeroHighRes.gameObject.SetActive(!a_Hero.IsAsleep);
        m_SleepHeroLowRes.gameObject.SetActive(!a_Hero.IsAsleep);
        m_WakeHeroHighRes.gameObject.SetActive(a_Hero.IsAsleep);
        m_WakeHeroLowRes.gameObject.SetActive(a_Hero.IsAsleep);
    }
    public void SelectHero(MapHero a_Hero)
    {
        if (!m_Heroes.Contains(a_Hero))
        {
            Debug.LogError("Selected hero that isn't owned by local player");
            return;
        }

        if (SelectedHero != null)
        {
            SelectedHero.OnDeselected();
            OnHeroDeselected?.Invoke(SelectedHero);
        }
        else if (SelectedTown != null)
        {
            OnTownDeselected?.Invoke(SelectedTown);
        }

        SelectedHero = a_Hero;
        SelectedTown = null;

        OnHeroSelected?.Invoke(a_Hero, m_Heroes.IndexOf(a_Hero));

        a_Hero.OnSelected();
    }
예제 #5
0
    MapHero CreatePartyOnMap(HeroParty heroParty, PartyData partyData)
    {
        Debug.Log("Creating party on map representation");
        // Create new party on map UI
        MapHero newPartyOnMap = Instantiate(heroPartyOnMapTemplate, MapManager.Instance.GetParentTransformByType(GetComponent <MapHero>())).GetComponent <MapHero>();

        // place party to original position on map
        //newPartyOnMap.GetComponent<RectTransform>().offsetMin = new Vector2(partyData.partyMapPosition.offsetMinX, partyData.partyMapPosition.offsetMinY);
        //newPartyOnMap.GetComponent<RectTransform>().offsetMax = new Vector2(partyData.partyMapPosition.offsetMaxX, partyData.partyMapPosition.offsetMaxY);
        // place it to original position on map based on the tile coordinates
        newPartyOnMap.transform.position = MapManager.Instance.GetWorldPositionByCoordinates(partyData.partyMapCoordinates);
        // Create hero label on map
        MapObjectLabel newPartyOnMapLabel = Instantiate(heroPartyOnMapLabelTemplate, MapManager.Instance.GetParentTransformByType(GetComponent <MapObjectLabel>())).GetComponent <MapObjectLabel>();

        // Link hero to the lable and label to the hero
        newPartyOnMap.GetComponent <MapObject>().Label = newPartyOnMapLabel;
        newPartyOnMapLabel.MapObject = newPartyOnMap.GetComponent <MapObject>();
        // create links between party on map and hero party
        newPartyOnMap.LHeroParty = heroParty;
        heroParty.LMapHero       = newPartyOnMap;
        // rename it
        newPartyOnMap.gameObject.name = heroParty.GetPartyLeader().GivenName + " " + heroParty.GetPartyLeader().UnitName + " Party";
        // set color according to the player color preference
        newPartyOnMap.SetColor(GetPlayerByFaction(heroParty.Faction).PlayerColor);
        // activate hero on map
        newPartyOnMap.gameObject.SetActive(true);
        // activate hero label on map
        newPartyOnMapLabel.gameObject.SetActive(true);
        // return result
        return(newPartyOnMap);
    }
예제 #6
0
    void SetPartyLeaderMovePointsInfo(MapHero mapHero)
    {
        // get party leader
        PartyUnit partyLeader = mapHero.LHeroParty.GetPartyLeader();

        // Set UI text
        focusedObjectInfoText.text = partyLeader.MovePointsCurrent + "/" + partyLeader.GetEffectiveMaxMovePoints() + " Move Points";
    }
예제 #7
0
    public void EnterBattle(MapHero playerOnMap, MapHero enemyOnMap)
    {
        // get hero's parties
        HeroParty playerHeroParty = playerOnMap.LHeroParty;
        HeroParty enemyHeroParty  = enemyOnMap.LHeroParty;

        EnterBattleCommon(playerHeroParty, enemyHeroParty);
    }
    void OnHeroAdded(MapHero a_Hero)
    {
        int _HeroCount = m_LocalOwnership.GetHeroCount();

        m_HeroImages[_HeroCount - 1].sprite = a_Hero.Hero.SmallPortrait;
        m_HeroImages[_HeroCount - 1].gameObject.SetActive(true);

        UpdateHeroDisplayLowRes();
    }
    void OnHeroSelected(MapHero a_Hero, int a_Index)
    {
        m_Map.ShowUnderground(a_Hero.IsUnderground);

        transform.position = new Vector3
                             (
            a_Hero.transform.position.x - 1.5f,
            a_Hero.transform.position.y + 0.5f,
            transform.position.z
                             );
    }
예제 #10
0
    void SetHeroPartyRepresentationOnTheMap(HeroParty newLeaderParty, City city = null)
    {
        // Create Hero's object on the map
        // create and update Hero Party panel in UI, (no - parent it to city UI)
        //Transform parentCityOnMap = map.Find(transform.name);
        // Create new hero party on map ui
        MapHero newPartyOnMapUI = Instantiate(ObjectsManager.Instance.HeroPartyOnMapTemplate, MapManager.Instance.GetParentTransformByType(GetComponent <MapHero>())).GetComponent <MapHero>();

        // Verify if argument is null
        if (city == null)
        {
            // Assign currently linked city
            city = LCity;
        }
        // adjust position, because city and hero transform have differnet anchor points
        // Get ui world corners
        // 12
        // 03
        Vector3[] worldCorners = new Vector3[4];
        newPartyOnMapUI.GetComponent <RectTransform>().GetWorldCorners(worldCorners);
        // get map hero ui width and heigh
        float newPartyOnMapUIHeight = Mathf.Abs(worldCorners[3].x - worldCorners[0].x);
        float newPartyOnMapUIWidth  = Mathf.Abs(worldCorners[1].y - worldCorners[0].y);
        // Debug.Log(newPartyOnMapUIWidth + ":" + newPartyOnMapUIHeight);
        Vector3 positionAdjustment = new Vector3(newPartyOnMapUIHeight / 2f, newPartyOnMapUIWidth / 2f, 0);

        // set it to the same position as the parent city
        newPartyOnMapUI.transform.position = city.LMapCity.transform.position + positionAdjustment;
        // Create hero label on map
        MapObjectLabel newPartyOnMapLabel = Instantiate(ObjectsManager.Instance.HeroPartyOnMapLabelTemplate, MapManager.Instance.GetParentTransformByType(GetComponent <MapObjectLabel>())).GetComponent <MapObjectLabel>();

        // Link hero to the lable and label to the hero
        newPartyOnMapUI.GetComponent <MapObject>().Label = newPartyOnMapLabel;
        newPartyOnMapLabel.MapObject = newPartyOnMapUI.GetComponent <MapObject>();
        // activate new party on map UI
        newPartyOnMapUI.gameObject.SetActive(true);
        // activate hero label on map
        newPartyOnMapLabel.gameObject.SetActive(true);
        // Link HeroParty to the hero party on the map
        newPartyOnMapUI.LHeroParty = newLeaderParty;
        // Link hero on the map to HeroParty
        newLeaderParty.LMapHero = (newPartyOnMapUI);
        // Link hero on the map to city on the map
        city.LMapCity.GetComponent <MapCity>().LMapHero = newPartyOnMapUI.GetComponent <MapHero>();
        // Link city on the map to hero on the map
        newPartyOnMapUI.GetComponent <MapHero>().lMapCity = city.LMapCity;
        // move hero party to the back, so its UI label is not covering city's UI label
        // but it is in front of map slices
        // newPartyOnMapUI.transform.SetSiblingIndex(1);
        // rename it
        newPartyOnMapUI.gameObject.name = newLeaderParty.GetPartyLeader().GivenName + " " + newLeaderParty.GetPartyLeader().UnitName + " Party";
        // set color according to the player color preference
        newPartyOnMapUI.SetColor(ObjectsManager.Instance.GetPlayerByFaction(newLeaderParty.Faction).PlayerColor);
    }
    public void AddHero(MapHero a_Hero)
    {
        if (m_Heroes.Contains(a_Hero))
        {
            Debug.LogError("Attempted to add hero that's already owned");
            return;
        }

        m_Heroes.Add(a_Hero);

        OnHeroAdded?.Invoke(a_Hero);
    }
예제 #12
0
    //int GetPreviousIndex(MapHero focuseddMapHero, int currentIndex)
    //{
    //    // get previous index
    //    int previousIndex = GetPreviousIndex(currentIndex, mapHeroesList.Count);
    //    // verify if hero on this index is n
    //}

    void ChangeHeroFocus(MapHero nextHero)
    {
        focusedObject = nextHero.gameObject;
        // set name UI
        SetHeroNameUI(nextHero);
        // select hero on map
        MapManager.Instance.SetSelection(MapManager.Selection.PlayerHero, nextHero);
        // reset cursor to normal, because it is changed by MapManager
        CursorController.Instance.SetNormalCursor();
        // set camera focus on a hero on map
        Camera.main.GetComponent <CameraController>().SetCameraFocus(nextHero);
    }
예제 #13
0
    void OnHeroSelected(MapHero a_Hero, int a_Index)
    {
        m_HeroCard.SetActive(true);
        m_InfoCard.SetActive(false);

        m_HeroImage.sprite = a_Hero.Hero.LargePortrait;
        m_HeroName.text    = a_Hero.Hero.Name;

        m_HeroAttack.text     = a_Hero.Hero.Attack.ToString();
        m_HeroDefense.text    = a_Hero.Hero.Defense.ToString();
        m_HeroKnowledge.text  = a_Hero.Hero.Knowledge.ToString();
        m_HeroSpellpower.text = a_Hero.Hero.Spellpower.ToString();
    }
    public void MoveHeroPressed()
    {
        MapHero _SelectedHero = m_LocalOwnership.SelectedHero;

        m_Map.ShowUnderground(_SelectedHero.IsUnderground);

        m_OverworldHighRes.gameObject.SetActive(_SelectedHero.IsUnderground);
        m_OverworldLowRes.gameObject.SetActive(_SelectedHero.IsUnderground);
        m_UndergroundHighRes.gameObject.SetActive(!_SelectedHero.IsUnderground);
        m_UndergroundLowRes.gameObject.SetActive(!_SelectedHero.IsUnderground);

        // Not doing null checking, because the button should only be interactable if a hero is selected
        _SelectedHero.MoveToDestination();
    }
예제 #15
0
    public void FocusOnHero()
    {
        // get first city
        MapHero mapHero = GetFirstHeroOnMap();

        // verify if mapCity is not null
        if (mapHero != null)
        {
            // activate focus on a map city
            SetActive(mapHero);
            // set camera focus on a hero on map
            Camera.main.GetComponent <CameraController>().SetCameraFocus(mapHero);
        }
    }
예제 #16
0
    public void DestroyParty(PartyPanel partyPanel)
    {
        Debug.Log("Destroy party");
        // set variables
        HeroParty      heroParty = partyPanel.GetHeroParty();
        MapHero        heroOnMapRepresentation = heroParty.LMapHero;
        MapObjectLabel heroOnMapLabel          = heroOnMapRepresentation.GetComponent <MapObject>().Label;

        // destroy label
        Destroy(heroOnMapLabel.gameObject);
        // destroy on map party representation
        Destroy(heroOnMapRepresentation.gameObject);
        // destroy party
        Destroy(heroParty.gameObject);
    }
    public void WakeHeroPressed()
    {
        MapHero _SelectedHero = m_LocalOwnership.SelectedHero;

        if (_SelectedHero != null)
        {
            _SelectedHero.IsAsleep = false;
        }

        m_SleepHeroHighRes.gameObject.SetActive(true);
        m_SleepHeroLowRes.gameObject.SetActive(true);
        m_WakeHeroHighRes.gameObject.SetActive(false);
        m_WakeHeroLowRes.gameObject.SetActive(false);

        UpdateNextHeroButton();
    }
예제 #18
0
    public void DismissPartyLeader(UnitSlot unitSlot)
    {
        // Get hero Party UI
        // Structure: LeftHeroParty-3PartyPanel-2Top/Middle/Bottom(Row)-1Back/Front/Wide(Cell)-UnitSlot(this)
        HeroPartyUI heroPartyUI = unitSlot.transform.parent.parent.parent.parent.GetComponent <HeroPartyUI>();
        // Get Hero Party
        HeroParty heroParty = heroPartyUI.LHeroParty;
        // Get Focus Panel
        FocusPanel focusPanel = GetComponentInParent <UIManager>().GetFocusPanelByHeroParty(heroParty);
        // Get Map hero UI
        MapHero mapHero = heroPartyUI.LHeroParty.LMapHero;
        // Get map hero label
        MapObjectLabel mapHeroLabel = mapHero.GetComponent <MapObject>().Label;

        // Deactivate HeroParty UI
        heroPartyUI.gameObject.SetActive(false);
        // verify if focus panel not deactivated already
        // .. find out why it is deactivated earlier and by whom
        if (focusPanel != null)
        {
            // Deactivate Focus Panel
            focusPanel.gameObject.SetActive(false);
        }
        // destroy label
        Destroy(mapHeroLabel.gameObject);
        // Destroy hero's represetnation on map
        Destroy(mapHero.gameObject);
        // Destroy hero's party
        Destroy(heroParty.gameObject);
        // Verify if we are in city and not in hero edit mode
        if (GetComponentInParent <UIManager>().GetHeroPartyByMode(PartyMode.Garnizon, false) != null)
        {
            // Enable Hire leader panel
            transform.parent.Find("HireHeroPanel").gameObject.SetActive(true);
            // Activate focus panel again to display NoPartyInfo
            focusPanel.gameObject.SetActive(true);
        }
        else
        {
            // check if there was only one hero in this screen
            if (LHeroParties.Length == 1)
            {
                // return to the map view with animation
                StartCoroutine(ReturnToTheMapScreenWithAnimation());
            }
        }
    }
예제 #19
0
 public void SetActive(MapHero mapHero)
 {
     // first do cleanup in case if previously were selected other object
     if (focusedObject != null)
     {
         // reset focus panel
         ReleaseFocus();
     }
     // Set focused object
     Debug.Log("Update map focus panel with " + mapHero.name);
     focusedObject = mapHero.gameObject;
     // save currently focused object id to game player it will be needed for game load and turns switch
     TurnsManager.Instance.GetActivePlayer().FocusedObjectID = focusedObject.gameObject.GetInstanceID();
     // transform.root.Find("Managers").GetComponent<TurnsManager>().GetActivePlayer().FocusedObjectID = focusedObject.gameObject.GetInstanceID();
     // Set hero name
     SetHeroNameUI(mapHero);
     // Set hero additinal info
     SetAdditionalInfo(mapHero);
     // verify if party is not on hold
     if (mapHero.LHeroParty.HoldPosition != true)
     {
         // Activate hold position control
         transform.Find("FocusedObjectControl/HoldPosition").gameObject.SetActive(true);
     }
     else
     {
         // Display that party is on hold information
         transform.Find("FocusedObjectControl/HoldingPositionInfo").gameObject.SetActive(true);
     }
     // Set list of map heroes
     mapHeroesList = new List <MapHero>();
     // Loop through all map heroes
     foreach (MapHero checkedHero in MapManager.Instance.GetComponentsInChildren <MapHero>())
     {
         // verify if mHero faction is the same as for active hero and that hero is not on hold
         if (mapHero.LHeroParty.Faction == checkedHero.LHeroParty.Faction && checkedHero.LHeroParty.HoldPosition != true)
         {
             mapHeroesList.Add(checkedHero);
         }
     }
     // verify if there is more than 1 hero of the same faction
     if (mapHeroesList.Count > 1)
     {
         // activate next and previous controls
         ActivateNextAndPreviousControls();
     }
 }
예제 #20
0
 public void SetCameraFocus(MapHero mapHero)
 {
     // Remove previous focus
     ResetFocusedObject();
     // save followed hero on map
     followedHeroOnMap = mapHero;
     // verify if mapHero is not null
     if (mapHero != null)
     {
         // reset camera is focused
         cameraIsFocused = false;
         // set followed object position
         followedObjectTransform = mapHero.transform;
         // start set focus animation
         MapManager.Instance.Queue.Run(WaitUntilCameraIsFocused(minDistanceToTheHero));
     }
 }
    void OnHeroRemoved(MapHero a_Hero)
    {
        List <MapHero> _Heroes = m_LocalOwnership.GetHeroes();

        for (int i = 0; i < _Heroes.Count; i++)
        {
            m_HeroImages[i].sprite = _Heroes[i].Hero.SmallPortrait;
            m_HeroImages[i].gameObject.SetActive(true);
        }

        for (int i = _Heroes.Count; i < 8; i++)
        {
            m_HeroImages[i].gameObject.SetActive(false);
        }

        UpdateHeroDisplayLowRes();
    }
예제 #22
0
 public void BreakHoldPosition(MapHero mapHero)
 {
     // stop holding position
     mapHero.LHeroParty.HoldPosition = false;
     // add hero party to the list
     mapHeroesList.Add(mapHero);
     // Activate hold position control
     transform.Find("FocusedObjectControl/HoldPosition").gameObject.SetActive(true);
     // Deactivate that party is on hold information
     transform.Find("FocusedObjectControl/HoldingPositionInfo").gameObject.SetActive(false);
     // verify if there is more than 1 hero of the same faction
     if (mapHeroesList.Count > 1)
     {
         // activate next and previous controls
         ActivateNextAndPreviousControls();
     }
 }
예제 #23
0
    public void CaptureAndEnterCity()
    {
        Debug.Log("BattleScreen: EnterCity");
        // remove dead units from city garnizon's heroParty
        enemyPartyPanel.transform.parent.GetComponent <HeroPartyUI>().LHeroParty.RemoveDeadPartyUnits();
        // Change city faction to player's faction
        enemyPartyPanel.GetCity().CityCurrentFaction = playerPartyPanel.GetHeroParty().Faction;
        // Prepare variables to be used later
        MapHero mapHero = playerPartyPanel.GetHeroParty().LMapHero;
        MapCity destinationCityOnMap = enemyPartyPanel.GetCity().LMapCity;

        //MapManager mapManager = GetMapManager();
        // execute default on battle exit function
        DefaultOnBattleExit();
        // Trigger map hero move to and enter city
        MapManager.Instance.MapHeroMoveToAndEnterCity(mapHero, destinationCityOnMap);
    }
    public void RemoveHero(MapHero a_Hero)
    {
        if (!m_Heroes.Contains(a_Hero))
        {
            Debug.LogError("Attempted to remove hero that isn't owned");
            return;
        }

        m_Heroes.Remove(a_Hero);

        if (SelectedHero == a_Hero)
        {
            SelectedHero.OnDeselected();
            OnHeroDeselected?.Invoke(a_Hero);
            SelectedHero = null;
        }

        OnHeroRemoved?.Invoke(a_Hero);
    }
    void OnHeroSelected(MapHero a_Hero, int a_Index)
    {
        m_SelectedHero = a_Hero;
        m_SelectedTown = null;

        m_SelectedBorder.SetActive(true);
        m_SelectedBorder.transform.position = m_HeroImages[a_Index].transform.position;

        if (a_Index >= m_HeroUIIndexLowRes + 5)
        {
            m_HeroUIIndexLowRes = 3;
        }
        else if (a_Index < m_HeroUIIndexLowRes)
        {
            m_HeroUIIndexLowRes = a_Index;
        }

        UpdateHeroDisplayLowRes();
    }
    void OnHeroDeselected(MapHero a_Hero)
    {
        if (a_Hero != m_SelectedHero)
        {
            Debug.LogError($"!! EVENTS ARE BROKE");
        }

        a_Hero.OnPathCreated   -= OnPathCreated;
        a_Hero.OnPathRemoved   -= OnPathRemoved;
        a_Hero.OnStartMovement -= OnStartMovement;

        m_MoveHeroHighRes.interactable = false;
        m_MoveHeroLowRes.interactable  = false;

        m_SleepHeroHighRes.interactable = false;
        m_SleepHeroLowRes.interactable  = false;
        m_WakeHeroHighRes.interactable  = false;
        m_WakeHeroLowRes.interactable   = false;

        m_SpellbookHighRes.interactable = false;
        m_SpellbookLowRes.interactable  = false;
    }
예제 #27
0
    public void EnterBattle(MapHero playerOnMap, MapCity enemyCityOnMap)
    {
        // gen enemy party, which can fight
        HeroParty enemyHeroParty = GetPartyInCityWhichCanFight(enemyCityOnMap);

        // verify if there are units in party protecting this city, which can fight
        // it is possible that city is not protected
        if (enemyHeroParty != null)
        {
            // city is protected
            // get hero's parties
            HeroParty playerHeroParty = playerOnMap.LHeroParty;
            // proceed with preparations for the battle
            EnterBattleCommon(playerHeroParty, enemyHeroParty);
        }
        else
        {
            // city is not protected
            // no need to battle
            // move to and enter city
            CaptureAndEnterCity();
        }
    }
예제 #28
0
 public void ShowNext()
 {
     // verify focused object type
     if (focusedObject.GetComponent <MapHero>())
     {
         Debug.Log("Show next hero");
         // get next hero from the list
         MapHero nextHero = mapHeroesList[GetNextIndex(GetSelectedHeroIndex(), mapHeroesList.Count)];
         // set focused object to new hero
         ChangeHeroFocus(nextHero);
     }
     else if (focusedObject.GetComponent <MapCity>())
     {
         Debug.Log("Show next city");
         // get next city from the list
         MapCity nextCity = mapCitiesList[GetNextIndex(GetSelectedCityIndex(), mapCitiesList.Count)];
         // set focused object to new city
         ChangeCityFocus(nextCity);
     }
     else
     {
         Debug.LogError("Unknwon focused object type");
     }
 }
예제 #29
0
 public void ShowPrevious()
 {
     // verify focused object type
     if (focusedObject.GetComponent <MapHero>())
     {
         Debug.Log("Show previous hero");
         // get previous hero from the list
         MapHero previousHero = mapHeroesList[GetPreviousIndex(GetSelectedHeroIndex(), GetSelectedHeroIndex())];
         // set focused object to new hero
         ChangeHeroFocus(previousHero);
     }
     else if (focusedObject.GetComponent <MapCity>())
     {
         Debug.Log("Show previous city");
         // get previous city from the list
         MapCity previousCity = mapCitiesList[GetPreviousIndex(GetSelectedCityIndex(), mapCitiesList.Count)];
         // set focused object to new city
         ChangeCityFocus(previousCity);
     }
     else
     {
         Debug.LogError("Unknwon focused object type");
     }
 }
예제 #30
0
    public void ActivateAdvance(MapHero mapHero)
    {
        Debug.Log("Show Party Info");
        //// clone hero panel and place it into the middle placeholder
        //SetPartyPanelPosition(mapHero.LHeroParty.Find("PartyPanel"), transform.Find("SinglePartyPlaceholder"));
        // Get Lefto Hero Party UI
        HeroPartyUI leftHeroPartyUI = transform.root.Find("MiscUI/LeftHeroParty").GetComponent <HeroPartyUI>();

        // assign HeroParty to left hero party UI
        leftHeroPartyUI.LHeroParty = mapHero.LHeroParty;
        // Get Party Panel
        PartyPanel partyPanel = leftHeroPartyUI.GetComponentInChildren <PartyPanel>(true);
        // Get new position
        RectTransform newPosition = transform.Find("SinglePartyPlaceholder").GetComponent <RectTransform>();

        // Change Party Panel position to new
        SetPartyPanelPosition(partyPanel, newPosition);
        // activate left hero party UI
        leftHeroPartyUI.gameObject.SetActive(true);
        // deactivate inventory
        leftHeroPartyUI.GetComponentInChildren <PartyInventoryUI>(true).gameObject.SetActive(false);
        //// Activate placeholder to be used as background
        //transform.Find("SinglePartyPlaceholder").gameObject.SetActive(true);
    }