Exemple #1
0
        public void addBomb(Vector3 position, TileCapture tileCapture, Color bombColor)
        {
            if (curBombs <= 0)
            {
                return;
            }

            GameObject newBombGameObj = new GameObject();
            ColorBomb  cb             = newBombGameObj.AddComponent <ColorBomb> ();

            cb.createBomb(position, tileCapture, bombColor, tileManager);
            bombs.Add(cb);
            curBombs--;
            updateText();
        }
Exemple #2
0
        //Update is called every frame.
        void Update()
        {
            if (levelInit.isInitializing())
            {
                return;
            }

            if (boardState.isLevelClear())
            {
                levelSelector.loadLevelSelect();
            }
            gameCounter++;
            if (gameCounter % 100 == 0)
            {
                //DrawTopColors();
                //Debug.Log(string.Format("gameCounter {0}", gameCounter));
            }
            if (!Input.GetKey("left ctrl") && !Input.GetMouseButton(1))
            {
                lastMousePos = null;
            }
            if (Input.GetKey("left ctrl") || Input.GetMouseButton(1))
            {
                //Debug.Log(string.Format("Co-ords of right click is [X: {0} Y: {1}]", pointClicked.x, pointClicked.y));
                if (lastMousePos.HasValue)
                {
                    Vector2 posDiff = mainCam.ScreenToWorldPoint(lastMousePos.Value) - mainCam.ScreenToWorldPoint(Input.mousePosition);
                    moveMainCam(posDiff);
                    //Debug.Log(string.Format("PosDiff {0} ", posDiff));
                }
                //Debug.Log(string.Format("Co-ords of right click is [X: {0} Y: {1}]", pointClicked.x, pointClicked.y));
                lastMousePos = Input.mousePosition;
            }
            else if (Input.GetMouseButtonDown(0))
            {
                Vector3   pointClicked = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                TileState tileState    = boardState.getTileState(pointClicked);
                if (tileState != null)
                {
                    Color       color         = tileState.getGameTile().getTileColor();
                    TileCapture bestTileMatch = boardState.processBombDrop(pointClicked, acm.getCurColor());
                    bombManager.addBomb(pointClicked, bestTileMatch, acm.getCurColor());
                    //Debug.Log(string.Format("Co-ords of mouse is [X: {0} Y: {1}] {2}", pointClicked.x, pointClicked.y, color.ToString()));
                }
            }
        }
Exemple #3
0
        public void createBomb(Vector3 initialPos, TileCapture tileCapture, Color color, TileManager tileManager)
        {
            this.initialPos  = initialPos;
            this.endTile     = tileCapture.tileState;
            this.startColor  = color;
            this.bombDamage  = tileCapture.capAmount;
            this.tileManager = tileManager;

            if (endTile != null)
            {
                this.endPos  = endTile.getTileMiddle();
                endDirection = new Vector2(endPos.Value.x - initialPos.x, endPos.Value.y - initialPos.y);
            }
            else
            {
                startColor.a = BAD_TILE_ALPHA;
            }

            setLr(backgroundRenderer, new Color(90, 90, 90, BAD_TILE_ALPHA), 9, .25f);
            setLr(colorRenderer, startColor, 10, .2f);

            colorRenderer.transform.position      = initialPos;
            backgroundRenderer.transform.position = initialPos;
        }