Exemplo n.º 1
0
    public MoveDown2(Grid2 gd, Block2 bc, Spawner2 sp, float _fallTime)
    {
        this.gd = gd;

        if (Time.time - bc.previosTime > _fallTime || bc.previosTime - Time.time > _fallTime)
        {
            //repeat:
            bc.transform.position += new Vector3(0, -1, 0);
            Debug.Log("carol");
            if (!ValidMove(bc.transform))
            {
                bc.transform.position -= new Vector3(0, -1, 0);
                gd.AddToGrid(bc.transform);
                gd.CheckForLines();
                bc.enabled = false;
                sp.CreateNewBlock(true);

                if (Time.timeScale == 0)
                {
                    return;
                }
                GamePlayManager.instance.PlaySound(3);
            }

            bc.previosTime = Time.time;
        }
    }
Exemplo n.º 2
0
    public GameWorld(int width, int height, ContentManager Content)
    {
        screenWidth = width;
        screenHeight = height;
        random = new Random();
        gameState = GameState.Menu;
        inputHelper = new InputHelper();
        block = Content.Load<Texture2D>("block");
        reset = Content.Load<Texture2D>("reset");
        font = Content.Load<SpriteFont>("SpelFont");
        font2 = Content.Load<SpriteFont>("SpriteFont1");
        font3 = Content.Load<SpriteFont>("SpriteFont2");
        playButton = Content.Load<Texture2D>("Play");
        optionsButton = Content.Load<Texture2D>("Options");
        backButton = Content.Load<Texture2D>("Back");
        polytris = Content.Load<Texture2D>("Polytris");
        grid = new TetrisGrid(block);
        level = 1;
        levelspeed = 1;
        score = 0;
        i = (int)random.Next(7) + 1;
        i2 = (int)random.Next(7) + 1;
        blockcounter = 1;

        blocks = new BlockList(block, Content);          //Voegen de verschillende blockobjecten toe aan de lijst
        block1 = new Block1(block, Content);
        blocks.Add(block1, 1);
        block2 = new Block2(block, Content);
        blocks.Add(block2, 2);
        block3 = new Block3(block, Content);
        blocks.Add(block3, 3);
        block4 = new Block4(block, Content);
        blocks.Add(block4, 4);
        block5 = new Block5(block, Content);
        blocks.Add(block5, 5);
        block6 = new Block6(block, Content);
        blocks.Add(block6, 6);
        block7 = new Block7(block, Content);
        blocks.Add(block7, 7);

        //Voegen de verschillende blockobjecten toe aan een tweede lijst voor het tekenen van het volgende blokje
        block1res = new Block1(block, Content);
        blocks.AddToReserve(block1res, 1);
        block2res = new Block2(block, Content);
        blocks.AddToReserve(block2res, 2);
        block3res = new Block3(block, Content);
        blocks.AddToReserve(block3res, 3);
        block4res = new Block4(block, Content);
        blocks.AddToReserve(block4res, 4);
        block5res = new Block5(block, Content);
        blocks.AddToReserve(block5res, 5);
        block6res = new Block6(block, Content);
        blocks.AddToReserve(block6res, 6);
        block7res = new Block7(block, Content);
        blocks.AddToReserve(block7res, 7);

        options = new Options(block, reset, backButton, width, height, font, blocks);
        menu = new Menu(playButton, optionsButton, polytris, width, height);
        gameOver = new GameOver(backButton, width, height);
    }
Exemplo n.º 3
0
        void showBlock(int level)
        {
            switch (level)
            {
            case 1:
                Block1.Show();
                Block1.Location = block.Location;
                break;

            case 2:
                Block2.Show();
                Block2.Location = block.Location;
                if (Block2.Left != Block1.Left)
                {
                    block.Hide();
                    Timer_Game3.Start();
                    fail();
                }
                break;

            case 3:
                Block3.Show();
                Block3.Location = block.Location;
                if (Block3.Left != Block2.Left)
                {
                    block.Hide();
                    Timer_Game3.Start();
                    fail();
                }
                break;
            }
        }
