Exemplo n.º 1
0
        //public static Texture2D ScreenSnapshot
        //{
        //    get
        //    {
        //        int[] _backImg = new int[_Graphics.PreferredBackBufferWidth * _Graphics.PreferredBackBufferHeight];
        //        _Graphics.GraphicsDevice.GetBackBufferData(_backImg);
        //        if (_ScreenSnapshot != null)
        //            _ScreenSnapshot.Dispose();
        //        _ScreenSnapshot = new Texture2D(_Graphics.GraphicsDevice, _Graphics.PreferredBackBufferWidth, _Graphics.PreferredBackBufferHeight, false, _Graphics.GraphicsDevice.PresentationParameters.BackBufferFormat);
        //        _ScreenSnapshot.SetData(_backImg);

        //        System.IO.Stream st = new System.IO.FileStream("Screenshot.png", System.IO.FileMode.Create);
        //        _ScreenSnapshot.SaveAsPng(st, _ScreenSnapshot.Width, _ScreenSnapshot.Height);
        //        st.Close(); 

        //        return _ScreenSnapshot;
        //    }
        //}

        public static void SwitchFocus(VisibleEntity src, VisibleEntity des)
        {
            _PreviousFocus = src;
            _CurrentFocus = des;
            src.HasFocus = false;
            des.HasFocus = true;
        }
        private void UpdatePlayersCardPositions(GameTime gameTime, TripleTriadCard[] cards, int player)
        {
            TripleTriadCard tmp = null;
            int index = -1;
            ResetHandPositions(player);
            for (int i = 0; i < cards.Length; ++i)
            {
                if (selectedCard == null && !TripleTriadGame.PlayedCards.Contains(cards[i]) && (cards[i].IsMouseOver() || cards[i].IsMouseDown()))
                {
                    if (tmp == null || cards[i].Depth > tmp.Depth)
                    {
                        tmp = cards[i];
                        index = i;
                    }
                }
            }

            if (tmp != null && index != -1)
            {
                if (tmp.IsSelected())
                {
                    selectedCard = tmp;
                    Global.SFXManager.Card.Play();
                }

                if (player == 1)
                    tmp.Position = TripleTriadCardLib.Player1HandPos[index] + new Vector2(-16, 0);
                else if (player == 2)
                    tmp.Position = TripleTriadCardLib.Player2HandPos[index] + new Vector2(16, 0);
            }

            if (tmp != null)
            {
                _PrevMouseTarget = _CurrMouseTarget;
                _CurrMouseTarget = tmp;
            }
            else
                UpdateCurrentMouseTargetOnBoard(gameTime, player);
        }
 private void UpdateCurrentMouseTargetOnBoard(GameTime gameTime, int player)
 {
     TripleTriadCard tmp = null;
     for (int i = 0; i < TripleTriadGame.PlayedCards.Length; ++i)
     {
         if (TripleTriadGame.PlayedCards[i] != null && (TripleTriadGame.PlayedCards[i].IsMouseOver() || TripleTriadGame.PlayedCards[i].IsMouseDown()))
         {
             tmp = TripleTriadGame.PlayedCards[i];
             break;
         }
     }
     _PrevMouseTarget = _CurrMouseTarget;
     _CurrMouseTarget = tmp;
 }
Exemplo n.º 4
0
 public virtual void AddEntity(VisibleEntity entity)
 {
     if (!_SceneEntities.Contains(entity))
         _SceneEntities.Add(entity);
 }