Exemplo n.º 1
0
        private void ChangeTeamColor(ControllerInfo info, int colorIteration)
        {
            int teamIndex      = 0;
            int otherTeamIndex = 1;

            if (info.PlayerIndex == 2 || info.PlayerIndex == 3)
            {
                teamIndex      = 1;
                otherTeamIndex = 0;
            }
            int colorSchemesLength = m_colorSchemeDataAsset.Content.ColorSchemes.Length;

            m_teamColorIndexes[teamIndex] += colorIteration;
            m_teamColorIndexes[teamIndex]  = (m_teamColorIndexes[teamIndex] + colorSchemesLength) % colorSchemesLength;
            if (m_teamColorIndexes[teamIndex] == m_teamColorIndexes[otherTeamIndex])
            {
                m_teamColorIndexes[teamIndex] += colorIteration;
                m_teamColorIndexes[teamIndex]  = (m_teamColorIndexes[teamIndex] + colorSchemesLength) % colorSchemesLength;
            }
            m_teamColorSpriteCmp[teamIndex].Color1 = m_colorSchemeDataAsset.Content.ColorSchemes[m_teamColorIndexes[teamIndex]].Color1;
        }
Exemplo n.º 2
0
        public void AddController(MenuController ctrl)
        {
            if (m_ctrlInfos.ContainsKey(ctrl))
            {
                return;
            }

            ControllerInfo info = new ControllerInfo();

            info.State           = ControllerState.None;
            info.Controller      = ctrl;
            info.ControllerIndex = m_ctrlInfos.Keys.Count;
            info.PlayerIndex     = -1;

            Sprite edgeSprite = Sprite.Create("Graphics/controlSprite.lua::Sprite");

            info.SpriteCmp = new SpriteComponent(edgeSprite, "Menu");
            if (ctrl.Type == InputType.Gamepad)
            {
                edgeSprite.SetAnimation("Gamepad");
            }
            else
            {
                edgeSprite.SetAnimation("Keyboard");
            }
            info.SpriteCmp.Visible      = false;
            info.SpriteCmp.Sprite.Scale = iconSpriteScale * Vector2.One;
            Menu.Owner.Attach(info.SpriteCmp);

            info.TextCmp            = new TextComponent("Menu");
            info.TextCmp.Style      = m_style;
            info.TextCmp.Alignement = TextAlignementHorizontal.Center;
            info.TextCmp.Text       = GetControllerText(ctrl);
            info.TextCmp.Visible    = false;
            Menu.Owner.Attach(info.TextCmp);

            m_ctrlInfos.Add(ctrl, info);
        }