Exemplo n.º 4
0
    public void CreateNewBlock(bool useNext = false)
    {
        r = -1;
        if (useNext)
        {
            r = randomIndex;
        }

        if (r.Equals(-1))
        {
            r = random.Next(blocks.ToList().Count());
        }
        Debug.LogError(r);
        activeObject = blocks[r];

        activeBlock = activeObject.GetComponent <Block2>();

        //block
        activeBlock = Instantiate(activeBlock, new Vector3(pos.transform.position.x, pos.transform.position.y + 4, pos.transform.position.z + 1), Quaternion.identity);
        randomIndex = random.Next(blocks.ToList().Count());
        Destroy(Clone);
        //block
        Clone = Instantiate(blocks[randomIndex], new Vector3(Nextpos.transform.position.x - 13, Nextpos.transform.position.y, Nextpos.transform.position.z + 1), Quaternion.identity);
        //PlayerPrefs.SetInt ("nextBlockIndex", randomIndex);

        /* GameObject newshadow = Instantiate (shadows[r], spawnpoint, Quaternion.identity);
         * newshadow.GetComponent<shadowblock> ().SetParent (Clone); */

        /*foreach (Transform child in nextObjectPanel.transform) {
         *  child.gameObject.SetActive (false);
         *  if (child.name == blocks[PlayerPrefs.GetInt ("nextBlockIndex")].name) {
         *      child.gameObject.SetActive (true);
         *  }
         * }*/
    }
Exemplo n.º 5
0
 public MoveRight2(Grid2 gd, Block2 bc)
 {
     this.gd = gd;
     bc.transform.position += new Vector3(-1, 0, 0);
     if (!ValidMove(bc.transform))
     {
         bc.transform.position -= new Vector3(-1, 0, 0);
     }
 }
Exemplo n.º 6
0
 public CharacterInfo()
 {
     Block1  = new Block1();
     Block2  = new Block2();
     Block3  = new Block3();
     XAdjust = 0;
     YAdjust = 0;
     Trailer = 0xFFFF;
 }
Exemplo n.º 7
0
 public MoveUp2(Grid2 gd, Block2 bc)
 {
     this.gd = gd;
     bc.transform.RotateAround(bc.transform.TransformPoint(Block.rotationPoint), new Vector3(0, 0, 1), 90);
     if (!ValidMove(bc.transform))
     {
         bc.transform.RotateAround(bc.transform.TransformPoint(Block.rotationPoint), new Vector3(0, 0, 1), -90);
     }
 }
Exemplo n.º 8
0
 void HideBlock()
 {
     Block1.Hide();
     Block2.Hide();
     Block3.Hide();
     Block4.Hide();
     Block5.Hide();
     Block6.Hide();
     Block7.Hide();
     Block8.Hide();
     Block9.Hide();
     Block10.Hide();
 }
Exemplo n.º 9
0
 // Update is called once per frame
 void Update()
 {
     if (count == 0)
     {
         Block2.GetComponent <Animator>().SetTrigger("Play");
         Invoke("countUpdate", 0.7f);
     }
     else if (count == 1)
     {
         Block1.GetComponent <Animator>().SetTrigger("Play");
         Block2.GetComponent <Animator>().SetTrigger("Play");
         Invoke("countUpdate", 0.7f);
     }
 }
Exemplo n.º 10
0
        public void Draw(SpriteBatch spriteBatch, GraphicsDeviceManager graphics)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Draw(background, new Vector2(0, 0), Color.White);
            TennisBall.Draw(spriteBatch);
            Panel.Draw(spriteBatch);
            JumpButton.Draw(spriteBatch);
            Block2.Draw(spriteBatch);

            Button.Draw(spriteBatch);

            EndBlock.Draw(spriteBatch);
            gui.Draw(spriteBatch);
            spriteBatch.Draw(cursorTexture, cursorRectangle, Color.White);
        }
Exemplo n.º 11
0
 public int[,] createBlock()
 {
     if (r.Next(7) == 0)
     {
         Block1 newArray = new Block1();
         currentBlock = newArray.getArray();
         currentColor = Color.Cyan;
     }
     else if (r.Next(7) == 1)
     {
         Block2 newArray = new Block2();
         currentBlock = newArray.getArray();
         currentColor = Color.CornflowerBlue;
     }
     else if (r.Next(7) == 2)
     {
         Block3 newArray = new Block3();
         currentBlock = newArray.getArray();
         currentColor = Color.Orange;
     }
     else if (r.Next(7) == 3)
     {
         Block4 newArray = new Block4();
         currentBlock = newArray.getArray();
         currentColor = Color.Yellow;
     }
     else if (r.Next(7) == 4)
     {
         Block5 newArray = new Block5();
         currentBlock = newArray.getArray();
         currentColor = Color.LimeGreen;
     }
     else if (r.Next(7) == 5)
     {
         Block6 newArray = new Block6();
         currentBlock = newArray.getArray();
         currentColor = Color.Purple;
     }
     else
     {
         Block7 newArray = new Block7();
         currentBlock = newArray.getArray();
         currentColor = Color.Red;
     }
     return(currentBlock);
 }
