Exemplo n.º 1
0
        private void GameShape_CardMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //zablokuj eventy
            //GameShape.CardDrag -= new CardDragEventHandler(GameShape_CardDrag);
            GameShape.CardMouseLeftButtonDown -= new MouseButtonEventHandler(GameShape_CardMouseLeftButtonDown);

            bool renons;
            //klikniecie na karte sprobuje zagrac karte
            var       cardShapeClicked = (CardShape)sender;
            CardShape card             = (CardShape)sender;
            var       gameShape        = GameShape.GetGameShape(card.Card.Deck.Game);
            var       oldDeckShape     = gameShape.GetDeckShape(card.Card.Deck);

            if (oldDeckShape.Name == "Player4Hand")
            {
                //karta ktora chce zagrac gracz
                Card userPlayedCard = new Card(card.Card);

                //wygeneruj mozliwe ruchy gracza
                Deck player4Moves = new Deck(Player4Hand.Deck);
                player4Moves = GameRules.PossibleMoves(Player4Hand.Deck, WistCard, HeartsOpen, out renons);
                Player4Hand.Deck.Sort();

                //sprawdz czy karta ktora chce zagrac gracz jest w jego mozliwych ruchac
                if (player4Moves.Has(userPlayedCard.Rank, userPlayedCard.Suit))
                {
                    Player4UsedCards.AddPlayed(userPlayedCard);
                    Player4UsedCards.SortHigh();
                    //jezeli graz jest wistujacym to jego ruch staje sie karta wistujaca
                    if (WistPlayerNumber == 4)
                    {
                        WistCard = userPlayedCard;
                    }
                    //jezeli nie jest to sprawdz czy nie ma krotkosci
                    else if (renons)
                    {
                        Player4UsedCards.CardRenons[WistCard.Suit] = true;
                    }

                    card.Card.Deck = Player4Trick.Deck;
                    currentTrick.Add(userPlayedCard);
                    //jezeli zagral kiera to otworz kiery
                    if (userPlayedCard.Suit == CardSuit.Hearts)
                    {
                        HeartsOpen = true;
                    }

                    EndTrick();
                    return;
                }
            }
            //Nie zagral prawidlowej karty - odblokuj klikanie
            GameShape.CardMouseLeftButtonDown += GameShape_CardMouseLeftButtonDown;
            //GameShape.CardMouseLeftButtonDown += new MouseButtonEventHandler(GameShape_CardMouseLeftButtonDown);

            //gameShape.GetDeckShape(card.Card.Deck).UpdateCardShapes();
            UpdateAllCardShapes();
            //Canvas.SetZIndex(oldDeckShape, 0);
        }
Exemplo n.º 2
0
 public void RemoveShape(GameShape shape)
 {
     shapeList.Remove(shape);
     if (shapeList.Count == 0 && OnPipeRemoved != null)
     {
         OnPipeRemoved(this);
     }
 }
Exemplo n.º 3
0
 public void ClearFilledShape()
 {
     if (this.FilledShape != null)
     {
         this.ParentGameBoard.DecrementVerticalColumnShapeTracker(this.BoardPos);
     }
     this.FilledShape = (GameShape)null;
 }
 private void OnShapeCreated(GameShape shape)
 {
     shape.RegisterOnStateChanged(OnShapeStateChanged);
     if (shape.Spawner.AttachedPipe != null)
     {
         shape.Spawner.AttachedPipe.SetState(GamePipeState.WRONG);
     }
 }
Exemplo n.º 5
0
 protected void CallShapeStateChanged(GameShape shape)
 {
     if (shape.HasFinished)
     {
         shape.Spawner.CurrentShapes--;
     }
     onShapeStateChanged(shape);
 }
    public static void CreateShape(GameObject shapePrefab, GameShape shape, GameObject parent, GameShapeController shapeController)
    {
        GameObject shapeObj = Instantiate(shapePrefab, shape.Position, Quaternion.identity);

        shapeObj.transform.SetParent(parent.transform);
        GameShapeView shapeView = shapeObj.AddComponent <GameShapeView>();

        shapeView.InitShapeView(shape, shapeController);
    }
 private void InitShapeView(GameShape gameShape, GameShapeController gameShapeController)
 {
     shapeController = gameShapeController;
     shape           = gameShape;
     animator        = gameObject.GetComponent <Animator>();
     animator.speed  = gameShape.SpawnSpeed;
     gameShape.RegisterOnPositionUpdated(OnPositionUpdated);
     gameShape.RegisterOnStateChanged(OnStateChanged);
 }
