Exemplo n.º 1
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);


            debugTex = new Texture2D(GraphicsDevice, 1, 1);
            Color[] white = { new Color(1f, 1f, 1f) };
            debugTex.SetData(white);

            BgTile.addTexture(Content.Load <Texture2D>("dirtText"));
            BgTile.addTexture(Content.Load <Texture2D>("grassText"));
            BgTile.addTexture(Content.Load <Texture2D>("floorText"));
            BgTile.addTexture(Content.Load <Texture2D>("waterText"));
            BgTile.addTexture(Content.Load <Texture2D>("rockText"));

            BlockTexture.addTexture(Content.Load <Texture2D>("woodBlockText"));
            BlockTexture.addTexture(Content.Load <Texture2D>("treeBlockText"));



            Lizard.initLizard(Content.Load <Texture2D>("liz"), Content.Load <Texture2D>("dest"));



            this.player = new Player(new Camera(GraphicsDevice.Viewport),
                                     Content.Load <Texture2D>("cursor"),
                                     Content.Load <Texture2D>("indicator"),
                                     new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height));
            Lizard.player = player;

            this.world = new World(player);

            player.Init(this.world);
        }
Exemplo n.º 2
0
 private void generatePipeBar()
 {
     for (int i = 0; i < 6; i++)
     {
         BgTile temp = Instantiate(BackgroundTile, new Vector3(i + 0.8f + (i * 0.1f), -1.5f, 0), Quaternion.identity).GetComponent <BgTile>();
         temp.IsPipeBar = true;
         temp.pipeBarID = i;
         Instantiate(pipeBarContent[i], new Vector3(i + 0.8f + (i * 0.1f), -1.5f, 0), Quaternion.identity);
     }
 }
Exemplo n.º 3
0
 private bool doesGridHoldAPipe(float x, float y)
 {
     foreach (GameObject Go in pipeGrid)
     {
         BgTile bgt = Go.GetComponent <BgTile>();
         if (bgt.transform.position.x == x && bgt.transform.position.y == y)
         {
             return(bgt.pipeOnBg != null);
         }
     }
     return(false);
 }
Exemplo n.º 4
0
    private void handleClick(Vector3 worldPos, RaycastHit2D hitData)
    {
        bool isBackgroundTile = hitData && hitData.collider.GetComponent <BgTile>() != null;

        if (isBackgroundTile)
        {
            // player clicks on bar to select a pipe
            if (hitData.collider.GetComponent <BgTile>().IsPipeBar)
            {
                SelectedPipe = pipeBarContent[hitData.collider.GetComponent <BgTile>().pipeBarID];
            }
            // player has clicked on the grid
            else
            {
                // the player has a selected pipe that he wants to place
                if (SelectedPipe != null)
                {
                    if (isPipePlacementAllowed(SelectedPipe, hitData.collider.gameObject))
                    {
                        if (isPipeNextToLatestPipe(hitData.collider.gameObject))
                        {
                            // placing pipe
                            GameObject TempGo = Instantiate(SelectedPipe, hitData.transform.position, Quaternion.identity);
                            // registering pipe on tile
                            hitData.collider.gameObject.GetComponent <BgTile>().pipeOnBg = TempGo;
                            // adding to pipelist for waterflow
                            pipeList.Add(TempGo.GetComponent <Pipe>());
                            // the player now has to select a new pipe
                            SelectedPipe = null;

                            // check if game won
                            foreach (GameObject Go in pipeGrid)
                            {
                                BgTile bgt = Go.GetComponent <BgTile>();
                                if (bgt.transform.position.x == endPipe.transform.position.x - 1 && bgt.transform.position.y == endPipe.transform.position.y)
                                {
                                    if (bgt.pipeOnBg != null)
                                    {
                                        if (bgt.pipeOnBg.GetComponent <Pipe>().pipeType == Pipe.PipeType.HorizontalPipe || bgt.pipeOnBg.GetComponent <Pipe>().pipeType == Pipe.PipeType.LeftUpPipe ||  bgt.pipeOnBg.GetComponent <Pipe>().pipeType == Pipe.PipeType.LeftDownPipe)
                                        {
                                            GameWon();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 5
0
    private void PlaceStartAndEndPipe()
    {
        foreach (GameObject Go in pipeGrid)
        {
            BgTile bgt = Go.GetComponent <BgTile>();

            //Start pipe
            if (bgt.transform.position.x == 0 && bgt.transform.position.y == 2)
            {
                bgt.pipeOnBg = Instantiate(HorizontalPipe, new Vector3(0, 2, 0), Quaternion.identity);
                // add to pipelist to enable waterflow
                pipeList.Add(bgt.pipeOnBg.GetComponent <Pipe>());
            }

            //End pipe
            if (bgt.transform.position.x == gridWidth - 1 && bgt.transform.position.y == 3)
            {
                endPipe      = Instantiate(HorizontalPipe, new Vector3(gridWidth - 1, 3, 0), Quaternion.identity);
                bgt.pipeOnBg = endPipe;
            }
        }
    }