Beispiel #1
0
        public void Init()
        {
            Owner.Attach(new RigidBodyComponent());

            m_font = Engine.AssetManager.Get <SpriteFont>("Graphics/DisplayFont");

            if (m_preview.Content.Size == ArenaSize.Large)
            {
                m_arenaHalfSize = new Vector2(800, 320);
            }
            else if (m_preview.Content.Size == ArenaSize.Normal)
            {
                m_arenaHalfSize = new Vector2(480, 320);
            }

            InitGoals();
            InitGeometry();
            InitPhysics();
            InitLaunchers();

            if (m_description.Content.Material != null && m_description.Content.AO != null)
            {
                ColorMaskedSprite arenaMask = new ColorMaskedSprite(Sprite.CreateFromTexture(m_description.Content.AO), "Background");
                arenaMask.Sprite.Scale = Vector2.One * m_description.Content.Scale;
                arenaMask.Mask         = m_description.Content.Material;
                arenaMask.Color1       = m_colorScheme.Color2;
                arenaMask.Color2       = Game.GameManager.Teams[0].ColorScheme.Color1.SetSaturation(0.5f);
                arenaMask.Color3       = Game.GameManager.Teams[1].ColorScheme.Color1.SetSaturation(0.5f);
                arenaMask.Color4       = m_colorScheme.Color1;

                Owner.Attach(arenaMask);
            }

            // TODO del
            else
            {
                if (m_description.Content.Background != null)
                {
                    Owner.Attach(new SpriteComponent(Sprite.CreateFromTexture(m_description.Content.Background)));
                }

                if (m_description.Content.Overlay != null)
                {
                    m_overlay = new SpriteComponent(Sprite.CreateFromTexture(m_description.Content.Overlay), "GroundOverlay0");
                    Owner.Attach(m_overlay);
                }

                if (m_description.Content.OverlayAlt != null)
                {
                    m_overlayAlt = new SpriteComponent(Sprite.CreateFromTexture(m_description.Content.OverlayAlt), "GroundOverlay0");
                    Owner.Attach(m_overlayAlt);
                    m_overlayAlt.Visible = false;
                }
            }

            InitTimerAndScore();

            //InitCup();
        }
Beispiel #2
0
        public void SwitchTeamSides()
        {
            ColorMaskedSprite arenaMaskedSprite = Owner.FindComponent <ColorMaskedSprite>();
            Color             tmp = arenaMaskedSprite.Color2;

            arenaMaskedSprite.Color2 = arenaMaskedSprite.Color3;
            arenaMaskedSprite.Color3 = tmp;
        }
Beispiel #3
0
        public override void Start()
        {
            m_scoreTexts       = new TextComponent[3];
            m_scoreTextFxs     = new TextFx[3];
            m_textFxParameters = new TextFxParameters[3];
            for (int i = 0; i < m_textFxParameters.Length; i++)
            {
                m_textFxParameters[i] = new TextFxParameters();
            }

            m_scoreTextsSpacing = new Vector2[]
            {
                new Vector2(-150, 140),
                new Vector2(0, 140),
                new Vector2(150, 140)
            };

            Engine.World.EventManager.AddListener((int)EventId.Goal, OnGoal);
            Engine.World.EventManager.AddListener((int)EventId.LastSeconds, OnLastSeconds);
            Engine.World.EventManager.AddListener((int)EventId.Victory, OnVictory);
            Engine.World.EventManager.AddListener((int)EventId.MatchBegin, OnMatchBegin);
            Engine.World.EventManager.AddListener((int)EventId.FirstPeriod, OnFirstPeriod);
            Engine.World.EventManager.AddListener((int)EventId.SecondPeriodBegin, OnSecondPeriodBegin);
            Engine.World.EventManager.AddListener((int)EventId.SecondPeriod, OnSecondPeriod);
            Engine.World.EventManager.AddListener((int)EventId.HalfTime, OnHalfTime);
            Engine.World.EventManager.AddListener((int)EventId.MatchEnd, OnMatchEnd);
            Engine.World.EventManager.AddListener((int)EventId.Victory, OnVictory);

            m_timerScoreTextMS         = new Timer(Engine.GameTime.Source, 0);
            m_timerScoreTextEvent      = new TimerEvent(m_timerScoreTextMS_OnTime);
            m_timerScoreTextMS.OnTime += m_timerScoreTextEvent;

            m_timerCupSpriteMS         = new Timer(Engine.GameTime.Source, 0);
            m_timerCupSpriteEvent      = new TimerEvent(m_timerCupSpriteMS_OnTime);
            m_timerCupSpriteMS.OnTime += m_timerCupSpriteEvent;

            m_playerOffScreenMarkerSprites = new ColorMaskedSprite[4];
            for (int i = 0; i < m_playerOffScreenMarkerSprites.Length; i++)
            {
                Sprite sprite = Sprite.CreateFromTexture("Graphics/playerOffScreenMarkerAO.png");
                sprite.Scale = new Vector2(0.5f, 0.5f);
                m_playerOffScreenMarkerSprites[i] = new ColorMaskedSprite(sprite, "ArenaOverlay9");
                var texAsset = Engine.AssetManager.GetAsset <Texture2D>("Graphics/playerOffScreenMarkerAO.png");

                m_playerOffScreenMarkerSprites[i].Mask    = texAsset.Content;
                m_playerOffScreenMarkerSprites[i].Color1  = Game.GameManager.Players[i].PlayerColors[2];
                m_playerOffScreenMarkerSprites[i].Color2  = Game.GameManager.Players[i].PlayerColors[2];
                m_playerOffScreenMarkerSprites[i].Color3  = Game.GameManager.Players[i].PlayerColors[2];
                m_playerOffScreenMarkerSprites[i].Visible = false;

                Owner.Attach(m_playerOffScreenMarkerSprites[i]);

                PlayerOffScreenMarker playerOffScreenMarker = Game.GameManager.Players[i].Owner.FindComponent <PlayerOffScreenMarker>();
                playerOffScreenMarker.Init();
            }
        }