Exemplo n.º 8
0
    //strategy shape state changed, by spawn type
    protected void TimeShapeStateChanged(GameShape shape)
    {
        if (shape.State == GameShapeState.EXPLODING)
        {
            CancelInvoke(SpawnShapeFunction);

            StartShapeSpawn(afterExplodeDelay);
        }
    }
Exemplo n.º 9
0
    public bool WillBlockShape(GameShape incoming)
    {
        bool flag = false;

        if (this.FilledShape != null)
        {
            flag = this.FilledShape.WillBlockShapeAtBoardSlot(incoming, this);
        }
        return(flag);
    }
Exemplo n.º 10
0
        private void Reset(IUIThreadDispatcher uiThreadDispatcher)
        {
            uiThreadDispatcher.BlockingInvoke(() =>
            {
                game = new GameShape();
                pluginContainer.Child = game;
            });

            currentMoveSuggestions.Clear();
        }
Exemplo n.º 11
0
    private void OnEnable()
    {
        gameShape    = GetComponent <GameShape>();
        elementImage = GetComponent <Image>();

        LoadElement(ThemeManager.GetCurrentTheme(), ThemeManager.GetCurrentColorMode());
        if (updateDynamically)
        {
            ThemeManager.onThemeSettingsUpdate += LoadElement;
        }
    }
Exemplo n.º 12
0
 protected void FinishShapeStateChanged(GameShape shape)
 {
     if (shape.State == GameShapeState.EXPLODING)
     {
         Invoke(SpawnShapeFunction, afterExplodeDelay);
     }
     else if (shape.State == GameShapeState.FINISHED)
     {
         Invoke(SpawnShapeFunction, afterFinishDelay);
     }
 }
Exemplo n.º 13
0
        public void getActivateNextTest()
        {
            GameState gameState      = new GameState();
            GameShape originalActive = gameState.getActiveShape();
            GameShape originalNext   = gameState.getNextShape();

            gameState.activateNext();

            Assert.AreEqual(originalNext, gameState.getActiveShape());
            Assert.IsNotNull(gameState.getNextShape());
        }
Exemplo n.º 14
0
 private void TimeOrFinishShapeStateChanged(GameShape shape)
 {
     if (shape.State == GameShapeState.EXPLODING)
     {
         Invoke(CheckSpawnShapeFunction, afterExplodeDelay);
     }
     else if (shape.State == GameShapeState.FINISHED)
     {
         Invoke(CheckSpawnShapeFunction, afterFinishDelay);
     }
 }
Exemplo n.º 15
0
    public int TriggerShapeDestruction(int index, Transform boardParent)
    {
        // Getting the current slot
        GameShape centerShape = boardParent.GetChild(index).GetComponent <GameSlot>().GetSlotShape();

        if (centerShape == null)
        {
            Debug.LogError("Couldn't find shape when triggering destruction at slot " + index);
            return(-1);
        }

        // Declaring temp storage variable
        List <int> targetIndexes = CheckForSurroundingShapes(index, boardParent);
        GameSlot   slot;
        GameShape  shape = null;
        bool       destoryCurrentSlot      = false;
        int        newShapesBeingDestroyed = 0;

        if (targetIndexes != null)
        {
            foreach (int i in targetIndexes)
            {
                slot  = boardParent.GetChild(i).GetComponent <GameSlot>();
                shape = slot.GetSlotShape();

                if (gameManager.CheckForMatch(centerShape, shape))
                {
                    if (!shape.IsMarkedForDestruct())
                    {
                        shape.TriggerDestruction();
                        shape.MarkForDestruction();
                        newShapesBeingDestroyed++;
                        shapesBeingDestroyed++;
                    }

                    destoryCurrentSlot = true;
                }
            }
        }

        if (destoryCurrentSlot)
        {
            if (!centerShape.IsMarkedForDestruct())
            {
                centerShape.TriggerDestruction();
                centerShape.MarkForDestruction();
                newShapesBeingDestroyed++;
                shapesBeingDestroyed++;
            }
        }

        //onShapeDestroy?.Invoke(newShapesBeingDestroyed);
        return(newShapesBeingDestroyed);
    }
