Example #1
0
        public void Position2DY()
        {
            tlog.Debug(tag, $"Position2DY START");

            var testingTarget = new Position2D(2, 3);

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <Position2D>(testingTarget, "Should return Position2D instance.");

            Assert.AreEqual(3, testingTarget.Y, "The Y property of position is not correct here.");

            testingTarget.Y = 2;
            Assert.AreEqual(2, testingTarget.Y, "The Y property of position is not correct.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"Position2DY END (OK)");
        }
Example #2
0
        public void Position2DNotEqualTo()
        {
            tlog.Debug(tag, $"Position2DNotEqualTo START");

            var testingTarget = new Position2D(10, 20);

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <Position2D>(testingTarget, "Should return Position2D instance.");

            using (Position2D position = new Position2D(1, 2))
            {
                Assert.IsTrue((testingTarget.NotEqualTo(position)), "Should be equal");
            }

            testingTarget.Dispose();
            tlog.Debug(tag, $"Position2DNotEqualTo END (OK)");
        }
Example #3
0
        public void Position2DUnaryNegation()
        {
            tlog.Debug(tag, $"Position2DUnaryNegation START");

            var testingTarget = new Position2D(2, 3);

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <Position2D>(testingTarget, "Should return Position2D instance.");

            var result = -testingTarget;

            Assert.AreEqual(-2, result.X, "The X value of the position is not correct!");
            Assert.AreEqual(-3, result.Y, "The Y value of the position is not correct!");

            testingTarget.Dispose();
            tlog.Debug(tag, $"Position2DUnaryNegation END (OK)");
        }
Example #4
0
        public void Position2DMultiplyByInteger()
        {
            tlog.Debug(tag, $"Position2DMultiplyByInteger START");

            var testingTarget = new Position2D(2, 3);

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <Position2D>(testingTarget, "Should return Position2D instance.");

            var result = testingTarget * 10;

            Assert.AreEqual(20, result.X, "The X value of the position is not correct!");
            Assert.AreEqual(30, result.Y, "The Y value of the position is not correct!");

            testingTarget.Dispose();
            tlog.Debug(tag, $"Position2DMultiplyByInteger END (OK)");
        }
Example #5
0
        public void WindowSetPosition()
        {
            tlog.Debug(tag, $"WindowSetPosition START");
            try
            {
                Position2D p1 = null;
                myWin.SetPosition(p1);
            }
            catch (Exception e)
            {
                Tizen.Log.Error(tag, "Caught Exception" + e.ToString());

                Assert.Fail("Caught Exception" + e.ToString());
            }
            tlog.Debug(tag, $"WindowSetPosition END (OK)");
            Assert.Pass("WindowSetPosition");
        }
Example #6
0
        private void CalculateContentPosition()
        {
            var    size   = Size2D;
            var    parent = GetParent();
            Size2D parentSize;

            if ((parent != null) && (parent is View))
            {
                parentSize = ((View)parent).Size;
            }
            else
            {
                parentSize = NUIApplication.GetDefaultWindow().Size;
            }

            Position2D = new Position2D((parentSize.Width - size.Width) / 2, (parentSize.Height - size.Height) / 2);
        }
Example #7
0
        public void KeyValuePosition2DValue()
        {
            tlog.Debug(tag, $"KeyValuePosition2DValue START");

            Position2D b1 = new Position2D(1, 1);
            KeyValue   a1 = new KeyValue
            {
                Position2DValue = b1
            };

            b1 = a1.Position2DValue;

            b1.Dispose();
            a1.Dispose();
            tlog.Debug(tag, $"KeyValuePosition2DValue END (OK)");
            Assert.Pass("KeyValuePosition2DValue");
        }
Example #8
0
    public override void _Ready()
    {
        player           = GetNode("Player") as PlayerObject;
        startPosition    = GetNode("StartPosition") as Position2D;
        startTimer       = GetNode("StartTimer") as Timer;
        scoreTimer       = GetNode("ScoreTimer") as Timer;
        mobTimer         = GetNode("MobTimer") as Timer;
        mobSpawnLocation = GetNode("MobPath").GetNode("MobSpawnLocation") as PathFollow2D;
        hud        = GetNode("HUD") as HUDObject;
        deathSound = GetNode("DeathSound") as AudioStreamPlayer;
        music      = GetNode("Music") as AudioStreamPlayer;

        hud.Connect("StartGame", this, "NewGame");
        player.Connect("Hit", this, "GameOver");

        randomGenerator = new Random();
    }
Example #9
0
    public override void _Ready()
    {
        line    = GetNode <Line2D>("Line");
        end     = GetNode <Position2D>("End");
        rayCast = GetNode <RayCast2D>("RayCast2D");

        int rand = (int)GD.RandRange(0, 1);

        if (rand == 0)
        {
            isClockWise = true;
        }
        else if (rand == 1)
        {
            isClockWise = false;
        }
    }
Example #10
0
File: Game.cs Project: wsenh/ld47
        public override void _Ready()
        {
            base._Ready();
            Map     = GetNode <Node2D>("Map");
            Spawn   = Map.GetNode <Position2D>("Spawn");
            Corpses = GetNode <Node2D>("Corpses");
            Camera  = GetNode <Camera2D>("MainCamera");
            UI      = GetNode <UI>("CanvasLayer/UI");
            RotationAnimationPlayer = GetNode <RotationAnimationPlayer>("RotationAnimationPlayer");

            Emitter.Instance.Connect(nameof(Emitter.NewPlayerSignal), this, nameof(OnNewPlayer));
            Emitter.Instance.Connect(nameof(Emitter.ActivateCheckPoint), this, nameof(OnActivateCheckPoint));
            Emitter.Instance.Connect(nameof(Emitter.Finish1Game), this, nameof(OnFinish1Game));
            Emitter.Instance.Connect(nameof(Emitter.Finish2Game), this, nameof(OnFinish2Game));

            SpawnPlayer();
        }
Example #11
0
        /*
         *  @ValidateStartPosition -> Valida a posicao da peca de acordo com o valor de origem
         */

        public void ValidateStartPosition(Position2D pos)
        {
            if (Board.GetPiece(pos) == null)
            {
                throw new BoardException("Não existe peça na posição de origem selecionada!");
            }

            if (CurrentPlayer != Board.GetPiece(pos).Color)
            {
                throw new BoardException("A peça de origem escolhida não é sua!");
            }

            if (!Board.GetPiece(pos).ExistMoviments())
            {
                throw new BoardException("Não existem moviemntos possíveis para a peça escolhida!");
            }
        }
        public Position3D TryToFitObject(Object3D selectedObject)
        {
            double     bestFittingQuality = Double.MaxValue;
            double     localFittingQuality;
            Position2D positionToPlace = null;

            GuillotineCutContainer2D selectedContainer = GuillotineContainer;

            // No space in container - return from function
            if (selectedContainer.Subcontainers.Count == 0)
            {
                return(null);
            }

            GuillotineCutSubcontainer2D selectedSubcontainer = selectedContainer.Subcontainers.First() as GuillotineCutSubcontainer2D;

            // flattens object to 2D during single shelf placement
            Object2D selectedObject2D = new Object2D(selectedObject.Width, selectedObject.Height);

            foreach (GuillotineCutSubcontainer2D subcontainer in selectedContainer.Subcontainers)
            {
                if (ValidateObjectPlacement(selectedObject2D, subcontainer))
                {
                    localFittingQuality = CalculateFittingQuality(selectedObject2D, subcontainer);
                    if (localFittingQuality < bestFittingQuality)
                    {
                        bestFittingQuality   = localFittingQuality;
                        selectedSubcontainer = subcontainer;
                        positionToPlace      = subcontainer.Position;
                    }
                }
            }


            if (positionToPlace != null)
            {
                var newPlacedObject = selectedContainer.PlaceObject(selectedObject2D, positionToPlace) as PlacedObject2D;
                UpdateMaxDepth(selectedObject.Depth);
                selectedContainer.SplitSubcontainer(selectedSubcontainer, newPlacedObject);
                return(new Position3D(positionToPlace.X, positionToPlace.Y, this.Depth));
            }
            else
            {
                return(null);
            }
        }
Example #13
0
        public static Position2D NoteToGridPos(byte note)
        {
            byte[,] grid = GetButtons();
            Position2D holder = new Position2D(0, 0);

            for (int xscan = 0; xscan < grid.GetLength(0); xscan++)
            {
                for (int yscan = 0; yscan < grid.GetLength(1); yscan++)
                {
                    if (grid[xscan, yscan] == note)
                    {
                        holder = new Position2D(xscan, yscan);
                    }
                }
            }
            return(holder);
        }
Example #14
0
            public IEnumerator WHEN_BalloonRoundAdded1Round_THEN_BalloonRoundGetterReturnsCorrectValues()
            {
                balloonsData        = new BalloonsStorage();
                balloonsData.Rounds = new List <BalloonsRound>();

                round = new BalloonsRound();

                round.BalloonSize = 180;
                double expectedBalloonSize = 180;

                round.DestinationClickTime = 1.5;
                double expectedDestinationClickTime = 1.5;

                round.DestinationPoint = new Position2D(0, 0);
                Position2D expectedDestinationPoint = new Position2D(0, 0);

                round.SuccessClickPoint = new Position2D(-200, 67);
                Position2D expectedSuccessClickPoint = new Position2D(-200, 67);

                TimeAndPosition testItem1 = new TimeAndPosition(0.5, new Position2D(10, 20));
                TimeAndPosition testItem2 = new TimeAndPosition(1.5, new Position2D(0.1, -40));

                round.Clicks = new List <TimeAndPosition>();
                round.Clicks.Add(testItem1);
                round.Clicks.Add(testItem2);

                balloonsData.Rounds.Add(round);
                BalloonsRound actualCirclesRound = balloonsData.Rounds[0];

                yield return(null);

                Assert.IsTrue(expectedBalloonSize == actualCirclesRound.BalloonSize);
                Assert.IsTrue(expectedDestinationClickTime == actualCirclesRound.DestinationClickTime);
                Assert.IsTrue(Math.Abs(expectedDestinationPoint.X - actualCirclesRound.DestinationPoint.X) <= tolerance &&
                              Math.Abs(expectedDestinationPoint.Y - actualCirclesRound.DestinationPoint.Y) <= tolerance);
                Assert.IsTrue(Math.Abs(expectedSuccessClickPoint.X - actualCirclesRound.SuccessClickPoint.X) <= tolerance &&
                              Math.Abs(expectedSuccessClickPoint.Y - actualCirclesRound.SuccessClickPoint.Y) <= tolerance);
                Assert.IsTrue(2 == actualCirclesRound.Clicks.Count);
                Assert.IsTrue(Math.Abs(testItem1.Time - actualCirclesRound.Clicks[0].Time) <= tolerance &&
                              Math.Abs(testItem1.Position.X - actualCirclesRound.Clicks[0].Position.X) <= tolerance &&
                              Math.Abs(testItem1.Position.Y - actualCirclesRound.Clicks[0].Position.Y) <= tolerance);
                Assert.IsTrue(Math.Abs(testItem2.Time - actualCirclesRound.Clicks[1].Time) <= tolerance &&
                              Math.Abs(testItem2.Position.X - actualCirclesRound.Clicks[1].Position.X) <= tolerance &&
                              Math.Abs(testItem2.Position.Y - actualCirclesRound.Clicks[1].Position.Y) <= tolerance);
            }
Example #15
0
    public void Init(Vector2 _position, int score, Mode mode = Mode.Normal)
    {
        player          = null;
        animationPlayer = GetNode <AnimationPlayer>("AnimationPlayer");

        gemPivot = GetNode <Node2D>("GemPivot");

        if (score < 10)
        {
            SetNormalSpawnRate(100, mode, score);
        }
        else if (score < 20)
        {
            SetNormalSpawnRate(70, mode, score);
            radius = 148;
        }
        else if (score < 25)
        {
            SetNormalSpawnRate(40, mode, score);
            radius = 144;
        }
        else
        {
            SetNormalSpawnRate(10, mode, score);
            radius = 140;
        }

        Position = _position;
        var collisionShape = GetNode <CollisionShape2D>("CollisionShape2D");

        collisionShape.Shape = (Shape2D)collisionShape.Shape.Duplicate();
        collisionShape.Shape.Set("radius", radius);

        var imgSize = GetNode <Sprite>("Sprite").Texture.GetSize().x / 2;

        GetNode <Sprite>("Sprite").Scale = new Vector2(1, 1) * radius / imgSize;

        orbitPosition = GetNode <Position2D>("Pivot/Orbit");
        var pos = new Vector2(radius + 25, orbitPosition.Position.y);

        orbitPosition.Position = pos;
        rotationSpeed         *= Mathf.Pow(-1, GD.Randi() % 2);

        SetLuckyGem();
    }
Example #16
0
        public void PositionConstructorWithPosition2D()
        {
            tlog.Debug(tag, $"PositionConstructorWithPosition2D START");

            Position2D position2D = new Position2D(50, 50);

            var testingTarget = new Position(position2D);

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <Position>(testingTarget, "Should return Position instance.");

            Assert.AreEqual(50.0f, testingTarget.X, "Should be equal!");
            Assert.AreEqual(50.0f, testingTarget.Y, "Should be equal!");
            Assert.AreEqual(0.0f, testingTarget.Z, "Should be equal!");

            testingTarget.Dispose();
            tlog.Debug(tag, $"PositionConstructorWithPosition2D END (OK)");
        }
    public override void _Ready()
    {
        cannon             = GetNode <Position2D>("Cannon");
        animationPlayer    = GetNode <AnimationPlayer>("AnimationPlayer");
        bulletCaseParticle = GetNode <CPUParticles2D>("BulletCaseParticle");
        shootSound         = GetNode <AudioStreamPlayer2D>("ShootAudioPlayer");


        STATE_READY = new FSM.State(WeaponReadyUpdate)
        {
            Name = "Ready"
        };
        STATE_TIMEOUT = new WaitState(TimeoutDuration, STATE_READY)
        {
            Name = "Reloading"
        };
        machine = new FSM(STATE_READY);
    }
Example #18
0
        public void Position2DConstructorWithPosition()
        {
            tlog.Debug(tag, $"Position2DConstructorWithPosition START");

            using (Position position = new Position(5.0f, 5.0f, 0.5f))
            {
                var testingTarget = new Position2D(position);
                Assert.IsNotNull(testingTarget, "null handle");
                Assert.IsInstanceOf <Position2D>(testingTarget, "Should return Position2D instance.");

                Assert.AreEqual(5.0f, testingTarget.X, "The X property of position is not correct here.");
                Assert.AreEqual(5.0f, testingTarget.Y, "The Y property of position is not correct here.");

                testingTarget.Dispose();
            }

            tlog.Debug(tag, $"Position2DConstructorWithPosition END (OK)");
        }
        public void InitializeGame()
        {
            Debug.Log("Initialize ECS cubespawner");
            var entityManager = World.Active.GetExistingManager <EntityManager>();

            for (int i = 0; i < cubeCount; i++)
            {
                var cube       = GameObject.CreatePrimitive(PrimitiveType.Cube);
                var cubeEntity = cube.AddComponent <GameObjectEntity>().Entity;

                var endPosition = new Position2D();
                endPosition.Value = new float2(Random.Range(-1000, 1000), Random.Range(-1000, 1000));
                entityManager.AddComponentData(cubeEntity, new CubeComponent()
                {
                    EndPosition = endPosition
                });
            }
        }
Example #20
0
        private void MovePlayerInCurrentDirection(bool append = false, Action onAppend = null)
        {
            playerBody.Enqueue(playerPosition);

            playerPosition += lastDirection = currentDirection;
            freeCells.Remove(playerPosition);

            if (append)
            {
                onAppend?.Invoke();
                return;
            }

            if (playerBody.Count > 0)
            {
                freeCells.Add(playerBody.Dequeue());
            }
        }
Example #21
0
    public Transform CreateRepresentation(IPlaceable placeable)
    {
        //TODO replace this with good code
        if (!(placeable is GroundTile))
        {
            return(null);
        }
        GroundTile.GroundTileType type = ((GroundTile)placeable).GetTileType();

        Position   pos   = placeable.GetPosition();
        Position2D pos2D = pos.AsPosition2D();

        tileTypes [(int)type].transform.position = new Vector3(pos2D.GetX(), pos2D.GetY(), 0);
        Transform newTile = GameObject.Instantiate(tileTypes [(int)type]);

        activeTiles.Add(newTile);
        return(newTile);
    }
Example #22
0
        public void Position2DEquals()
        {
            tlog.Debug(tag, $"Position2DEquals START");

            var testingTarget = new Position2D(1, 1);

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <Position2D>(testingTarget, "Should return Position2D instance.");

            using (Position2D position = new Position2D(1, 1))
            {
                var result = testingTarget.Equals(position);
                Assert.IsTrue(result, "Should be true here!");
            }

            testingTarget.Dispose();
            tlog.Debug(tag, $"Position2DEquals END (OK)");
        }
Example #23
0
        public void SiblingTest1()
        {
            Position2D _myPos = new Position2D(100, 30);

            for (int i = 0; i < 10; i++)
            {
                PushButton _view = new PushButton();

                _view.Name         = "sibling" + i;
                _view.LabelText    = "view" + i;
                _view.MinimumSize  = new Size2D(100, 50);
                _view.ParentOrigin = ParentOrigin.TopLeft;
                _view.PivotPoint   = PivotPoint.TopLeft;
                _view.Position2D   = _myPos + new Position2D(20 * i, 10 * i);

                _window.Add(_view);
            }
        }
Example #24
0
    public List <Position2D> GetMinionPositions(int minionCount)
    {
        List <Position2D> minionList = new List <Position2D>();

        Position2D upPos   = new Position2D(basePosition.x, basePosition.y + 1);
        Position2D downPos = new Position2D(basePosition.x, basePosition.y - 1);

        if (map.getTileTypeAt(upPos.x, upPos.y) != TileType.Water)
        {
            minionList.Add(upPos);
        }
        else
        {
            minionList.Add(downPos);
        }

        return(minionList);
    }
    public void NewGame()
    {
        GetNode <Timer>("MobTimer").SetWaitTime(_waitTime);
        GetNode <AudioStreamPlayer>("Music").Play();
        _score = 0;

        Player     player        = GetNode <Player>("Player");
        Position2D startposition = GetNode <Position2D>("StartPosition");

        player.Start(startposition.Position);

        GetNode <Timer>("StartTimer").Start();

        HUD hud = GetNode <HUD>("HUD");

        hud.UpdateScore(_score);
        hud.ShowMessage("Get Ready!");
    }
Example #26
0
        public IsotropicGasParticle(double d, double hmax) : base(hmax)
        {
            Vel      = new Position2D();
            Vel.Name = "Vel";
            AddChild(Vel);

            AddDiffVect(Vel);
            this.D = d;

            dV      = new Position2D();
            dV.Name = "dV";
            AddChild(dV);
            Vel.AddDiffVect(dV, false);


            // AddDiffPropToParam(pRo,pdRo);
            AddDiffPropToParam(pE, pdE);
        }
Example #27
0
        /// <summary>
        /// Returns null if the position is not valid
        /// </summary>
        private Position2D GetPosition2D(Position position)
        {
            Position2D position2D = position.AsPosition2D();

            if (position2D == null)
            {
                Debug.Log("is not a 2D position");
                return(null);
            }
            int x = position2D.GetX();
            int y = position2D.GetY();

            if (x >= _sizeX || y >= _sizeY)
            {
                return(null);
            }
            return(position2D);
        }
Example #28
0
 public void addFrontier(Position2D frontier, bool blockedByRiver, bool canCrossMountains)
 {
     if (isFrontier(frontier.x, frontier.y))
     {
         if (map.isPassable(map.getTileTypeAt(frontier.x, frontier.y), canCrossMountains))
         {
             if (!blockedByRiver)
             {
                 frontiers.Add(frontier);
             }
             else
             {
                 riverFrontiers.Add(frontier);
                 setState(State.needsBridge, true);
             }
         }
     }
 }
Example #29
0
        public override void Execute(ObjectSet originalObjects)
        {
            int selectedFitContainerIndex = 0;

            Position2D positionToPlace = null;

            SkylineContainer2D selectedContainer = containers.First() as SkylineContainer2D;

            var objectsCopy = originalObjects.ToObjectList();

            while (objectsCopy.Any())
            {
                Object2D selectedObject = objectsCopy.First() as Object2D;

                for (int i = 0; i < containers.Count; i++)
                {
                    positionToPlace = FindMostBottomFittingSkyline(containers[i] as SkylineContainer2D, selectedObject);

                    if (positionToPlace != null)
                    {
                        selectedFitContainerIndex = i;
                        break;
                    }
                }

                // Object not placed, create new container, place object bottom-left
                if (positionToPlace == null)
                {
                    AddContainer();

                    selectedContainer = containers.Last() as SkylineContainer2D;

                    positionToPlace = new Position2D(0, 0);
                }
                else
                {
                    selectedContainer = containers[selectedFitContainerIndex] as SkylineContainer2D;
                }

                objectsCopy.Remove(selectedObject);
                selectedContainer.PlaceNewObject(selectedObject, positionToPlace);
                selectedFitContainerIndex = 0;
            }
        }
    private void handlePizzaComplete(int pizzaIndex)
    {
        Entity     pizzaEntity   = pizzaData.Entities[pizzaIndex];
        PizzaGroup pizzaGroup    = pizzaData.PizzaGroup[pizzaIndex];
        Position2D pizzaPosition = pizzaData.Position[pizzaIndex];
        PizzaCost  pizzaCost     = pizzaData.PizzaCost[pizzaIndex];

        // Pizza is done.
        Debug.Log("PIZZA DONE - " + pizzaGroup.PizzaId + ": " + pizzaCost.OrderCost + " | " + pizzaCost.ActualCost);

        // Update global score.
        PostUpdateCommands.CreateEntity();
        PostUpdateCommands.AddComponent(new DeductScore {
            Value = pizzaCost.ActualCost
        });
        PostUpdateCommands.AddSharedComponent(new ScoringGroup {
            GroupId = 0
        });

        // Delete this Pizza.
        MoveSpeed toWindow = new MoveSpeed {
            speed = BootStrap.GameSettings.ArrowSpeed
        };
        TimedLife timedLife = new TimedLife {
            TimeToLive = 10.0f
        };

        PostUpdateCommands.AddComponent(pizzaEntity, toWindow);
        PostUpdateCommands.AddComponent(pizzaEntity, timedLife);
        PostUpdateCommands.RemoveComponent <PizzaGroup>(pizzaEntity);

        // TODO: While ingredients are flying off with the pizza, arrows could hit them.
        for (int i = 0; i < IngredientData.CalculateLength(); i++)
        {
            Entity ingredientEntity = IngredientData.GetEntityArray()[i];
            //PostUpdateCommands.AddComponent(ingredientEntity, toWindow);
            //PostUpdateCommands.AddComponent(ingredientEntity, timedLife);
            //PostUpdateCommands.RemoveComponent<PizzaGroup>(ingredientEntity);
            PostUpdateCommands.DestroyEntity(ingredientEntity);
        }

        // Create new Pizza.
        createNewPizza(pizzaIndex);
    }
Example #31
0
 public bool SwapPositions(Position2D first, Position2D second)
 {
     return SwapPositions(first.Y, first.X, second.Y, second.X);
 }
Example #32
0
    private void bubblePositionUp(ref int i, int j)
    {
        if (BulletBubbling != null)
        {
            BulletBubbling(new BulletActionEventArgs(new Position2D(j, i), null));
        }

        while (i > 0)
        {
            var first = new Position2D(j, i);
            var second = new Position2D(j, --i);

            SwapPositions(first, second);
            Debug_PrintAndSleep();
        }
    }
Example #33
0
 public void Set(Position2D upperLeft, Position2D lowerRight)
 {
     UpperLeftCorner = upperLeft;
     LowerRightCorner = lowerRight;
 }
Example #34
0
 public bool CanSwapPositions(Position2D first, Position2D second)
 {
     Position2D[] compass = createCompass(first);
     bool areNotEqual = !(first.Equals(second));
     return !IsOutOfBounds(first) && !IsOutOfBounds(second) && areNotEqual && compass.Any(a => a.Equals(second));
 }
Example #35
0
 public void Set(int x1, int y1, int x2, int y2)
 {
     UpperLeftCorner = new Position2D(x1, y1);
     LowerRightCorner = new Position2D(x2, y2);
 }
Example #36
0
 private bool IsOutOfBounds(Position2D position)
 {
     return position.Y < 0 || position.Y >= this.Height
         || position.X < 0 || position.X >= this.Width;
 }
Example #37
0
 private bool isStreak(Position2D pos)
 {
     return isStreak(pos.Y, pos.X);
 }
Example #38
0
    private bool positionCanMakeMatches(Position2D position)
    {
        Position2D[] compass = createCompass(position);

        foreach (Position2D direction in compass)
        {
            if (CanSwapPositions(direction, position))
            {
                SwapPositions(position, direction);
                bool swapSuccess = CollectMatchedBullets().Count > 0;
                SwapPositions(position, direction);

                if (swapSuccess)
                {
                    return true;
                }
            }
        }

        return false;
    }
Example #39
0
 public void Set(Position2D pos, Dimension2D size)
 {
     UpperLeftCorner = pos;
     LowerRightCorner = new Position2D(pos.X + size.Width, pos.Y + size.Height);
 }
Example #40
0
 public void SpawnFullGrid()
 {
     if (this.BulletSpawned != null)
     {
         StepThroughGrid((i, j) =>
         {
             var position = new Position2D(j, (Height - 1) - i);
             var bullet = GetBulletAt(position);
             BulletSpawned(new BulletActionEventArgs(position, bullet));
         });
     }
 }
Example #41
0
    public Position2D GetBulletPosition(JDBullet bullet)
    {
        Position2D position = new Position2D();

        StepThroughGrid(
            (i, j) =>
            {
                if (grid[i, j] == bullet)
                {
                    position.X = j;
                    position.Y = i;
                }
            });

        return position;
    }
Example #42
0
 public static Rect From(Position2D upperL, Position2D lowerR)
 {
     Rect toR = new Rect();
     toR.Set(upperL, lowerR);
     return toR;
 }
Example #43
0
    public bool IsBadSwap(Position2D first, Position2D second)
    {
        SwapPositions(first, second);

        #if DEBUG || RELEASE
        if (this.enablePrinting)
        {
            Debug_PrintAndSleep();
        }
        #endif
        bool anyMatches = CollectMatchedBullets().Count > 0;
        SwapPositions(first, second);

        #if DEBUG || RELEASE
        if (this.enablePrinting)
        {
            Debug_PrintAndSleep();
        }
        #endif
        return anyMatches;
    }
Example #44
0
 public PositionTransferEventArgs(Position2D origin, Position2D next)
 {
     this.origin = origin;
     this.next = next;
 }
Example #45
0
    public JDBullet GetBulletAt(Position2D position)
    {
        if (position.X >= this.Width || position.X < 0 || position.Y >= this.Height || position.Y < 0)
        {
            return null;
        }

        return grid[position.Y, position.X];
    }
Example #46
0
 public Rect(Position2D pos, Dimension2D size)
 {
     UpperLeftCorner = new Position2D();
     LowerRightCorner = new Position2D();
     Set(pos, size);
 }
Example #47
0
 public bool CanSwapPositions(int i, int j, int i2, int j2)
 {
     Position2D first = new Position2D(j, i);
     Position2D second = new Position2D(j2, i2);
     return CanSwapPositions(first, second);
 }
Example #48
0
 public void AddInternalPoint(Position2D pos)
 {
     AddInternalPoint(pos.X, pos.Y);
 }
Example #49
0
 public BulletActionEventArgs(Position2D point, JDBullet bulletSpawned)
 {
     this.point = point;
     this.bulletSpawned = bulletSpawned;
 }
Example #50
0
 /// <summary>
 /// Returns if a 2d point is within this rectangle.
 /// </summary>
 /// <param name="pos"> Position to test if it lies within this rectangle.</param>
 /// <returns> Returns true if the position is within the rectangle, false if not.</returns>
 public bool IsPointInside(Position2D pos)
 {
     return UpperLeftCorner.X <= pos.X && UpperLeftCorner.Y <= pos.Y &&
         LowerRightCorner.X >= pos.X && LowerRightCorner.Y >= pos.Y;
 }
Example #51
0
 public GameObjectTransferEventArgs(GameObject gameObject, Position2D position)
 {
     this.gameObject = gameObject;
     this.position = position;
 }
Example #52
0
    private Position2D[] createCompass(Position2D center)
    {
        int i = center.X;
        int j = center.Y;

        return new Position2D[]
        {
            new Position2D(i + 1, j),
            new Position2D(i - 1, j),
            new Position2D(i, j + 1),
            new Position2D(i, j - 1)
        };
    }
Example #53
0
 public Rect(Position2D upperLeft, Position2D lowerRight)
 {
     UpperLeftCorner = new Position2D();
     LowerRightCorner = new Position2D();
     Set(upperLeft, lowerRight);
 }
Example #54
0
    private void QueueBulletInSpawner(JDBullet bullet, Position2D point)
    {
        BulletSpawner spawner = GetBulletSpawner(point.X);
        GameObject fallingBullet = spawner.SpawnBullet(bullet);
        FallingBullet group = this.GetBulletGroup(bullet);

        if (group != null)
        {
            fallingBullet.transform.parent = group.gameObject.transform;
        }

        FallingBullet fallingBulletScript = fallingBullet.GetComponent<FallingBullet>();

        if (fallingBulletScript != null)
        {
            fallingBulletScript.MySpawner = spawner;
            this.AllBullets.Add(fallingBulletScript);
        }

        toSpawn.Enqueue(fallingBullet);
    }