Beispiel #4
0
        public override void Start()
        {
            m_player = Owner.FindComponent <Player>();

            int nSprite = 10;

            m_spriteCmps = new ColorMaskedSprite[nSprite];
            for (int i = 0; i < nSprite; i++)
            {
                var allPlayerSpriteInfos = Engine.AssetManager.Get <PlayerSpriteInfo[]>("Game/PlayerSprites.lua::PlayerSpritesTackle");
                var playerSpriteInfo     = allPlayerSpriteInfos[(int)m_player.PlayerIndex];

                Sprite playerSprite = Sprite.CreateFromTexture(playerSpriteInfo.Material);

                playerSprite.Scale       = new Vector2(0.48f, 0.48f);
                playerSprite.Orientation = m_player.Owner.Orientation;

                m_spriteCmps[i] = new ColorMaskedSprite(playerSprite, "ArenaOverlay5");
                var texAsset = playerSpriteInfo.Mask;
                m_spriteCmps[i].Mask = texAsset;

                m_spriteCmps[i].Color1 = m_player.PlayerColors[0];
                m_spriteCmps[i].Color2 = m_player.PlayerColors[1];
                m_spriteCmps[i].Color3 = m_player.PlayerColors[2];

                m_spriteCmps[i].AttachedToOwner = false;
                m_spriteCmps[i].Sprite.Alpha    = 0;
                Owner.Attach(m_spriteCmps[i]);
            }

            m_fadeTimeMS   = 0.12f * 1000;
            m_repeatTimeMS = 0.03f * 1000;
            m_totalTimeMS  = 0.2f * 1000;

            m_repeatTimer         = new Timer(Engine.GameTime.Source, m_repeatTimeMS, TimerBehaviour.Restart);
            m_repeatTimerEvent    = new TimerEvent(m_repeatTimer_OnTime);
            m_repeatTimer.OnTime += m_repeatTimerEvent;
            m_repeatTimer.Start();
            m_repeatTimer_OnTime(null);

            m_lifeTimer         = new Timer(Engine.GameTime.Source, m_totalTimeMS, TimerBehaviour.Stop);
            m_lifeTimerEvent    = new TimerEvent(m_lifeTimer_OnTime);
            m_lifeTimer.OnTime += m_lifeTimerEvent;
            m_lifeTimer.Start();
        }
