Example #1
0
 // Use this for initialization
 void Start()
 {
     controller         = GameObject.Find("WSController").GetComponent <WSController>();
     uiHandler          = controller.GetComponent <WSUIHandler>();
     unitOrWeapon       = transform.FindChild("UnitOrWeapon").GetComponent <SpriteRenderer>();
     unitOrWeaponBorder = transform.FindChild("UnitOrWeaponBorder").GetComponent <SpriteRenderer>();
 }
Example #2
0
        void Start()
        {
            uiHandler = GameObject.Find("WSController").GetComponent <WSUIHandler>();
            spriteContainerTransform = transform.FindChild("SpriteHolder");
            UnitBackground           = spriteContainerTransform.FindChild("Background").GetComponent <SpriteRenderer>();
            UnitBorder               = spriteContainerTransform.FindChild("Border").GetComponent <SpriteRenderer>();
            UnitBorder.color         = Config.Palette.border;
            BaseTypeSprite           = spriteContainerTransform.FindChild("Base Type").GetComponent <SpriteRenderer>();
            BaseTypeSprite.color     = Config.Palette.unitIconFill;
            BaseTypeBorder           = BaseTypeSprite.transform.FindChild("Base Type Border").GetComponent <SpriteRenderer>();
            BaseTypeBorder.color     = Config.Palette.border;
            WeaponSprite             = spriteContainerTransform.FindChild("Weapon").GetComponent <SpriteRenderer>();
            WeaponSprite.color       = Config.Palette.unitIconFill;
            WeaponSpriteBorder       = WeaponSprite.transform.FindChild("Weapon Border").GetComponent <SpriteRenderer>();
            WeaponSpriteBorder.color = Config.Palette.border;

            initialized     = true;
            UnitType        = _unitType;
            WeaponType      = _weaponType;
            PlayerOwner     = _playerOwner;
            VisiblePosition = _visiblePosition;
            Active          = _active;
            LitBorder       = _litBorder;
        }
Example #3
0
        void Start()
        {
            //Netcode and playerdirectory
            Vaults.wsUnitList = new List <WSUnitDescriptor>();
            netPlayersInVault = new List <int>();

            GameObject matchControllerObject = GameObject.Find("MatchController");

            if (matchControllerObject != null)
            {
                matchController = matchControllerObject.GetComponent <Deft.Netcode.MatchController>();
            }
            if (matchController != null)
            {
                playerDirectory = new Dictionary <int, PlayerType>();
                foreach (int player in matchController.netRepPlayers.Keys)
                {
                    if (matchController.whoAmI == player)
                    {
                        playerDirectory.Add(player, PlayerType.Local);
                    }
                    else
                    {
                        playerDirectory.Add(player, PlayerType.Online);
                    }
                }
            }
            else if (Vaults.playerDirectory != null)
            {
                playerDirectory = Vaults.playerDirectory;
            }
            else
            {
                playerDirectory = new Dictionary <int, PlayerType>();
                playerDirectory.Add(1, PlayerType.Local);
                playerDirectory.Add(2, PlayerType.AI);
            }

            //Variable instantiation
            uiHandler = GetComponent <WSUIHandler>();
            _hexGrid  = new Dictionary <Vector2, WSHexManager>();
            _units    = new Dictionary <int, List <WSUnitManager> >();

            //Load inert hexgrid for visual aid to players
            LoadGrid();
            uiHandler.Initialize();

            //Choose the player whose turn it is
            if (matchController != null)
            {
                activePlayer = matchController.whoAmI;
                if (activePlayer == 2)   // Have the turn button show correctly in network mode

                {
                    UnityEngine.UI.ColorBlock colorBlock = UnityEngine.UI.ColorBlock.defaultColorBlock;
                    colorBlock.normalColor   = Config.Palette.PlayerColor(2);
                    playerTurnDisplay.colors = colorBlock;
                    playerTurnDisplay.transform.FindChild("PlayerTurnText").GetComponent <UnityEngine.UI.Text>().text = "Player 2 Turn";
                }
            }
            else
            {
                activePlayer = 1;
            }
            draftPhase = 1;

            //Load units to have weapons and base types modified by players
            _units[1] = new List <WSUnitManager>();
            _units[2] = new List <WSUnitManager>();
            LoadUnitPositions();
            EstablishDraftVisibility(activePlayer);
            uiHandler.CenterCameraOnUnits(activePlayer);

            SelectedUnitIter = 0;
        }