void Update() { if (!gameOver) { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, maxDistance)) { if (hit.transform.tag == "Sphere") { Colours.ColourNames sphereColor = hit.transform.GetComponent <Sphere>().GetColour(); FindObjectOfType <MatchingBox>().HandleMatchingColour(_cursor.GetColor(), sphereColor); _cursor.SetColor(sphereColor); _sphereManager.MoveSphere(hit.transform.gameObject); _scoreManager.UpdateScore(hit.transform.localScale.x); } else { _scoreManager.ResetMultiplyer(); } } } } }
public void MoveSphere(GameObject sphere) { Colours.ColourNames newColour = GetRandomColor(); sphere.transform.position = GetRandomPosition(); sphere.GetComponent <Sphere>().SetColour(newColour); SpawnNewSphere(); AkSoundEngine.PostEvent("POP", gameObject); }
public void SetColour(Colours.ColourNames newColour) { var material = GetComponent <MeshRenderer>().material; material.SetColor("_Color", Colours.ColourValue(newColour)); material.SetColor("_EmissionColor", Colours.ColourValue(newColour)); currentColour = newColour; if (currentColour == Colours.ColourNames.Red) { material.SetColor("_EmissionColor", new Color32(40, 1, 0, 1)); } }
public void HandleMatchingColour(Colours.ColourNames cursorColour, Colours.ColourNames orbColour) { bool doubleValue = false; if (currentColour == Colours.ColourNames.Green) { if (cursorColour == Colours.ColourNames.Blue && orbColour == Colours.ColourNames.Yellow) { doubleValue = true; GetRandomColour(); } else if (cursorColour == Colours.ColourNames.Yellow && orbColour == Colours.ColourNames.Blue) { doubleValue = true; GetRandomColour(); } } if (currentColour == Colours.ColourNames.Purple) { if (cursorColour == Colours.ColourNames.Blue && orbColour == Colours.ColourNames.Red) { doubleValue = true; GetRandomColour(); } else if (cursorColour == Colours.ColourNames.Red && orbColour == Colours.ColourNames.Blue) { doubleValue = true; GetRandomColour(); } } if (currentColour == Colours.ColourNames.Orange) { if (cursorColour == Colours.ColourNames.Red && orbColour == Colours.ColourNames.Yellow) { doubleValue = true; GetRandomColour(); } else if (cursorColour == Colours.ColourNames.Yellow && orbColour == Colours.ColourNames.Red) { doubleValue = true; GetRandomColour(); } } if (doubleValue) { _animator.SetTrigger("ScoreDoubled"); FindObjectOfType <ScoreManager>().DoubleScore(); } }
private void GetRandomColour() { var rendererMaterial = GetComponent <Renderer>().material; var newColour = coloursToChoose[Random.Range(0, 3)]; rendererMaterial.SetColor("_Color", Colours.ColourValue(newColour)); rendererMaterial.SetColor("_EmissionColor", Colours.ColourValue(newColour)); currentColour = newColour; if (currentColour == Colours.ColourNames.Orange) { rendererMaterial.SetColor("_EmissionColor", new Color32(84, 5, 0, 1)); } Debug.Log($"Setting new colour: {currentColour.ToString()}"); }
public void SetColor(Colours.ColourNames newColor) { if (newColor == Colours.ColourNames.Red) { SetCursorColour(redCursorTexture); currentColor = Colours.ColourNames.Red; } else if (newColor == Colours.ColourNames.Blue) { SetCursorColour(blueCursorTexture); currentColor = Colours.ColourNames.Blue; } else if (newColor == Colours.ColourNames.Yellow) { SetCursorColour(yellowCursorTexture); currentColor = Colours.ColourNames.Yellow; } }
void Start() { SetCursorColour(cursorTexture); currentColor = Colours.ColourNames.Purple; }