Beispiel #5
0
        private void DebugColorEdit()
        {
            KeyControl keyPlayer = new KeyControl(Keys.NumPad4);
            KeyControl keyTeam1  = new KeyControl(Keys.NumPad2);
            KeyControl keyTeam2  = new KeyControl(Keys.NumPad3);
            KeyControl keyShift1 = new KeyControl(Keys.LeftControl);
            KeyControl keyShift2 = new KeyControl(Keys.RightControl);

            if (keyPlayer.KeyPressed())
            {
                ColorMaskedSprite playerMaskedSprite = Owner.FindComponent <ColorMaskedSprite>();
                if (PlayerIndex == PlayerIndex.One) // hack to avoid several Color incrementations
                {
                    if (keyShift1.KeyDown() || keyShift2.KeyDown())
                    {
                        Colors.Previous();
                    }
                    else
                    {
                        Colors.Next();
                    }
                }

                playerMaskedSprite.Color1 = Colors.Current();
            }
            else if (keyTeam1.KeyPressed() && m_team.TeamID == TeamId.TeamOne ||
                     (keyTeam2.KeyPressed() && m_team.TeamID == TeamId.TeamTwo))
            {
                ColorMaskedSprite playerMaskedSprite = Owner.FindComponent <ColorMaskedSprite>();

                if (keyShift1.KeyDown() || keyShift2.KeyDown())
                {
                    Colors.Current();
                }
                else
                {
                    Colors.Current();
                }

                m_team.ColorScheme.Color1 = Colors.Current();

                playerMaskedSprite.Color3 = Colors.Current();
            }
        }
Beispiel #6
0
        public void InitColorPanel()
        {
            if (m_arenaColorIndex == -1)
            {
                m_arenaColorIndex = 0;
            }

            Vector2 position = Parameters.SeparatorLineOffset * Vector2.UnitX
                               - Parameters.SeparatorMargin * Vector2.UnitX
                               - Parameters.DescriptionPanelSize * Vector2.UnitX;

            position += -Parameters.DescriptionPreviewHeight * Vector2.UnitY - Parameters.DescriptionPreviewSize.ProjectY() * 0.5f - Parameters.DescriptionPreviewMargin * Vector2.UnitY;

            m_arenaColorTextCmp          = new TextComponent("Menu");
            m_arenaColorTextCmp.Text     = "Color :";
            m_arenaColorTextCmp.Position = position;
            m_arenaColorTextCmp.Style    = new TextStyle()
            {
                Font = m_contentStyle2.Font, Scale = m_contentStyle2.Scale, Color = Color.White
            };
            m_arenaColorTextCmp.Visible = true;
            Menu.Owner.Attach(m_arenaColorTextCmp);

            Sprite colorSprite = Sprite.CreateFromTexture("Graphics/Menu/ColorSelectionBase.png");
            var    texAsset    = Engine.AssetManager.GetAsset <Texture2D>("Graphics/Menu/ColorSelectionColorMask.png");


            m_arenaColorSpriteCmp = new ColorMaskedSprite(colorSprite, "Menu2");
            float arenaColorSpriteOffset = m_contentStyle2.Font.MeasureString(m_arenaColorTextCmp.Text + " ").X *m_contentStyle2.Scale;

            m_arenaColorSpriteCmp.Position = m_arenaColorTextCmp.Position + arenaColorSpriteOffset * Vector2.UnitX + colorSprite.Size.X * 0.5f * Vector2.UnitX;
            m_arenaColorSpriteCmp.Mask     = texAsset.Content;
            m_arenaColorSpriteCmp.Color1   = m_colorSchemeDataAsset.Content.ColorSchemes[m_arenaColorIndex].Color2;
            m_arenaColorSpriteCmp.Color2   = Color.White;
            m_arenaColorSpriteCmp.Color3   = Color.White;
            m_arenaColorSpriteCmp.Color4   = Color.White;
            Menu.Owner.Attach(m_arenaColorSpriteCmp);
        }