Exemplo n.º 12
0
    /* #region Singleton
     * public static MoveFactory instance;
     *
     * public MoveFactory () {
     *  instance = this;
     * }
     #endregion */

    public Move2 PerformMove(string type, Block2 bc, Grid2 gd, Spawner2 sp, float fall = 0)
    {
        if (type == "Left")
        {
            return(new MoveLeft2(gd, bc));
        }
        else if (type == "Right")
        {
            return(new MoveRight2(gd, bc));
        }
        else if (type == "Up")
        {
            return(new MoveUp2(gd, bc));
        }
        else if (type == "Down")
        {
            if (gd == null)
            {
                Debug.Log("philip");
            }
            return(new MoveDown2(gd, bc, sp, fall));
        }
        return(null);
    }
Exemplo n.º 13
0
        public static async Task Validate(Transaction transaction)
        {
            var transactionStrings = JsonConvert.SerializeObject(transaction, Formatting.Indented);

            Console.WriteLine($"New Transaction : {transactionStrings} \n");

            float moneyLeft = 999999999.00f;
            User  fromUser  = new User();

            if (!IsDonatable)
            {
                fromUser  = _dbContext.Users.FirstOrDefault(x => x.Username == transaction.FromAddress);
                moneyLeft = fromUser.RemainingMoney;
            }

            if (moneyLeft < transaction.Amount)
            {
                Console.WriteLine("Money Not Enough!");
            }
            else
            {
                if (!IsDonatable)
                {
                    Console.WriteLine("User's Money : " + JsonConvert.SerializeObject(fromUser));
                    fromUser.RemainingMoney -= transaction.Amount;
                }

                transaction.HashedTransactionId = _hash.HashTransaction(transaction);
                var serializedTransaction = JsonConvert.SerializeObject(transaction);
                Client.Broadcast($"Verify : {serializedTransaction}");

                while (ConfirmedNumber < RequiredNumber() && ConfirmedNumber + RejectedNumber < NumNode)
                {
                    await Task.Delay(1000);
                }

                if (ConfirmedNumber < RequiredNumber())
                {
                    Console.WriteLine("Rejected Transaction.....");
                    ConfirmedNumber = 1;
                    RejectedNumber  = 0;
                }
                else
                {
                    var blockCharName = _dbContext.Foundations.OrderBy(x => x.NameEn).LastOrDefault()?.NameEn;

                    if (transaction.ToAddress == blockCharName)
                    {
                        var foundations         = _dbContext.Foundations.FirstOrDefault(x => x.NameEn == transaction.ToAddress);
                        var donatedTransactions = _dbContext.Transactions
                                                  .Where(x => x.IntendedFoundation == blockCharName)
                                                  .ToList();

                        foundations.TotalDonate  += foundations.TotalUnDonate;
                        foundations.TotalUnDonate = 0;

                        donatedTransactions.ForEach(x => x.IsDonated = true);
                        transaction.IsDonated = true;
                    }
                    else
                    {
                        var foundations = _dbContext.Foundations.FirstOrDefault(x => x.NameEn == transaction.IntendedFoundation);
                        foundations.TotalUnDonate += transaction.Amount;
                        transaction.FromAddress    = _hash.CalculateHash(transaction.FromAddress);
                    }

                    // foundations.TotalDonate += transaction.Amount;
                    _dbContext.Transactions.Add(transaction);
                    _dbContext.SaveChanges();

                    ConfirmedNumber = 1;
                    RejectedNumber  = 0;
                    Console.WriteLine("Added Transaction.....");
                    await Task.Delay(5000);

                    BlockGeneric block;
                    BlockGeneric prevBlock;
                    if (Program.Port == 2222)
                    {
                        block     = new Block1();
                        prevBlock = _dbContext.Blockchains1
                                    .OrderBy(x => x.UnixTimeStamp)
                                    .LastOrDefault();
                    }
                    else if (Program.Port == 2223)
                    {
                        block     = new Block2();
                        prevBlock = _dbContext.Blockchains2
                                    .OrderBy(x => x.UnixTimeStamp)
                                    .LastOrDefault();
                    }
                    else
                    {
                        block     = new Block3();
                        prevBlock = _dbContext.Blockchains3
                                    .OrderBy(x => x.UnixTimeStamp)
                                    .LastOrDefault();
                    }

                    var transactions = _dbContext.Transactions
                                       .Where(x => !x.IsCommitted)
                                       .OrderBy(x => x.UnixTimeStamp)
                                       .Take(block.MaxBlockSize)
                                       .ToList();

                    var hashedTransactions = String.Join('-', transactions.Select(x => x.HashedTransactionId));

                    block.HashedTransactionIds = hashedTransactions;
                    block.Height           = (prevBlock?.Height + 1) ?? 0;
                    block.PreviousHash     = prevBlock?.Hash;
                    block.TransactionJsons = transactions != null?JsonConvert.SerializeObject(transactions) : null;

                    block.UnixTimeStamp = DateTime.Now.ToUnixTimeStamp();
                    block.Hash          = _hash.HashBlock(block);
                    block.VerifiedBy    = _hash.CalculateHash(Program.Port.ToString());
                    block.BlockSize     = transactions.Count;

                    transactions.ForEach(x => x.BlockHeight = block.Height);

                    var serializedBlock = JsonConvert.SerializeObject(block, Formatting.Indented);
                    Console.WriteLine($"Transaction inside \n {JsonConvert.SerializeObject(transactions, Formatting.Indented)}");
                    Console.WriteLine($"BlockSize : {block.BlockSize}");
                    Console.WriteLine($"Block : {serializedBlock}\n");
                    Client.Broadcast($"New Block : {serializedBlock}");

                    while (ConfirmedNumber < RequiredNumber() && ConfirmedNumber + RejectedNumber < NumNode)
                    {
                        await Task.Delay(30);
                    }

                    if (ConfirmedNumber < RequiredNumber())
                    {
                        Console.WriteLine("Rejected Block.....");
                    }
                    else
                    {
                        Console.WriteLine("Added Block.....");
                        transactions.ForEach(x => x.IsCommitted = true);

                        if (Program.Port == 2222)
                        {
                            _dbContext.Blockchains1.Add((Block1)block);
                        }

                        else if (Program.Port == 2223)
                        {
                            _dbContext.Blockchains2.Add((Block2)block);
                        }

                        else
                        {
                            _dbContext.Blockchains3.Add((Block3)block);
                        }

                        await _dbContext.SaveChangesAsync();

                        Client.Broadcast($"Add Block to Chain : {JsonConvert.SerializeObject(block)}");
                        PreDonateToFoundationIfAble(transaction);
                    }
                    ConfirmedNumber = 1;
                    RejectedNumber  = 0;
                }
            }
        }
