public void Initialize(ScenarioObject a_ScenarioObject, GameReferences a_GameReferences)
    {
        m_GameReferences = a_GameReferences;

        gameObject.name = a_ScenarioObject.Template.Name;

        m_SpriteRenderer.sortingOrder = -32767 + a_ScenarioObject.SortOrder;

        uint _ColorIndex = a_ScenarioObject.DwellingOwner;

        // Seems neutral objects can represent multiple different values
        if (_ColorIndex > 8)
        {
            _ColorIndex = 8;
        }

        m_SpriteRenderer.material.SetColor("_PlayerColor", m_PlayerColors.Colors[_ColorIndex]);

        var _Operation = Addressables.LoadAssetAsync <MapObjectVisualData>($"MapObjects/{gameObject.name}.asset");

        // Synchonously, because underground objects are initially disabled, which break their coroutines
        MapObjectVisualData _Data = _Operation.WaitForCompletion();

        if (_Operation.Status == UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationStatus.Failed)
        {
            Debug.Log(gameObject.name);
        }
        else
        {
            m_Renderer.SetSprites(_Operation.Result.Sprites);
            m_ShadowRenderer.SetSprites(_Operation.Result.ShadowSprites);
        }
    }
Beispiel #2
0
    void Initialize()
    {
        gameObject.name = Hero.Name;

        if (!IsPrison)
        {
            m_HeroRenderer.sprite       = Hero.HeroVisualData.IdleSprites[0];
            m_HeroShadowRenderer.sprite = Hero.HeroVisualData.ShadowIdleSprites[0];

            HeroFlagVisualData _FlagData = m_PlayerColors.Flags[PlayerIndex];

            m_FlagRenderer.SetSprites(_FlagData.IdleSprites);
            m_FlagRenderer.transform.localPosition = new Vector3(Hero.HeroVisualData.IdleFlagOffsets[m_Direction].x, Hero.HeroVisualData.IdleFlagOffsets[m_Direction].y, 0);
        }
        else
        {
            m_HeroRenderer.sprite       = m_PrisonVisualData.m_Sprites[0];
            m_HeroShadowRenderer.sprite = m_PrisonVisualData.m_ShadowSprites[0];
        }

        if (PlayerIndex == m_GameSettings.LocalPlayerIndex)
        {
            m_GameReferences.LocalOwnership.AddHero(this);
        }

        m_LocalPathfindingVersion = -1;
    }
Beispiel #3
0
    public void Initialize(ScenarioObject a_ScenarioObject, GameReferences a_GameReferences)
    {
        gameObject.name = a_ScenarioObject.Template.Name;

        m_SpriteRenderer.sortingOrder = -32767 + a_ScenarioObject.SortOrder;

        switch (a_ScenarioObject.Template.Name)
        {
        case "avtwood0":
            Resource = m_Resources.Resources[0];
            break;

        case "avtmerc0":
            Resource = m_Resources.Resources[1];
            break;

        case "avtore0":
            Resource = m_Resources.Resources[2];
            break;

        case "avtsulf0":
            Resource = m_Resources.Resources[3];
            break;

        case "avtcrys0":
            Resource = m_Resources.Resources[4];
            break;

        case "avtgems0":
            Resource = m_Resources.Resources[5];
            break;

        case "avtgold0":
            Resource = m_Resources.Resources[6];
            break;

        default:
            Resource = m_Resources.Resources[Random.Range(0, m_Resources.Resources.Count)];
            break;
        }

        m_Renderer.SetSprites(Resource.m_Sprites);
        m_ShadowRenderer.SetSprites(Resource.m_ShadowSprites);

        m_DynamicObstacle.Initialize(a_GameReferences.Pathfinding, this);
    }
    public void Initialize(ScenarioObject a_ScenarioObject, GameReferences a_GameReferences, Vector2Int a_ShipyardSpot)
    {
        m_GameReferences = a_GameReferences;

        m_SpriteRenderer.sortingOrder = -32767 + a_ScenarioObject.SortOrder;

        PlayerIndex   = a_ScenarioObject.Town.Owner;
        IsUnderground = a_ScenarioObject.IsUnderground;

        ShipyardSpot     = a_ShipyardSpot;
        CanBuildShipyard = a_ShipyardSpot != Vector2Int.zero;

        // Neutral objects are 255
        if (PlayerIndex == 255)
        {
            PlayerIndex = 8;
        }

        switch (a_ScenarioObject.Template.Name)
        {
        case "avcranx0":
        case "avcranz0":
        case "avcrand0":
            if (PlayerIndex != 8)
            {
                Faction = m_GameSettings.Players.First(a_Player => a_Player.Index == PlayerIndex).Faction;
            }
            else
            {
                Faction = m_Factions.Factions[Random.Range(0, m_Factions.Factions.Count)];
            }
            break;

        case "avccasx0":
        case "avccasz0":
        case "avccast0":
            Faction = m_Factions.Factions[0];
            break;

        case "avcramx0":
        case "avcramz0":
        case "avcramp0":
            Faction = m_Factions.Factions[1];
            break;

        case "avctowx0":
        case "avctowz0":
        case "avctowr0":
            Faction = m_Factions.Factions[2];
            break;

        case "avcinfx0":
        case "avcinfz0":
        case "avcinft0":
            Faction = m_Factions.Factions[3];
            break;

        case "avcnecx0":
        case "avcnecz0":
        case "avcnecr0":
            Faction = m_Factions.Factions[4];
            break;

        case "avcdunx0":
        case "avcdunz0":
        case "avcdung0":
            Faction = m_Factions.Factions[5];
            break;

        case "avcstrx0":
        case "avcstrz0":
        case "avcstro0":
            Faction = m_Factions.Factions[6];
            break;

        case "avcftrx0":
        case "avcforz0":
        case "avcftrt0":
            Faction = m_Factions.Factions[7];
            break;

        case "avchforx":
        case "avchforz":
        case "avchfor0":
            Faction = m_Factions.Factions[8];
            break;
        }

        m_SpriteRenderer.material.SetColor("_PlayerColor", m_PlayerColors.Colors[PlayerIndex]);

        if (a_ScenarioObject.Town.HasCustomBuildings)
        {
            Buildings = a_ScenarioObject.Town.CustomBuildings;
        }
        else
        {
            Buildings        = new BuiltBuildings();
            Buildings.Tavern = true;

            if (a_ScenarioObject.Town.HasFort)
            {
                Buildings.Fort      = true;
                Buildings.Dwelling1 = true;

                int _Random = Random.Range(0, 3);

                if (_Random == 0)
                {
                    Buildings.Dwelling2 = true;
                }
            }
        }

        if (Buildings.Capitol)
        {
            m_Renderer.SetSprites(Faction.MapVisualDataCapitol.m_Sprites);
            m_ShadowRenderer.SetSprites(Faction.MapVisualDataCapitol.m_ShadowSprites);
        }
        else if (Buildings.Fort)
        {
            m_Renderer.SetSprites(Faction.MapVisualData.m_Sprites);
            m_ShadowRenderer.SetSprites(Faction.MapVisualData.m_ShadowSprites);
        }
        else
        {
            m_Renderer.SetSprites(Faction.MapVisualDataNoFort.m_Sprites);
            m_ShadowRenderer.SetSprites(Faction.MapVisualDataNoFort.m_ShadowSprites);
        }

        if (a_ScenarioObject.Town.Name != "")
        {
            gameObject.name = a_ScenarioObject.Town.Name;
        }
        else
        {
            gameObject.name = Faction.name;
        }

        if (PlayerIndex == m_GameSettings.LocalPlayerIndex)
        {
            m_GameReferences.LocalOwnership.AddTown(this);
        }
    }