Beispiel #7
0
        public override void OnInitGeometry()
        {
            var rbCmp = Arena.Owner.RigidBodyCmp;

            float width      = ConvertUnits.ToSimUnits(Arena.ArenaHalfSize.X);
            float height     = ConvertUnits.ToSimUnits(Arena.ArenaHalfSize.Y);
            float goalWidth  = ConvertUnits.ToSimUnits(100);
            float goalHeight = ConvertUnits.ToSimUnits(80);

            rbCmp.Body.CollidesWith        = (Category)CollisionType.All | (Category)CollisionType.Ball;
            rbCmp.Body.CollisionCategories = (Category)CollisionType.Wall;

            m_mobileObjs = new GameObject[2];

            for (int i = 0; i < m_mobileObjs.Length; i++)
            {
                m_mobileObjs[i] = new GameObject("Arena Mobile Object");
                Sprite mobileObjAOSprite = Sprite.CreateFromTexture("Arenas/ArenaMobLarge/AOMob.png");
                mobileObjAOSprite.Scale = 0.5f * Vector2.One;
                ColorMaskedSprite mobileObjColorSprite = new ColorMaskedSprite(mobileObjAOSprite, "ArenaOverlay3");


                var texAsset = Engine.AssetManager.GetAsset <Texture2D>("Arenas/ArenaMobLarge/materialMob" + i + ".png");
                mobileObjColorSprite.Mask   = texAsset.Content;
                mobileObjColorSprite.Color1 = Arena.ColorScheme.Color2;
                mobileObjColorSprite.Color2 = Ball.Game.GameManager.Teams[i].ColorScheme.Color1.SetSaturation(0.5f); //mettre en public depuis Arena
                mobileObjColorSprite.Color3 = Ball.Game.GameManager.Teams[i].ColorScheme.Color1.SetSaturation(0.5f);

                m_mobileObjs[i].Attach(mobileObjColorSprite);

                Asset <Texture2D>   textureAsset        = Engine.AssetManager.GetAsset <Texture2D>("Arenas/ArenaMobLarge/collisionMob.png");
                CollisionDefinition collisionDefinition = CollisionDefinitionHelper.FromTexture(textureAsset.Content, 2.0f);
                for (int iCol = 0; iCol < collisionDefinition.Entries.Length; iCol++)
                {
                    Engine.Log.Write(String.Format("Collision {0}: {1} vertices", iCol, collisionDefinition.Entries[iCol].Vertices.Length));
                }

                RigidBodyComponentParameters parameters = new RigidBodyComponentParameters {
                    Collision = collisionDefinition
                };

                RigidBodyComponent rigidBodyCmp = new RigidBodyComponent(new Asset <RigidBodyComponentParameters>(parameters));
                m_mobileObjs[i].Attach(rigidBodyCmp);

                m_mobileObjs[i].RigidBodyCmp.Body.CollidesWith        = (Category)CollisionType.Player | (Category)CollisionType.Ball;
                m_mobileObjs[i].RigidBodyCmp.Body.CollisionCategories = (Category)CollisionType.Wall;
            }

            m_mobileObjs[0].Position    = new Vector2(-mobileObjsPosX, 0);
            m_mobileObjs[1].Position    = new Vector2(mobileObjsPosX, 0);
            m_mobileObjs[0].Orientation = 0;
            m_mobileObjs[1].Orientation = 0;

            Engine.World.EventManager.AddListener((int)EventId.FirstPeriod, OnFirstPeriod);
            Engine.World.EventManager.AddListener((int)EventId.HalfTime, OnHalfTime);
            Engine.World.EventManager.AddListener((int)EventId.HalfTimeTransition, OnHalfTimeTransition);
            Engine.World.EventManager.AddListener((int)EventId.SecondPeriod, OnSecondPeriod);
            Engine.World.EventManager.AddListener((int)EventId.MatchEnd, OnMatchEnd);

            m_rotateTimer         = new Timer(Engine.GameTime.Source, m_timeFirstMS, TimerBehaviour.Restart);
            m_rotateTimerEvent    = new TimerEvent(StartRotation);
            m_rotateTimer.OnTime += m_rotateTimerEvent;
        }
