private void Start() { colorManager = PlayerManager.instance.GetColorManager; currentColor = colorManager.colorList[COLORS.WHITE]; prevColor = currentColor; currentColor.InitAbility(gameObject); colorInput = ObjectReferences.instance.colorInput; colorPieces[0] = ObjectReferences.instance.leftPiece; colorPieces[1] = ObjectReferences.instance.centerPiece; colorPieces[2] = ObjectReferences.instance.rightPiece; UpdateImage(); colorIndicator = ObjectReferences.instance.colorIndicator; UpdateColorWheel(); UpdateColorUI(); // REFERENCE CODE sr = GetComponent <SpriteRenderer>(); }
private void Update() { if (vol == null) { vol = Camera.main.GetComponent <Volume>(); if (vol != null) { vol.profile.TryGet(out colorAdjust); } } //Input detected if (colorInput.Direction != Vector2.zero) { canChoose = true; } else { if (colorChanged) { currentColor = colorManager.colorList[colorPieces[index].GetMain]; UpdateColorWheel(); UpdateColorUI(); prevColor.ExitAbility(gameObject); currentColor.InitAbility(gameObject); prevColor = currentColor; EventManager.instance.TriggerPlatformColorEvent(currentColor.GetMain); //Reset variables to default colorChanged = false; index = -1; ResetColorPiecesSize(); // Change character color hue // sr.color = currentColor.Color; // now change color of companion to current color hue if (currentColor.GetMain == COLORS.PURPLE) { companionSR.color = colorsOverlay[3]; } else if (currentColor.GetMain == COLORS.ORANGE) { companionSR.color = colorsOverlay[1]; } else { companionSR.color = currentColor.Color; } if (!companionSR.gameObject.GetComponent <Animator>().GetBool("Hue") && currentColor.Color != Color.white) // hasn't change to hue yet and the next color is not white shall you change to hue { companionSR.gameObject.GetComponent <Animator>().SetBool("Hue", true); } else if (currentColor.Color == Color.white) // switch out of hue if the next color is white instead { companionSR.gameObject.GetComponent <Animator>().SetBool("Hue", false); } } canChoose = false; ToggleVisualEffect(); } if (canChoose) { //Top left Quarter of joystick UpdateColorWheel(); ResetColorPiecesSize(); if (colorInput.Direction.x < 0f && colorInput.Direction.y > 0f && colorInput.Handle.anchoredPosition.magnitude >= 40f) { float dotProduct = Vector2.Dot(colorInput.Direction, Vector2.up); float angle = Mathf.Acos(dotProduct) * Mathf.Rad2Deg; if (angle <= 30f)//right piece { index = 2; } else if (angle <= 60f)//center piece { index = 1; } else if (angle <= 90f)//left piece { index = 0; } colorPieces[index].Image.rectTransform.sizeDelta = new Vector2(growSize, growSize); ToggleVisualEffect(index + 1); colorChanged = true; } else { colorChanged = false; colorAdjust.colorFilter.value = colorsEffects[0]; } } ToggleSlowDown(); currentColor.UpdateAbility(gameObject); }