コード例 #1
0
ファイル: ModelManager.cs プロジェクト: meetjonblack/Aurora
        public void CreatePackage()
        {
            Vector3 previewPosition = new Vector3(30, 30 , 0);

            for (int i = 0; i < 4; i++)
            {
                if (((Game1)Game).rand.Next(2) == 1)
                {
                    package[i] = new Block(Game, Game.Content.Load<Model>(@"Models\blue_box"));
                    //package.Add(new Block(Game, Game.Content.Load<Model>(@"Models\blue_box")));

                }
                else
                {
                    package[i] = new Block(Game, Game.Content.Load<Model>(@"Models\rboxnew"));
                    //package.Add(new Block(Game, Game.Content.Load<Model>(@"Models\rboxnew")));
                }

            }

            ///Putting the elements where they belong....I thnk
            //current blocks are about 13x13.

            //Placing blocks in the preview position
            /*package.ElementAt(package.Count() - 1).SetLocation(new Vector3(-300.0f, 160.0f, -50.0f));
            package.ElementAt(package.Count() - 1).SetDestination(new Vector3(-13.0f, 13.0f, -50.0f));

            package.ElementAt(package.Count() - 2).SetLocation(new Vector3(-274.0f, 160.0f, -50.0f));
            package.ElementAt(package.Count() - 2).SetDestination(new Vector3(13.0f, 13.0f, -50.0f));

            package.ElementAt(package.Count() - 3).SetLocation(new Vector3(-300.0f, 134.0f, -50.0f));
            package.ElementAt(package.Count() - 3).SetDestination(new Vector3(-13.0f, -13.0f, -50.0f));

            package.ElementAt(package.Count() - 4).SetLocation(new Vector3(-274.0f, 134.0f, -50.0f));
            package.ElementAt(package.Count() - 4).SetDestination(new Vector3(13.0f, -13.0f, -50.0f));
            */

            //block 1
            package[0].SetLocation(new Vector3(-300.0f, 160.0f, -50.0f));
            package[0].SetDestination(new Vector3(-13.0f, 13.0f, -50.0f));

            //block 2
            package[1].SetLocation(new Vector3(-274.0f, 160.0f, -50.0f));
            package[1].SetDestination(new Vector3(13.0f, 13.0f, -50.0f));

            //block 3
            package[2].SetLocation(new Vector3(-300.0f, 134.0f, -50.0f));
            package[2].SetDestination(new Vector3(-13.0f, -13.0f, -50.0f));

            //block 4
            package[3].SetLocation(new Vector3(-274.0f, 134.0f, -50.0f));
            package[3].SetDestination(new Vector3(13.0f, -13.0f, -50.0f));
        }
コード例 #2
0
ファイル: Package.cs プロジェクト: meetjonblack/Aurora
        /// <summary>
        /// Up/Down helper function
        /// </summary>
        /// <param name="block">block that will be moved</param>
        /// <param name="m">list of models on the field</param>
        /// <param name="direction">direction of movement</param>
        private void VerticalHelper(ref Block block, List<BasicModel> m, string direction)
        {
            Vector3 tempLocation;
            Block tempBlock;
            bool isCollision;

            if (direction == "up")
            {
                tempLocation = block.GetLocation();
                tempLocation.Y += moveUnit;
                tempBlock = new Block(Game, tempLocation);
            }
            else
            {
                //moving the block down and setting its location
                tempLocation = block.GetLocation();
                tempLocation.Y -= moveUnit;
                tempBlock = new Block(Game, tempLocation);
            }

            //Checking for Collisions within the blocks on the field
            isCollision = CheckForCollisions(m, ref tempBlock);

            //if there hasn't been a collision with the blocks already on the field
            //checking for collisions within the setBlocks(if applicable)
            if ( !isCollision  && setBlocks.Count > 0)
                isCollision = CheckForCollisions(setBlocks, ref tempBlock);

            if (isCollision == true)
            {
                //adding the block to the setblock list
                setBlocks.Add(block);
                block.SetState(Block.BlockState.BLOCKY);

                if (block == topRight && bottomRight.GetState() != Block.BlockState.BLOCKY)
                {
                    //setting the blocks state to BLOCKy and then moving the appropriate units
                    setBlocks.Add(bottomRight);
                    bottomRight.SetState(Block.BlockState.BLOCKY);
                }

                else if (block == topLeft && bottomLeft.GetState() != Block.BlockState.BLOCKY)
                {
                    //setting the blocks state to BLOCKy and then moving the appropriate units
                    setBlocks.Add(bottomLeft);
                    bottomLeft.SetState(Block.BlockState.BLOCKY);
                }
                else if (block == bottomRight && topRight.GetState() != Block.BlockState.BLOCKY)
                {
                    setBlocks.Add(topRight);
                    topRight.SetState(Block.BlockState.BLOCKY);
                }

                else if (block == bottomLeft && topLeft.GetState() != Block.BlockState.BLOCKY)
                {
                    setBlocks.Add(topLeft);
                    topLeft.SetState(Block.BlockState.BLOCKY);
                }
            }
            //if there is no collision then moving the block up/down
            else if (isCollision == false && block.GetState() != Block.BlockState.BLOCKY)
            {
                block.SetLocation(tempLocation);
            }
        }
コード例 #3
0
ファイル: Package.cs プロジェクト: meetjonblack/Aurora
 private void CreatePackageHelper(ref Block block)
 {
     if (((Game1)Game).rand.Next(2) == 1)
     {
         block = new Block(Game, Game.Content.Load<Model>(@"Models\blue_box"));
     }
     else
     {
         block = new Block(Game, Game.Content.Load<Model>(@"Models\rboxnew"));
     }
 }
コード例 #4
0
ファイル: Package.cs プロジェクト: meetjonblack/Aurora
        private bool CheckForCollisions(List<BasicModel>models, ref Block block)
        {
            //creating and setting the isCollision flag to automatically be false
            //Innocent until proven guilty
            //bool isCollision = false;

            //checking the blocks that have already been set in case there is a possible collision
            foreach (Block b in models)
            {
                if (b.CollidesWith(block.GetLocation().X, block.GetLocation().Y))
                {
                    //stop drop and roll ya dig
                    //block.SetState(Block.BlockState.BLOCKY);

                    //collision has been found to notating that and breaking from the loop
                    return true;
                }
            }

            //returning false on all other occasions
            return false;
        }