Beispiel #8
0
        public void Init()
        {
            m_effects = new List <PlayerEffect>();

            var allPlayerSpriteInfos = Engine.AssetManager.Get <PlayerSpriteInfo[]>("Game/PlayerSprites.lua::PlayerSprites");
            var playerSpriteInfo     = allPlayerSpriteInfos[(int)m_playerIndex];

            Sprite playerSprite = Sprite.CreateFromTexture(playerSpriteInfo.Material);

            playerSprite.Scale = new Vector2(0.48f, 0.48f);
            m_spritePlayerCmp  = new ColorMaskedSprite(playerSprite, "ArenaOverlay9");
            var texAsset = playerSpriteInfo.Mask;

            m_spritePlayerCmp.Mask = texAsset;
            ResetColors();
            Owner.Attach(m_spritePlayerCmp);

            m_shadowCmp = new SpriteComponent(
                Sprite.CreateFromTexture("Graphics/playerShadow.png"),
                "ArenaOverlay8");
            m_shadowCmp.Sprite.Scale = playerSprite.Scale;
            Owner.Attach(m_shadowCmp);

            Sprite sparksSprite = Sprite.Create("Graphics/playerSprite.lua::Sprite");

            sparksSprite.SetAnimation("Sparks");
            sparksSprite.Playing = true;
            m_sparksCmp          = new SpriteComponent(sparksSprite, "ArenaOverlay10");
            m_sparksCmp.Visible  = false;
            Owner.Attach(m_sparksCmp);

            Sprite goldFxSprite = Sprite.Create("Graphics/playerSprite.lua::Sprite");

            goldFxSprite.SetAnimation("GoldFx");
            goldFxSprite.Playing      = false;
            m_goldFxSpriteCmp         = new SpriteComponent(goldFxSprite, "ArenaOverlay10");
            m_goldFxSpriteCmp.Visible = false;
            Owner.Attach(m_goldFxSpriteCmp);

            Sprite shieldUpFxSprite = Sprite.Create("Graphics/playerSprite.lua::Sprite");

            shieldUpFxSprite.SetAnimation("ShieldUp");
            shieldUpFxSprite.Playing      = false;
            m_shieldUpFxSpriteCmp         = new SpriteComponent(shieldUpFxSprite, "ArenaOverlay10");
            m_shieldUpFxSpriteCmp.Visible = false;
            Owner.Attach(m_shieldUpFxSpriteCmp);

            // Physic
            m_bodyCmp = new RigidBodyComponent();
            CircleShape bodyShape = new CircleShape(ConvertUnits.ToSimUnits(Parameters.Radius), 1.0f);
            Fixture     fix       = new Fixture(m_bodyCmp.Body, bodyShape);

            Owner.Attach(m_bodyCmp);

            m_bodyCmp.Body.FixedRotation = true;

            m_bodyCmp.Body.LinearDamping       = Parameters.Physic.LinearDamping;
            m_bodyCmp.Body.AngularDamping      = Parameters.Physic.AngularDamping;
            m_bodyCmp.Body.Restitution         = Parameters.Physic.Restitution;
            m_bodyCmp.Body.Mass                = Parameters.Physic.Mass;
            m_bodyCmp.Body.CollisionCategories = (Category)CollisionType.Player;
            m_bodyCmp.Body.SleepingAllowed     = false;
            m_bodyCmp.Body.IsBullet            = true;

            // Blink
            m_blink = new PlayerBlink(this);
            Owner.Attach(m_blink);

            if (m_playerIndex == PlayerIndex.One)
            {
                m_bodyCmp.Body.CollisionCategories = (Category)CollisionType.Gameplay | (Category)CollisionType.Player | (Category)CollisionType.TeamA;
            }
            if (m_playerIndex == PlayerIndex.Two)
            {
                m_bodyCmp.Body.CollisionCategories = (Category)CollisionType.Gameplay | (Category)CollisionType.Player | (Category)CollisionType.TeamA;
            }
            if (m_playerIndex == PlayerIndex.Three)
            {
                m_bodyCmp.Body.CollisionCategories = (Category)CollisionType.Gameplay | (Category)CollisionType.Player | (Category)CollisionType.TeamB;
            }
            if (m_playerIndex == PlayerIndex.Four)
            {
                m_bodyCmp.Body.CollisionCategories = (Category)CollisionType.Gameplay | (Category)CollisionType.Player | (Category)CollisionType.TeamB;
            }

            // Audio
            m_audioCmpBallShot = new AudioComponent("Audio/Sounds.lua::BallShot");
            Owner.Attach(m_audioCmpBallShot);
            m_audioCmpStun = new AudioComponent("Audio/Sounds.lua::Stun");
            Owner.Attach(m_audioCmpStun);
            m_audioCmpCharge = new AudioComponent("Audio/Sounds.lua::Charge");
            Owner.Attach(m_audioCmpCharge);

            //
            m_ballTrigger = new TriggerComponent();
            var triggerFixture = FixtureFactory.AttachCircle(
                ConvertUnits.ToSimUnits(Parameters.Radius + Parameters.BallSnapRadius),
                0,
                m_ballTrigger.Body);

            triggerFixture.IsSensor         = true;
            m_ballTrigger.Body.CollidesWith = (Category)CollisionType.Ball;
            Owner.Attach(m_ballTrigger);

            m_magnetSensor = new TriggerComponent();
            triggerFixture = FixtureFactory.AttachCircle(
                ConvertUnits.ToSimUnits(Parameters.MagnetRadiusMax),
                0,
                m_magnetSensor.Body);
            triggerFixture.IsSensor          = true;
            m_magnetSensor.Body.CollidesWith = (Category)CollisionType.Ball;
            Owner.Attach(m_magnetSensor);

            Engine.World.EventManager.AddListener((int)EventId.MatchBegin, OnMatchBegin);
            Engine.World.EventManager.AddListener((int)EventId.FirstPeriod, OnFirstPeriod);
            Engine.World.EventManager.AddListener((int)EventId.HalfTime, OnHalfTime);
            Engine.World.EventManager.AddListener((int)EventId.HalfTimeTransition, OnHalfTimeTransition);
            Engine.World.EventManager.AddListener((int)EventId.SecondPeriod, OnSecondPeriod);
            Engine.World.EventManager.AddListener((int)EventId.MatchEnd, OnMatchEnd);
            Engine.World.EventManager.AddListener((int)EventId.Victory, OnMatchVictory);
            Engine.World.EventManager.AddListener((int)EventId.KickOff, OnKickOff);

            m_ballAngle = 0;

            //Initialise ChargetShots Timer
            float chargeTimeMS = Parameters.ChargedShot.ChargeTimeMS;

            chargeTimeMS      *= ComputeSkillCoef("ChargedShotTime", Parameters.Skills.ChargedShotTimeBase, Parameters.Skills.ChargedShotTimeCoef);
            m_chargedShotTimer = new Timer(Engine.GameTime.Source, chargeTimeMS, TimerBehaviour.Stop);

            float delay = Engine.Debug.EditSingle("ChargedShotDelay", 250);

            m_chargedShotDelayTimer = new Timer(Engine.GameTime.Source, delay);

            ShakeComponent shakeCmp = new ShakeComponent(m_spritePlayerCmp);

            shakeCmp.ShakeAmount = 4.0f;
            Owner.Attach(shakeCmp);

            PlayerOffScreenMarker offScreenMarker = new PlayerOffScreenMarker();

            Owner.Attach(offScreenMarker);

            if (m_playerInfo.InputType == InputType.AI && m_teamMate.PlayerInfo.InputType == InputType.AI)
            {
                offScreenMarker.Hide = true;
            }

            m_moveDirection = Vector2.Zero;

            m_bodyCmp.OnCollision += new CollisionEvent(OnCollision);

            m_bodyCmp.UserData.Add("Tag", "Player");

            //Antenna
            var playerAntenna = new PlayerAntenna();

            Owner.Attach(playerAntenna);
        }