Exemplo n.º 16
0
    // tells how far apart two GameObjects are
    public double distanceTo(GameObject other)
    {
        GameObject g1 = this;
        GameObject g2 = other;
        GameShape  s1 = g1.getShape();
        GameShape  s2 = g2.getShape();

        double[] offset = new double[2];
        offset[0] = g2.getCenter()[0] - g1.getCenter()[0];
        offset[1] = g2.getCenter()[1] - g1.getCenter()[1];
        return(s1.distanceTo(s2, offset));
    }
Exemplo n.º 17
0
    // tells whether two GameObjects are currently overlapping
    public bool intersects(GameObject other)
    {
        GameObject g1 = this;
        GameObject g2 = other;
        GameShape  s1 = g1.getShape();
        GameShape  s2 = g2.getShape();

        double[] offset = new double[2];
        offset[0] = g2.getCenter()[0] - g1.getCenter()[0];
        offset[1] = g2.getCenter()[1] - g1.getCenter()[1];
        return(s1.intersects(s2, offset));
    }
Exemplo n.º 18
0
        /// <summary>Осуществляет поворот фигуры по часовой стрелке на 90 градусов.</summary>
        /// <returns>Повёрнутую фигуру.</returns>
        public GameShape Rotate()
        {
            GameShape res = Clone();

            res.X1 = RotateRow(Y1);
            res.Y1 = RotateCol(X1);
            res.X2 = RotateRow(Y2);
            res.Y2 = RotateCol(X2);
            res.X3 = RotateRow(Y3);
            res.Y3 = RotateCol(X3);
            return(res);
        }
Exemplo n.º 19
0
        public PhysicsEntity(GameShape shape)
        {
            float dens = 1.0f;

            Shape = shape;

            Mass    = shape.GetMass(dens);
            MassInv = 1 / Mass;

            Inertia    = shape.GetInertia(dens);
            InertiaInv = 1 / Inertia;
        }
 private ShapePipePair GetShapePipePair(GameShape shape)
 {
     foreach (ShapePipePair pair in Pairs)
     {
         if (pair.Shape == shape)
         {
             return(pair);
         }
     }
     Debug.Log("shape not found!");
     return(null);
 }
    private float MoveShape(ShapePipePair pair, float dt)
    {
        GameShape shape = pair.Shape;
        GamePipe  pipe  = pair.AttachedPipe;

        float   distanceTravelled   = dt * shape.Speed;
        float   percentualTravelled = shape.PercentualTraveled + distanceTravelled;
        Vector3 newPosition         = pipe.GetPositionFromPercentual(percentualTravelled);

        shape.UpdatePosition(percentualTravelled, newPosition);
        return(percentualTravelled);
    }
Exemplo n.º 22
0
    public virtual double distanceTo(GameShape other, double[] offset)
    {
        //double[] deltas = new double[offset.Length];
        double delta;
        double dist = 0;

        // offset in the x-dimension
        delta = Math.Abs(offset[0]);
        if (this.getType() == SHAPE.GAME_RECTANGLE)
        {
            delta -= this.getWidth() / 2;
        }
        if (other.getType() == SHAPE.GAME_RECTANGLE)
        {
            delta -= other.getWidth() / 2;
        }
        if (delta < 0)
        {
            delta = 0;
        }
        dist += delta * delta;
        // offset in the y-dimension
        delta = Math.Abs(offset[1]);
        if (this.getType() == SHAPE.GAME_RECTANGLE)
        {
            delta -= this.getWidth() / 2;
        }
        if (other.getType() == SHAPE.GAME_RECTANGLE)
        {
            delta -= other.getWidth() / 2;
        }
        if (delta < 0)
        {
            delta = 0;
        }
        dist += delta * delta;
        dist  = Math.Sqrt(dist);
        // subtract off the circular radius
        if (this.getType() == SHAPE.GAME_CIRCLE)
        {
            dist -= ((GameCircle)this).getRadius();
        }
        if (other.getType() == SHAPE.GAME_CIRCLE)
        {
            dist -= ((GameCircle)other).getRadius();
        }
        if (dist < 0)
        {
            dist = 0;
        }
        return(dist);
    }
    public GameShape CreateShape(GameShapeType newShapeType, GameSpawner spawner, float speed, float spawnSpeed)
    {
        GameShape shape = new GameShape(newShapeType, spawner, speed, spawnSpeed);

        ShapePipePair newPair = new ShapePipePair
        {
            Shape = shape
        };

        Pairs.Add(newPair);

        return(shape);
    }
