Пример #1
0
    /*
     * Current max x where the background ends is +- 28.8
     * which is (sprite.width / 2) * 3
     * OR
     * (sprite.width / 2) + (9.6 * (tilesInX * 2))
     * For max y and min y it's the same formula with tilesInY
     */

    private void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            Instance = this;

            float spriteX = backgroundSprite.rect.width / 100f;
            float spriteY = backgroundSprite.rect.height / 100f;

            int tileMultiplyerX = 0;
            int tileMultiplyerY = 0;

            if (tilesInX > 0)
            {
                tileMultiplyerX = tilesInX + 1;
            }
            if (tilesInY > 0)
            {
                tileMultiplyerY = tilesInY + 1;
            }

            gameObject.GetComponent <BoxCollider2D>().size = new Vector2(spriteX + (spriteX * tileMultiplyerX),
                                                                         spriteY + (spriteY * tileMultiplyerY));

            maxX = (spriteX / 2f) + ((spriteX / 2f) * (tilesInX * 2));
            minX = -maxX;

            maxY = (spriteY / 2) + ((spriteY / 2f) * (tilesInY * 2));
            minY = -maxY;
        }
    }
Пример #2
0
        private bool CheckWallBounce(Vector2f destination, ref WorldBorder windowBorder, FloatRect borderBounds)
        {
            if (!(destination.Y - (_boundingBox.GetGlobalBounds().Height / 2f) <=
                  borderBounds.Top + windowBorder.Border.OutlineThickness) &&
                !(destination.Y + (_boundingBox.GetGlobalBounds().Height / 2f) >=
                  borderBounds.Height - windowBorder.Border.OutlineThickness))
            {
                return(false);
            }

            SetVelocity(new Vector2f(_velocity.X, -_velocity.Y)); // invert Y axis velocity
            return(true);
        }
Пример #3
0
        private bool CheckScore(Vector2f destination, ref WorldBorder windowBorder, FloatRect borderBounds)
        {
            if (destination.X - (_boundingBox.GetGlobalBounds().Width / 2f) <=
                borderBounds.Left + windowBorder.Border.OutlineThickness)
            {
                SetVelocity(new Vector2f());
                ResourceRegistry.GetSingleton <ScoreBoard>().ScorePoint(false);
                return(true);
            }

            if (destination.X + (_boundingBox.GetGlobalBounds().Width / 2f) >=
                borderBounds.Width - windowBorder.Border.OutlineThickness)
            {
                SetVelocity(new Vector2f());
                ResourceRegistry.GetSingleton <ScoreBoard>().ScorePoint(true);
                return(true);
            }

            return(false);
        }
Пример #4
0
 public void OnWorldBorder(WorldBorder packet)
 {
 }
Пример #5
0
 private void InvokeWorldBorder(WorldBorder packet)
 {
     packetListener.OnWorldBorder(packet);
 }