Beispiel #9
0
        private void DebugColorEdit()
        {
            KeyControl keyArenaWall   = new KeyControl(Keys.NumPad0);
            KeyControl keyArenaGround = new KeyControl(Keys.NumPad1);
            KeyControl keyTeam1       = new KeyControl(Keys.NumPad2);
            KeyControl keyTeam2       = new KeyControl(Keys.NumPad3);
            KeyControl keyShift1      = new KeyControl(Keys.LeftControl);
            KeyControl keyShift2      = new KeyControl(Keys.RightControl);

            if (keyArenaWall.KeyPressed())
            {
                ColorMaskedSprite arenaMaskedSprite = Owner.FindComponent <ColorMaskedSprite>();

                if (keyShift1.KeyDown() || keyShift2.KeyDown())
                {
                    arenaMaskedSprite.Color1 = Colors.Previous();
                }
                else
                {
                    arenaMaskedSprite.Color1 = Colors.Next();
                }
            }
            else if (keyArenaGround.KeyPressed())
            {
                ColorMaskedSprite arenaMaskedSprite = Owner.FindComponent <ColorMaskedSprite>();

                if (keyShift1.KeyDown() || keyShift2.KeyDown())
                {
                    arenaMaskedSprite.Color4 = Colors.Previous();
                }
                else
                {
                    arenaMaskedSprite.Color4 = Colors.Next();
                }
            }
            else
            {
                bool keyTeamPressed = false;
                Team team           = null;

                if (keyTeam1.KeyPressed())
                {
                    keyTeamPressed = true;
                    team           = Game.GameManager.Teams[0];
                }
                else if (keyTeam2.KeyPressed())
                {
                    keyTeamPressed = true;
                    team           = Game.GameManager.Teams[1];
                }

                if (keyTeamPressed)
                {
                    if (keyShift1.KeyDown() || keyShift2.KeyDown())
                    {
                        Colors.Previous();
                    }
                    else
                    {
                        Colors.Next();
                    }

                    team.ColorScheme.Color1 = Colors.Current();

                    ColorMaskedSprite arenaMaskedSprite = Owner.FindComponent <ColorMaskedSprite>();
                    if (m_leftGoal.Team.TeamID == team.TeamID)
                    {
                        arenaMaskedSprite.Color2 = Colors.Current();
                    }
                    else
                    {
                        arenaMaskedSprite.Color3 = Colors.Current();
                    }
                }
            }
        }