Exemplo n.º 24
0
    public override bool Equals(object other)
    {
        GameShape otherShape = (GameShape)other;

        if (otherShape != null)
        {
            return(shapeType == otherShape.shapeType && colorType == otherShape.colorType);
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 25
0
        private static void checkAndApply(InputAction action, BlockGrid grid, GameShape shape)
        {
            List <Block>   shapeBlocks         = shape.CalcBlocksPostAction(action);
            List <Vector2> occupiedCoordinates = grid.GetOccupiedCoordinates();
            bool           collision           = CheckForCollisions(grid, shapeBlocks, shape);

            CheckForCollisions(grid, shape.blocks, shape);
            if (!collision)
            {
                shape.ApplyAction(action);
            }
            checkAboutToPlace(shape.blocks, shape, occupiedCoordinates);
        }
Exemplo n.º 26
0
 private void OnStateChanged(GameShape gameShape)
 {
     if (gameShape.State == GameShapeState.EXPLODING)
     {
         Debug.Log("exploded...");
         Invoke("BeforeDestruction", 0);
     }
     else if (gameShape.State == GameShapeState.FINISHED)
     {
         gameObject.transform.position = gameShape.Position;
         Invoke("BeforeDestruction", 0);
     }
 }
    private int GetPairIndex(GameShape shape)
    {
        for (int index = 0; index < Pairs.Count; index++)
        {
            ShapePipePair pair = Pairs[index] as ShapePipePair;

            if (pair.Shape == shape)
            {
                return(index);
            }
        }
        return(-1);
    }
    private void FromCorrectMoving(GameShape shape, GameShapeState shapeState)
    {
        switch (shapeState)
        {
        case GameShapeState.FINISHED:
            shape.SetState(GameShapeState.FINISHED);
            shape.OnShapeFinished(true);
            break;

        default:
            break;
        }
    }
Exemplo n.º 29
0
        //zagrywa karte z wybranej reki
        //funkcja do animacji, nie robi nic poza tym
        private void PlayCard(Deck playerHand, Deck playerTrick, Card cardToPlay)
        {
            var card         = cardToPlay;
            var gameShape    = GameShape.GetGameShape(card.Deck.Game);
            var cardShape    = gameShape.GetCardShape(card);
            var oldDeckShape = gameShape.GetDeckShape(card.Deck);

            card.Deck = playerTrick;
            // playerTrick.Visibility = System.Windows.Visibility.Visible;
            playerTrick.TopCard.Visible = true;

            gameShape.GetDeckShape(card.Deck).UpdateCardShapes();
        }
Exemplo n.º 30
0
        public void ApplyMoveActionTest()
        {
            List <Vector2> coordinates;
            GameShape      shape = BasicShapeInitialize(out coordinates, defaultOri);

            shape.ApplyAction(InputAction.MoveDown);

            //ensure move function called
            foreach (Block b in shape.blocks)
            {
                Assert.IsTrue(coordinates.Contains(new Vector2(b.GetX(), b.GetY() + 1)));
            }
        }
Exemplo n.º 31
0
        private void ClearGame()
        {
            this.LayoutRoot.Children.Remove(gameShape);
            foreach (DeckShape deck in gameShape.DeckShapes)
            {
                if((deck!=Dealer)&&(deck!=Ground)&&(this.LayoutRoot.Children.Contains(deck)))
                    this.LayoutRoot.Children.Remove(deck);
            }

            gameShape = new GameShape();
            this.LayoutRoot.Children.Add(gameShape);
            Canvas.SetZIndex(gameShape, -1);
        }
Exemplo n.º 32
0
 public Rock(GameShape Shape)
     : base(Shape)
 {
     Color = new Color4(1, 1, 1, 1);
 }