public void Init(GameObject gameObject)
 {
     cardMovementRef         = gameObject.GetComponent <CardMovementReferences> ();
     gameRef                 = gameObject.GetComponent <GameReferences> ();
     shouldAllowCardDragging = true;
     tappedCardsDictionary   = new Dictionary <int, GameObject> ();
 }
Esempio n. 2
0
 private void Awake()
 {
     refs             = this;
     PlayerGameObject = GameObject.FindGameObjectWithTag("Player").transform.root.gameObject;
     agent            = PlayerGameObject.GetComponent <NavMeshAgent>();
     rb = PlayerGameObject.GetComponent <Rigidbody>();
 }
Esempio n. 3
0
 public void Init(GameObject gameObject)
 {
     gameRef     = gameObject.GetComponent <GameReferences> ();
     gorillaAnim = gameRef.gorilla.GetComponent <Animator> ();
     shouldAllowGorillaMovement = true;
     isKilled = false;
 }
    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);
        }
    }
Esempio n. 5
0
    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;

        if (a_ScenarioObject.Template.IsLowPrioritySortOrder)
        {
            m_SpriteRenderer.sortingLayerName = "MapLowPriorityObjects";
        }

        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
        {
            Renderer.SetSprites(_Operation.Result.Sprites);
            ShadowRenderer.SetSprites(_Operation.Result.ShadowSprites);
        }
    }
Esempio n. 6
0
    public void Initialize(Hero a_Hero, int a_PlayerIndex, int a_PosX, int a_PosY, bool a_IsUnderground, GameReferences a_GameReferences)
    {
        MouseCollision    = new byte[6];
        MouseCollision[0] = 0b00000000;
        MouseCollision[1] = 0b00000000;
        MouseCollision[2] = 0b00000000;
        MouseCollision[3] = 0b00000000;
        MouseCollision[4] = 0b00000000;
        MouseCollision[5] = 0b01000000;

        InteractionCollision    = new byte[6];
        InteractionCollision[0] = 0b00000000;
        InteractionCollision[1] = 0b00000000;
        InteractionCollision[2] = 0b00000000;
        InteractionCollision[3] = 0b00000000;
        InteractionCollision[4] = 0b00000000;
        InteractionCollision[5] = 0b01000000;

        Hero          = a_Hero;
        PlayerIndex   = a_PlayerIndex;
        IsUnderground = a_IsUnderground;

        m_GameReferences = a_GameReferences;

        transform.position = new Vector3(a_PosX + 0.5f, -a_PosY - 0.5f, 0);
        m_PathfindingPos   = new Vector2Int(a_PosX - 1, a_PosY);

        m_DynamicObstacle.Initialize(m_GameReferences.Pathfinding, this);
        m_DynamicObstacle.AddInteractedNode(m_PathfindingPos.x, m_PathfindingPos.y, a_IsUnderground);

        Initialize();
    }
Esempio n. 7
0
 //Loads the game
 public void LoadGame(GameObject gameObject)
 {
     gameContextObject = gameObject;
     IsUIOpened        = false;
     gameRef           = gameContextObject.GetComponent <GameReferences> ();
     LeaderboardManager.AuthenticateToGameCenter();
     GameStartScreenController.Instance.ShowGameStartScreen(gameRef.gameStartScreenRef);
 }
 public void LoadGame(GameObject gameObject)
 {
     gameContextObject = gameObject;
     gameRef           = gameContextObject.GetComponent <GameReferences> ();
     GameModel.Instance.AreGameVariableReady = true;
     UpdatePlayersRevenueLabels();
     GameStartScreenController.Instance.ShowGameStartMenu(gameRef.gameStartScreenRef);
 }
 public void Init(GameReferences gameReferences)
 {
     gameRef = gameReferences;
     shouldStartGameMechanics        = true;
     this.ShouldStartOscillatingLine = true;
     this.IsScreenTapped             = false;
     this.IsValidTap = false;
 }
Esempio n. 10
0
    public void Awake()
    {
        // References
        GameReferences.SetSettingsReference(this);
        GameReferences.SetPlayerReference(player);

        player.maxDistance = resetDistance;
        road.maxDistance   = resetDistance;
    }