Beispiel #5
0
    public void Initialize(ScenarioObject a_ScenarioObject, GameReferences a_GameReferences)
    {
        m_GameReferences = a_GameReferences;

        m_SpriteRenderer.sortingOrder = -32767 + a_ScenarioObject.SortOrder;

        switch (a_ScenarioObject.Template.Name)
        {
        case "avwmon1":
            List <Monster> _Tier1Monsters = m_Monsters.Monsters.Where((a_Monster) => a_Monster.Tier == 0).ToList();
            Monster         = _Tier1Monsters[Random.Range(0, _Tier1Monsters.Count)];
            gameObject.name = Monster.MapVisualData.name;
            break;

        case "avwmon2":
            List <Monster> _Tier2Monsters = m_Monsters.Monsters.Where((a_Monster) => a_Monster.Tier == 1).ToList();
            Monster         = _Tier2Monsters[Random.Range(0, _Tier2Monsters.Count)];
            gameObject.name = Monster.MapVisualData.name;
            break;

        case "avwmon3":
            List <Monster> _Tier3Monsters = m_Monsters.Monsters.Where((a_Monster) => a_Monster.Tier == 2).ToList();
            Monster         = _Tier3Monsters[Random.Range(0, _Tier3Monsters.Count)];
            gameObject.name = Monster.MapVisualData.name;
            break;

        case "avwmon4":
            List <Monster> _Tier4Monsters = m_Monsters.Monsters.Where((a_Monster) => a_Monster.Tier == 3).ToList();
            Monster         = _Tier4Monsters[Random.Range(0, _Tier4Monsters.Count)];
            gameObject.name = Monster.MapVisualData.name;
            break;

        case "avwmon5":
            List <Monster> _Tier5Monsters = m_Monsters.Monsters.Where((a_Monster) => a_Monster.Tier == 4).ToList();
            Monster         = _Tier5Monsters[Random.Range(0, _Tier5Monsters.Count)];
            gameObject.name = Monster.MapVisualData.name;
            break;

        case "avwmon6":
            List <Monster> _Tier6Monsters = m_Monsters.Monsters.Where((a_Monster) => a_Monster.Tier == 5).ToList();
            Monster         = _Tier6Monsters[Random.Range(0, _Tier6Monsters.Count)];
            gameObject.name = Monster.MapVisualData.name;
            break;

        case "avwmon7":
            List <Monster> _Tier7Monsters = m_Monsters.Monsters.Where((a_Monster) => a_Monster.Tier == 6).ToList();
            Monster         = _Tier7Monsters[Random.Range(0, _Tier7Monsters.Count)];
            gameObject.name = Monster.MapVisualData.name;
            break;

        case "avwmrnd0":
            Monster = m_Monsters.Monsters[Random.Range(0, m_Monsters.Monsters.Count)];
            break;

        default:
            Monster = m_Monsters.Monsters.FirstOrDefault((a_Monster) => a_Monster.MapVisualData.name == a_ScenarioObject.Template.Name);
            break;
        }

        int _Offset = Random.Range(0, Monster.MapVisualData.m_Sprites.Length);

        m_Renderer.SetSprites(Monster.MapVisualData.m_Sprites);
        m_Renderer.SetOffset(_Offset);
        m_ShadowRenderer.SetSprites(Monster.MapVisualData.m_ShadowSprites);
        m_ShadowRenderer.SetOffset(_Offset);

        m_DynamicObstacle.Initialize(m_GameReferences.Pathfinding, this);

        gameObject.name = Monster.name;
    }