Beispiel #1
0
    public static void AddBonusPoints(int height, int width, int i, Point p, List <Point> kill, List <Point> bonus)
    {
        switch (i)
        {
        case 1:
            for (int j = 1; j < height - 1; j++)
            {
                bonus.Add(new Point(p.x, j));
            }
            Match3.AddPoints(ref kill, bonus);
            break;

        case 2:
            for (int k = 1; k < width - 1; k++)
            {
                bonus.Add(new Point(k, p.y));
            }
            Match3.AddPoints(ref kill, bonus);
            break;

        case 3:
            for (int j = 1; j < height - 1; j++)
            {
                bonus.Add(new Point(p.x, j));
            }
            Match3.AddPoints(ref kill, bonus);

            for (int k = 1; k < width - 1; k++)
            {
                bonus.Add(new Point(k, p.y));
            }
            Match3.AddPoints(ref kill, bonus);
            break;
        }
    }
Beispiel #2
0
 public void SetPosition(Vector2 position)
 {
     gridLocation            = position;
     transform.localPosition = Match3.GetWorldPosition(gridLocation);
     target = transform.localPosition;
     Match3.SetTile(gridLocation, this);
 }
Beispiel #3
0
 private void Start()
 {
     GetSpriteRenderer   = gameObject.GetComponent <SpriteRenderer>();
     GetMatch3           = GameObject.Find("GameManager").GetComponent <Match3>();
     GetLiveSystem       = GameObject.Find("GameManager").GetComponent <LiveSystem>();
     GetCircleCollider2D = gameObject.GetComponent <CircleCollider2D>();
     StartCoroutine(activeCollider());
 }
Beispiel #4
0
 public void Destroy()
 {
     _state = State.Dying;
     transform.DOScale(Vector3.zero, 0.5f).OnComplete(() =>
     {
         Match3.RemoveTile((int)gridLocation.x, (int)gridLocation.y);
         Destroy(this.gameObject);
     });
 }
Beispiel #5
0
    /// <summary>
    /// Initialization.
    /// </summary>
    void Start()
    {
        // GUI scaling.
        GUIScaler.Initialize();

        // Game logic.
        match3 = new Match3();

        // Start new game.
        NewGame();
    }
Beispiel #6
0
    public IEnumerator moveDown(int rows)
    {
        Match3  match   = GameObject.FindObjectOfType(typeof(Match3)) as Match3;
        Vector3 lastPos = transform.position;
        Vector3 newPos  = new Vector3(transform.position.x, transform.position.y - rows, transform.position.z);
        float   time    = 0;

        while (time < 1)
        {
            time += Time.deltaTime;
            transform.position = Vector3.Lerp(lastPos, newPos, time);
            yield return(null);
        }
    }
Beispiel #7
0
    public void Setup(Match3 match3, Grid <Match3.GemGridPosition> grid)
    {
        this.match3 = match3;
        this.grid   = grid;

        float cameraYOffset = 1f;

        cameraTransform.position = new Vector3(grid.GetWidth() * .5f, grid.GetHeight() * .5f + cameraYOffset, cameraTransform.position.z);

        match3.OnGemGridPositionDestroyed += Match3_OnGemGridPositionDestroyed;
        match3.OnNewGemGridSpawned        += Match3_OnNewGemGridSpawned;

        // Initialize Visual
        gemGridDictionary   = new Dictionary <Match3.GemGrid, GemGridVisual>();
        glassGridDictionary = new Dictionary <Match3.GemGridPosition, GlassGridVisual>();

        for (int x = 0; x < grid.GetWidth(); x++)
        {
            for (int y = 0; y < grid.GetHeight(); y++)
            {
                Match3.GemGridPosition gemGridPosition = grid.GetGridObject(x, y);
                Match3.GemGrid         gemGrid         = gemGridPosition.GetGemGrid();

                Vector3 position = grid.GetWorldPosition(x, y);
                position = new Vector3(position.x, 12);

                // Visual Transform
                Transform gemGridVisualTransform = Instantiate(pfGemGridVisual, position, Quaternion.identity);
                gemGridVisualTransform.Find("sprite").GetComponent <SpriteRenderer>().sprite = gemGrid.GetGem().sprite;

                GemGridVisual gemGridVisual = new GemGridVisual(gemGridVisualTransform, gemGrid);

                gemGridDictionary[gemGrid] = gemGridVisual;

                // Glass Visual Transform
                Transform glassGridVisualTransform = Instantiate(pfGlassGridVisual, grid.GetWorldPosition(x, y), Quaternion.identity);

                GlassGridVisual glassGridVisual = new GlassGridVisual(glassGridVisualTransform, gemGridPosition);

                glassGridDictionary[gemGridPosition] = glassGridVisual;

                // Background Grid Visual
                Instantiate(pfBackgroundGridVisual, grid.GetWorldPosition(x, y), Quaternion.identity);
            }
        }

        SetBusyState(.5f, () => SetState(State.TryFindMatches));

        isSetup = true;
    }
Beispiel #8
0
    private void Awake()
    {
        if (grid_ref == null)
        {
            grid_ref = GameObject.FindGameObjectWithTag("Grid").GetComponent <TheGrid>();
        }

        instance = this;

        if (box_prefab != null)
        {
            boxWidth = box_prefab.GetComponent <SpriteRenderer>().sprite.rect.width;
        }
    }