Esempio n. 11
0
    public void LoadGame(GameObject gameObject)
    {
        gameContextObject = gameObject;
        gameRef           = gameContextObject.GetComponent <GameReferences> ();
        gameRef.movingLine.GetComponent <RectTransform>().anchoredPosition = new Vector3(GameModel.Instance.LineMinPositionX, 0.0f, 0.0f);
        gameRef.scoreLabel.text = UpdateScoreLabel();
        GameStartScreenController.Instance.ShowGameStartScreen(gameRef.gameStartScreenRef);
//		RequestInterstitial ();
    }
Esempio n. 12
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 LoadGame(GameObject gameObject)
 {
     gameContextObject = gameObject;
     gameRef           = gameContextObject.GetComponent <GameReferences> ();
     GameStartScreenController.Instance.ShowGameStartMenu(gameRef.gameStartScreenRef);
 }
    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);
        }
    }
Esempio n. 15
0
 private void Awake()
 {
     Instance = this;
 }
Esempio n. 16
0
 public void SetReference(GameReferences references)
 {
     this.References = references;
 }
Esempio n. 17
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;
    }
Esempio n. 18
0
    public void Initialize(ScenarioObject a_ScenarioObject, GameReferences a_GameReferences)
    {
        PlayerIndex = a_ScenarioObject.Hero.PlayerIndex;

        m_GameReferences = a_GameReferences;

        if (a_ScenarioObject.Template.Name == "avxprsn0")
        {
            IsPrison = true;
        }

        Hero _BaseHero;

        bool _ClaimedMainHero = false;

        if (a_ScenarioObject.Hero.ID != 255)
        {
            _BaseHero = m_Heroes.Heroes.First((a_Hero) => a_Hero.Hero.ID == a_ScenarioObject.Hero.ID).Hero;
        }
        else
        {
            GameSettings.Player _Player = m_GameSettings.Players.First((a_Player) => a_Player.Index == PlayerIndex);

            if (m_GameSettings.Scenario.PlayerInfo[PlayerIndex].IsMainHeroRandom &&
                _Player.SetMapHero)
            {
                _BaseHero          = _Player.Hero;
                _Player.SetMapHero = false;
                _ClaimedMainHero   = true;
            }
            else
            {
                _BaseHero = HeroPool.GetRandomHero(PlayerIndex, m_GameSettings.Players.First((a_Player) => a_Player.Index == PlayerIndex).Faction, true);
            }
        }

        Hero = new Hero();

        Hero.ID             = _BaseHero.ID;
        Hero.Faction        = _BaseHero.Faction;
        Hero.HeroVisualData = _BaseHero.HeroVisualData;

        if (a_ScenarioObject.Hero.Name != "")
        {
            Hero.Name = a_ScenarioObject.Hero.Name;
        }
        else
        {
            Hero.Name = _BaseHero.Name;
        }

        if (a_ScenarioObject.Hero.Portrait != 255)
        {
            Hero _Hero = m_Heroes.Heroes.First((a_Hero) => a_Hero.Hero.ID == a_ScenarioObject.Hero.Portrait).Hero;
            Hero.SmallPortrait = _Hero.SmallPortrait;
            Hero.LargePortrait = _Hero.LargePortrait;
        }
        else
        {
            Hero.SmallPortrait = _BaseHero.SmallPortrait;
            Hero.LargePortrait = _BaseHero.LargePortrait;
        }

        if (a_ScenarioObject.Hero.HasCustomPrimarySkills)
        {
            Hero.Attack     = a_ScenarioObject.Hero.Attack;
            Hero.Defense    = a_ScenarioObject.Hero.Defense;
            Hero.Spellpower = a_ScenarioObject.Hero.Spellpower;
            Hero.Knowledge  = a_ScenarioObject.Hero.Knowledge;
        }
        else
        {
            Hero.Attack     = _BaseHero.Attack;
            Hero.Defense    = _BaseHero.Defense;
            Hero.Spellpower = _BaseHero.Spellpower;
            Hero.Knowledge  = _BaseHero.Knowledge;
        }

        if (!_ClaimedMainHero)
        {
            HeroPool.ClaimHero(Hero);
        }

        m_DynamicObstacle.Initialize(m_GameReferences.Pathfinding, this);

        m_PathfindingPos = new Vector2Int(a_ScenarioObject.PosX - 1, a_ScenarioObject.PosY);

        Initialize();
    }