Exemplo n.º 14
0
 public bool IsValidFormat() =>
 Block1?.IsValidFormat() == true &&
 Block2?.IsValidFormat() == true &&
 Metadata?.IsValidFormat() == true;
Exemplo n.º 15
0
 private void OnTriggerEnter(Collider other)
 {
     Block1.GetComponent <MovingObstacle>().enabled = true;
     Block2.GetComponent <MovingObstacle>().enabled = true;
 }
Exemplo n.º 16
0
        public void Update(GameTime gameTime)
        {
            if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Panel.PanelRectangle, Panel.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Button.PanelRectangle, Button.PanelTextureData))
            {
                Block2.PanelPosition.Y -= 1000;
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, JumpButton.PanelRectangle, JumpButton.PanelTextureData))
            {
                TennisBall.BallVelocity.Y *= 2f;
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Block2.PanelRectangle, Block2.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (EndBlock.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, EndBlock.PanelRectangle, EndBlock.PanelTextureData))
            {
                TennisBall.Update(gameTime);
                finished = true;
            }
            else
            {
                TennisBall.Update(gameTime);
            }

            if (JumpButton.IntersectsPixel(cursorRectangle, cursorTextureData, JumpButton.PanelRectangle, JumpButton.PanelTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !TennisBall.started && !Button.IntersectsPixel(cursorRectangle, cursorTextureData, Button.PanelRectangle, Button.PanelTextureData))
            {
                float x, y;
                x = JumpButton.PanelPosition.X - mouse.X;
                y = JumpButton.PanelPosition.Y - mouse.Y;
                JumpButton.PanelPosition.X = Mouse.GetState().X + x;
                JumpButton.PanelPosition.Y = Mouse.GetState().Y + y;
            }
            if (Button.IntersectsPixel(cursorRectangle, cursorTextureData, Button.PanelRectangle, Button.PanelTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !TennisBall.started && !JumpButton.IntersectsPixel(cursorRectangle, cursorTextureData, JumpButton.PanelRectangle, JumpButton.PanelTextureData))
            {
                float x, y;
                x = Button.PanelPosition.X - mouse.X;
                y = Button.PanelPosition.Y - mouse.Y;
                Button.PanelPosition.X = Mouse.GetState().X + x;
                Button.PanelPosition.Y = Mouse.GetState().Y + y;
            }
            if (gui.Start.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Start.ButtonRectangle, gui.Start.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                TennisBall.started = true;
            }
            if (gui.Stop.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Stop.ButtonRectangle, gui.Stop.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed || !TennisBall.started)
            {
                TennisBall.started     = false;
                Block2.PanelPosition.Y = 420;
            }
            if (gui.Hint.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Hint.HRectangle, gui.Hint.HTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && TennisBall.started == false)
            {
                MessageBox.Show("Используй 2 блока для направления\n" +
                                "мяча к финишу, незабудь про поверхость пола!\n", "Подсказка #5", MessageBoxButtons.OK);
            }
            Panel.Update(gameTime);
            JumpButton.Update(gameTime);
            Block2.Update(gameTime);

            Button.Update(gameTime);

            EndBlock.Update(gameTime);

            gui.Update(gameTime);
            mouse           = Mouse.GetState();
            cursorRectangle = new Rectangle(mouse.X - (cursorTexture.Width / 2),
                                            mouse.Y - (cursorTexture.Height / 2), cursorTexture.Width, cursorTexture.Height);
        }
Exemplo n.º 17
0
	public void ExtendStructureX(bool IsBefore) {
		float i = Size.x;
		{
			Block2 NewBlock2 = new Block2(); 
			for (int j = 0; j < Size.y; j++) 
			{
				Block1 NewBlock1 = new Block1();
				for (int k = 0; k < Size.z; k++) 
				{
					Block0 NewBlock0 = new Block0();
					NewBlock1.AddData(NewBlock0);
				}
				NewBlock2.AddData(NewBlock1);
			}
			if (!IsBefore)
				Data.Add(NewBlock2);
			else 
				Data.Insert (0,NewBlock2);
		}
	}
Exemplo n.º 18
0
	public void InitilizeData() {
		ClearData ();
		for (int i = 0; i < Size.x; i++) 
		{
			Block2 NewBlock2 = new Block2(); 
			for (int j = 0; j < Size.y; j++) 
			{
				Block1 NewBlock1 = new Block1();
				for (int k = 0; k < Size.z; k++) 
				{
					Block0 NewBlock0 = new Block0();
					NewBlock1.AddData(NewBlock0);
				}
				NewBlock2.AddData(NewBlock1);
			}
			Data.Add(NewBlock2);
		}
		for (int i = 0; i < 32; i++) {
			BlockAmounts.Add (0);
		}
	}
Exemplo n.º 19
0
	public List<Block2> GetData() {
		List<Block2> NewData = new List<Block2>();
		
		for (int i = 0; i < SizeX; i++) 
		{
			Block2 NewBlock2 = new Block2(); 
			for (int j = 0; j < SizeY; j++) 
			{
				Block1 NewBlock1 = new Block1();
				for (int k = 0; k < SizeZ; k++) 
				{
					Block0 NewBlock0 = new Block0();
					NewBlock0.SetType(Data[i].Data[j].Data[k].Type);
					NewBlock0.SetIsActivated(Data[i].Data[j].Data[k].IsActivated);
					NewBlock1.AddData(NewBlock0);
				}
				NewBlock2.AddData(NewBlock1);
			}
			NewData.Add(NewBlock2);
		}
		return NewData;
	}