コード例 #1
0
 public static void Update(GameTime gameTime)
 {
     if (GameManager.GetLevel() == null)
     {
         if (PlayerProfile.getController(0) == null)
         {
             PlayerProfile.Update(gameTime, true);
             if (PlayerProfile.getController(0) != null)
             {
                 setMessage("Press A to search for connection");
             }
         }
         else
         {
             PlayerProfile.Update(gameTime, false);
             if (NetworkManager.networkSession == null)
             {
                 BasicController b = PlayerProfile.getController(0);
                 if (b.AButton())
                 {
                     setMessage("Attempting to Join...");
                     if (NetworkManager.JoinSession())
                     {
                         setMessage("Sucess");
                     }
                     else
                     {
                         setMessage("Failure to Connect");
                     }
                 }
             }
             else
             {
                 NetworkManager.Update(gameTime);
             }
         }
     }
     else
     {
         if (!PlayerProfile.getController(0).BackButton())
         {
             GameManager.Update(gameTime);
             FPSCounter.Update(gameTime);
         }
         else
         {
             GameManager.ClearLevel();
         }
     }
 }
コード例 #2
0
        public void Update(GameTime gameTime, BasicController MyController, bool Highlighted)
        {
            if (Highlighted && !ParentMenu.Closing)
            {
                TargetPosition = ParentMenu.Position - TechTreeMenu.NegativeOffset - new Vector2(0, Size.Y / 2);
                Position      += (TargetPosition - Position) * gameTime.ElapsedGameTime.Milliseconds * PlayerMenu.CloseOpenSpeed * 2;
                Alpha          = Math.Min(1, Alpha + gameTime.ElapsedGameTime.Milliseconds * PlayerMenu.CloseOpenSpeed * 2);
                if (Alpha > 0.5f)
                {
                    Vector2 CursorPrevious = Cursor;
                    bool    ExtraSticks    = FactionManager.GetFaction(ParentMenu.ParentShip.FactionNumber).PickingCards;
                    Cursor += MyController.MenuStick(ExtraSticks, ExtraSticks, true, false, false);

                    if (ExtraSticks)
                    {
                        Vector2 BumperCursorPrevious = BumperCursor;
                        BumperCursor = MyController.MenuStick(false, false, false, true, true);
                        if (Math.Abs(BumperCursor.X) > 0.1f && Math.Abs(BumperCursor.X) < 0.1f)
                        {
                            Faction f = FactionManager.GetFaction(ParentMenu.ParentShip.FactionNumber);
                            if (BumperCursor.X > 0)
                            {
                                f.CardPickPosition++;
                                if (f.CardPickPosition == f.Cards.Count)
                                {
                                    ParentMenu.ParentShip.ReadyMenu();
                                }
                            }
                            else
                            {
                                f.CardPickPosition = Math.Max(0, f.CardPickPosition - 1);
                            }
                        }
                    }

                    if (Cursor.Y != 0 && ParentMenu.MyFaction.PickingCards)
                    {
                        if (Cursor.Y < 0)
                        {
                            TechTreeGroup PreviousGroup = MyNode.Previous != null ? MyNode.Previous.Value : MyNode.List.Last.Value;
                            if (PreviousGroup.Cards != null && PreviousGroup.Cards.Count > 0)
                            {
                                PreviousGroup.Cursor.X = Cursor.X;
                                PreviousGroup.Position = Position - new Vector2(0, PreviousGroup.Size.Y);
                                ParentMenu.SetGroup(PreviousGroup);
                                PreviousGroup.SwitchTo();
                            }
                        }
                        else if (Cursor.Y > 0)
                        {
                            TechTreeGroup NextGroup = MyNode.Next != null ? MyNode.Next.Value : MyNode.List.First.Value;
                            if (NextGroup.Cards != null && NextGroup.Cards.Count > 0)
                            {
                                NextGroup.Cursor.X = Cursor.X;
                                NextGroup.Position = Position + new Vector2(0, Size.Y);
                                ParentMenu.SetGroup(NextGroup);
                                NextGroup.SwitchTo();
                            }
                        }
                        Cursor.Y = 0;
                    }
                    Cursor.X = MathHelper.Clamp(Cursor.X, 0, Cards.Count - 1);

                    int i = 0;
                    foreach (FactionCard c in Cards)
                    {
                        c.MenuUpdate(gameTime, (int)Cursor.X == i, 1 - Math.Abs(Cursor.X - i++) / 2.25f);
                    }

                    Vector2 TargetOffset = -new Vector2((Cursor.X - 2) * CellBorders.X, -CellBorders.Y / 2f);
                    DrawOffset += (TargetOffset - DrawOffset) * OffsetSpeed;

                    HighlightedCard = Cards[(int)Cursor.X];
                    if (MyController.AButton() && !MyController.AButtonPrevious())
                    {
                    }
                    HighlightedCard.Update3D(ParentMenu.ParentShip);
                }
            }
            else
            {
                Alpha = Math.Max(0, Alpha - gameTime.ElapsedGameTime.Milliseconds * PlayerMenu.CloseOpenSpeed);
            }
        }