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); }
public void RemoveShape(GameShape shape) { shapeList.Remove(shape); if (shapeList.Count == 0 && OnPipeRemoved != null) { OnPipeRemoved(this); } }
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); } }
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); }
//strategy shape state changed, by spawn type protected void TimeShapeStateChanged(GameShape shape) { if (shape.State == GameShapeState.EXPLODING) { CancelInvoke(SpawnShapeFunction); StartShapeSpawn(afterExplodeDelay); } }
public bool WillBlockShape(GameShape incoming) { bool flag = false; if (this.FilledShape != null) { flag = this.FilledShape.WillBlockShapeAtBoardSlot(incoming, this); } return(flag); }
private void Reset(IUIThreadDispatcher uiThreadDispatcher) { uiThreadDispatcher.BlockingInvoke(() => { game = new GameShape(); pluginContainer.Child = game; }); currentMoveSuggestions.Clear(); }
private void OnEnable() { gameShape = GetComponent <GameShape>(); elementImage = GetComponent <Image>(); LoadElement(ThemeManager.GetCurrentTheme(), ThemeManager.GetCurrentColorMode()); if (updateDynamically) { ThemeManager.onThemeSettingsUpdate += LoadElement; } }
protected void FinishShapeStateChanged(GameShape shape) { if (shape.State == GameShapeState.EXPLODING) { Invoke(SpawnShapeFunction, afterExplodeDelay); } else if (shape.State == GameShapeState.FINISHED) { Invoke(SpawnShapeFunction, afterFinishDelay); } }
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()); }
private void TimeOrFinishShapeStateChanged(GameShape shape) { if (shape.State == GameShapeState.EXPLODING) { Invoke(CheckSpawnShapeFunction, afterExplodeDelay); } else if (shape.State == GameShapeState.FINISHED) { Invoke(CheckSpawnShapeFunction, afterFinishDelay); } }
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); }
// 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)); }
// 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)); }
/// <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); }
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); }
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); }
public override bool Equals(object other) { GameShape otherShape = (GameShape)other; if (otherShape != null) { return(shapeType == otherShape.shapeType && colorType == otherShape.colorType); } else { return(false); } }
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); }
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; } }
//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(); }
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))); } }
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); }
public Rock(GameShape Shape) : base(Shape) { Color = new Color4(1, 1, 1, 1); }