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; } }
public void SetPosition(Vector2 position) { gridLocation = position; transform.localPosition = Match3.GetWorldPosition(gridLocation); target = transform.localPosition; Match3.SetTile(gridLocation, this); }
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()); }
public void Destroy() { _state = State.Dying; transform.DOScale(Vector3.zero, 0.5f).OnComplete(() => { Match3.RemoveTile((int)gridLocation.x, (int)gridLocation.y); Destroy(this.gameObject); }); }
/// <summary> /// Initialization. /// </summary> void Start() { // GUI scaling. GUIScaler.Initialize(); // Game logic. match3 = new Match3(); // Start new game. NewGame(); }
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); } }
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; }
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; } }
private void Start() { _game = GetComponent <Match3>(); }
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(); }
void Start() { game = GetComponent <Match3>(); Screen.SetResolution(540, 960, false); }
public void Animate(Vector2 position) { target = Match3.GetWorldPosition(position); }
public void OnMouseUp() { Debug.Log("Released"); Match3.Release(); }
public void OnMouseDown() { Debug.LogFormat("Picked {0}", gameObject.name); Match3.Grab(this); }
// 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); }
// 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()); }
private void Awake() { Instance = this; _game = GetComponent <Match3>(); }
void Start() { game = GetComponent <Match3>(); }
void Awake() { instance = this; }