Beispiel #9
0
 private void Start()
 {
     _game = GetComponent <Match3>();
 }
Beispiel #10
0
    void Update()
    {
        instance = this;
        var energy = (Time.time / 2.0f) % 10 / 10;
        var life   = (Time.time % 10) / 10;

        energyBar.transform.localScale = new Vector3(energy, 1, 1);
        lifeBar.transform.localScale   = new Vector3(life, 1, 1);
        if (hasChanges && match3 != null)
        {
            if (waitCounter++ < waitTime)
            {
                return;
            }

            hasChanges = !match3.check();

            if (state == NeedsFallDown)
            {
                fallDown();
                state = NeedsRefill;
            }
            else if (state == NeedsRefill)
            {
                refill();
                state = Done;
            }
            else if (hasChanges && state == Done)
            {
                delete();
                state = NeedsFallDown;
                comboCounter++;
                text = "Points: " + points + "   Combo: x" + comboCounter;
            }
            else
            {
                comboCounter = 0;
                text         = "Points: " + points;
            }
            waitCounter = 0;
        }
        output.text = text;

        //Resolution res = Screen.currentResolution;
        //screen = new Vector3 (res.width, res.height);

        if (lastScale == scale)
        {
            return;
        }
        match3 = new Match3();
        match3.init(w, h);
        hasChanges = true;
        lastScale  = scale;
        foreach (var item in gameObject.GetComponentsInChildren <Tile>())
        {
            if (item.tag != "keep")
            {
                Destroy(item.gameObject);
            }
        }
        data = new TileData[h][];
        //size = (int) (scale * 3);
        for (int y = 0; y < h; y++)
        {
            var row = new TileData[w];
            for (int x = 0; x < w; x++)
            {
                row [x] = new TileData {
                    y = y, x = x
                };
            }
            data [y] = row;
        }
        for (int tempY = 0; tempY < h; tempY++)
        {
            for (int tempX = 0; tempX < w; tempX++)
            {
                createButton(tempY, tempX, data [tempY] [tempX]);
            }
        }
        refreshColours();
    }
Beispiel #11
0
 void Start()
 {
     game = GetComponent <Match3>();
     Screen.SetResolution(540, 960, false);
 }
Beispiel #12
0
 public void Animate(Vector2 position)
 {
     target = Match3.GetWorldPosition(position);
 }
Beispiel #13
0
 public void OnMouseUp()
 {
     Debug.Log("Released");
     Match3.Release();
 }
Beispiel #14
0
 public void OnMouseDown()
 {
     Debug.LogFormat("Picked {0}", gameObject.name);
     Match3.Grab(this);
 }
    /// <summary>
    /// Initialization.
    /// </summary>
    void Start()
    {
        // GUI scaling.
        GUIScaler.Initialize();

        // Game logic.
        match3 = new Match3();

        // Start new game.
        NewGame();
    }
Beispiel #16
0
 // Use this for initialization
 void Start()
 {
     cam = GameObject.Find("Camera").camera;
     mt  = GameObject.Find("Match3Object").GetComponent <Match3> ();
 }
 public void LoadLevel(LevelNumberSO levelNumberSO) {
     Match3.LoadLevel(levelNumberSO);
 }
Beispiel #18
0
    // Start is called before the first frame update
    private void Start()
    {
        if (previewBoxes == null)
        {
            previewBoxes = GameObject.FindGameObjectWithTag("PreviewBoxes").GetComponent <PreviewBoxes>();
        }

        if (scoreUI == null)
        {
            scoreUI = GameObject.FindGameObjectWithTag("Score").GetComponent <ScoreUI>();
        }

        if (match3_ref == null)
        {
            match3_ref = GetComponent <Match3>();
        }

        if (audioSource == null)
        {
            audioSource = GetComponent <AudioSource>();
        }

        audioVolume = audioSource.volume;
        isMuted     = false;

        Random.InitState(seed.GetHashCode());

#if UNITY_STANDALONE
        if (loadMapFilename.Any())
        {
            loadGridLayoutFromFile(Application.streamingAssetsPath + "\\" + loadMapFilename);
        }
#endif

#if UNITY_WEBGL
        loadGridLayoutFromArray(defaultLayoutMap);
#endif

        if (gridLayout == null)
        {
            loadGridLayoutFromArray(defaultLayoutMap);
        }
        width  = gridLayout.GetLength(0);
        height = gridLayout.GetLength(1);

        //making sure default values are valid
        width  = (width < 0) ? 0 : width;
        height = (width < 0) ? 0 : width;
        seed   = (!seed.Any()) ? getRandomSeed() : seed;

        grid = new Tile[width, height];

        setupGrid();

        if (player == null)
        {
            player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
        }

        player.SpawnAt(new Point(width / 2 + 2, height / 2 + 2));

        previewBoxes.generateNextPreview();
        spawnTriBox(previewBoxes.getCurrentBoxElements());
    }
Beispiel #19
0
 private void Awake()
 {
     Instance = this;
     _game    = GetComponent <Match3>();
 }
Beispiel #20
0
 void Start()
 {
     game = GetComponent <Match3>();
 }
Beispiel #21
0
 void Awake()
 {
     instance = this;
 }