Beispiel #10
0
        public override void Start()
        {
            m_teamColorIndexes     = new int[2];
            m_colorSchemeDataAsset = Engine.AssetManager.GetAsset <ColorSchemeData>("Game/Colors.lua::ColorShemeTeams");
            m_teamColorIndexes[0]  = -1;
            m_teamColorIndexes[1]  = -1;

            if (Game.GameSession.CurrentMatchInfo == null)
            {
                Game.GameSession.CurrentMatchInfo = new MatchStartInfo();
                m_teamColorIndexes[0]             = 0;
                m_teamColorIndexes[1]             = m_colorSchemeDataAsset.Content.ColorSchemes.Length / 2;
            }
            else
            {
                for (int i = 0; i < Game.GameSession.CurrentMatchInfo.Teams.Length; i++)
                {
                    for (int j = 0; j < m_colorSchemeDataAsset.Content.ColorSchemes.Length; j++)
                    {
                        if (Game.GameSession.CurrentMatchInfo.Teams[i].ColorScheme == m_colorSchemeDataAsset.Content.ColorSchemes[j])
                        {
                            m_teamColorIndexes[i] = j;
                            break;
                        }
                    }
                }
            }

            m_parameters = Engine.AssetManager.GetAsset <SelectTeamMenuParamters>("Interface/SelectTeamMenu.lua::Params");

            var backgroundCmp = new SpriteComponent(Sprite.CreateFromTexture("Graphics/Menu/Background.png"), "MenuBackground");

            Menu.Owner.Attach(backgroundCmp);

            var backgroundTeamCmp = new SpriteComponent(Sprite.CreateFromTexture("Graphics/Menu/TeamSelectionBackground.png"), "Menu");

            Menu.Owner.Attach(backgroundTeamCmp);

            m_ctrlInfos   = new Dictionary <MenuController, ControllerInfo>();
            m_playerSlots = new MenuController[4];

            SpriteFont font = Engine.AssetManager.Get <SpriteFont>("Graphics/Menu/BigMacUnselectedPen");

            m_style = new TextStyle()
            {
                Scale = 0.4f, Color = Color.White, Font = font
            };

            m_playerSpotPos    = new Vector2[4];
            m_playerSpotPos[0] = Parameters.Offset * Vector2.UnitX - Parameters.PanelWidth * Vector2.UnitX + Parameters.ControllersHeight * Vector2.UnitY;
            m_playerSpotPos[1] = Parameters.Offset * Vector2.UnitX - Parameters.PanelWidth * Vector2.UnitX + Parameters.ControllersHeight * Vector2.UnitY - Parameters.ControllersHeightOffset * Vector2.UnitY;
            m_playerSpotPos[2] = Parameters.Offset * Vector2.UnitX + Parameters.PanelWidth * Vector2.UnitX + Parameters.ControllersHeight * Vector2.UnitY;
            m_playerSpotPos[3] = Parameters.Offset * Vector2.UnitX + Parameters.PanelWidth * Vector2.UnitX + Parameters.ControllersHeight * Vector2.UnitY - Parameters.ControllersHeightOffset * Vector2.UnitY;

            m_pressStartCmp                    = new TextComponent("Menu");
            m_pressStartCmp.Text               = "Press Start\n     to join";
            m_pressStartCmp.Alignement         = TextAlignementHorizontal.Center;
            m_pressStartCmp.AlignementVertical = TextAlignementVertical.Down;
            m_pressStartCmp.Style              = new TextStyle()
            {
                Font = m_style.Font, Scale = m_style.Scale, Color = Color.DarkGray
            };
            m_pressStartCmp.Visible = false;
            Menu.Owner.Attach(m_pressStartCmp);

            m_teamColorTextCmp = new TextComponent[2];

            m_teamColorTextCmp[0]            = new TextComponent("Menu");
            m_teamColorTextCmp[0].Text       = "Color :";
            m_teamColorTextCmp[0].Alignement = TextAlignementHorizontal.Center;
            m_teamColorTextCmp[0].Position   = m_playerSpotPos[1] - Parameters.ControllersHeight * Vector2.UnitY;
            m_teamColorTextCmp[0].Style      = new TextStyle()
            {
                Font = m_style.Font, Scale = m_style.Scale, Color = Color.White
            };
            m_teamColorTextCmp[0].Visible = true;
            Menu.Owner.Attach(m_teamColorTextCmp[0]);

            m_teamColorTextCmp[1]            = new TextComponent("Menu");
            m_teamColorTextCmp[1].Text       = "Color :";
            m_teamColorTextCmp[1].Alignement = TextAlignementHorizontal.Center;
            m_teamColorTextCmp[1].Position   = m_playerSpotPos[3] - Parameters.ControllersHeight * Vector2.UnitY;
            m_teamColorTextCmp[1].Style      = new TextStyle()
            {
                Font = m_style.Font, Scale = m_style.Scale, Color = Color.White
            };
            m_teamColorTextCmp[1].Visible = true;
            Menu.Owner.Attach(m_teamColorTextCmp[1]);

            //
            if (m_teamColorIndexes[0] == -1)
            {
                m_teamColorIndexes[0] = 0;
            }

            if (m_teamColorIndexes[1] == -1)
            {
                m_teamColorIndexes[1] = m_colorSchemeDataAsset.Content.ColorSchemes.Length / 2;
            }

            m_teamColorSpriteCmp = new ColorMaskedSprite[2];
            Sprite colorSprite = Sprite.CreateFromTexture("Graphics/Menu/ColorSelectionBase.png");
            var    texAsset    = Engine.AssetManager.GetAsset <Texture2D>("Graphics/Menu/ColorSelectionColorMask.png");

            m_teamColorSpriteCmp[0]          = new ColorMaskedSprite(colorSprite, "Menu2");
            m_teamColorSpriteCmp[0].Position = m_teamColorTextCmp[0].Position - Parameters.ControllersHeight * Vector2.UnitY;
            m_teamColorSpriteCmp[0].Mask     = texAsset.Content;
            m_teamColorSpriteCmp[0].Color1   = m_colorSchemeDataAsset.Content.ColorSchemes[m_teamColorIndexes[0]].Color1;
            m_teamColorSpriteCmp[0].Color2   = Color.White;
            m_teamColorSpriteCmp[0].Color3   = Color.White;
            m_teamColorSpriteCmp[0].Color4   = Color.White;
            Menu.Owner.Attach(m_teamColorSpriteCmp[0]);

            m_teamColorSpriteCmp[1]          = new ColorMaskedSprite(colorSprite, "Menu2");
            m_teamColorSpriteCmp[1].Position = m_teamColorTextCmp[1].Position - Parameters.ControllersHeight * Vector2.UnitY;
            m_teamColorSpriteCmp[1].Mask     = texAsset.Content;
            m_teamColorSpriteCmp[1].Color1   = m_colorSchemeDataAsset.Content.ColorSchemes[m_teamColorIndexes[1]].Color1;
            m_teamColorSpriteCmp[1].Color2   = Color.White;
            m_teamColorSpriteCmp[1].Color3   = Color.White;
            m_teamColorSpriteCmp[1].Color4   = Color.White;
            Menu.Owner.Attach(m_teamColorSpriteCmp[1]);

            //
            SpriteDefinition spriteDef = Engine.AssetManager.Get <SpriteDefinition>("Graphics/controlSprite.lua::Sprite");

            m_playerSpotCmp     = new SpriteComponent[4];
            m_playerSpotTextCmp = new TextComponent[4];
            for (int i = 0; i < 4; i++)
            {
                m_playerSpotCmp[i]              = new SpriteComponent(new Sprite(spriteDef), "Menu");
                m_playerSpotCmp[i].Position     = m_playerSpotPos[i];
                m_playerSpotCmp[i].Sprite.Scale = iconSpriteScale * Vector2.One;
                Menu.Owner.Attach(m_playerSpotCmp[i]);

                m_playerSpotTextCmp[i]            = new TextComponent("Menu");
                m_playerSpotTextCmp[i].Text       = "AI";
                m_playerSpotTextCmp[i].Alignement = TextAlignementHorizontal.Center;
                m_playerSpotTextCmp[i].Style      = m_style;
                m_playerSpotTextCmp[i].Position   = m_playerSpotPos[i] - Parameters.ControllerTextHeightOffset * Vector2.UnitY;
                Menu.Owner.Attach(m_playerSpotTextCmp[i]);
            }

            for (int i = 0; i < 4; i++)
            {
                var playerInfo = Game.GameSession.CurrentMatchInfo.Players[i];
                if (playerInfo.InputType != InputType.AI)
                {
                    foreach (var menuController in Game.MenuManager.Controllers)
                    {
                        if (menuController.InputIndex == playerInfo.InputIndex && menuController.Type == playerInfo.InputType)
                        {
                            AddController(menuController);
                            m_playerSlots[i] = menuController;
                            m_ctrlInfos[menuController].PlayerIndex = i;

                            if (i == 0 || i == 1)
                            {
                                m_ctrlInfos[menuController].State = ControllerState.Left;
                            }
                            else
                            {
                                m_ctrlInfos[menuController].State = ControllerState.Right;
                            }
                        }
                    }
                }
            }

            Menu.SelectItem(0);

            Game.GameMusic.PlayMenuMusic();
        }
Beispiel #11
0
 public void Init()
 {
     m_player       = (Player)Owner.FindComponent <Player>();
     m_markerSprite = Game.GameManager.MatchFeedBack.PlayerOffScreenMarkerSprites[(int)m_player.PlayerIndex];
 }