public void ReleaseBubble() { //release current bubble if (bubble != null) { bubble.ChangeState(bubble.GetComponent <HeldState>()); bubble = null; } }
public void SetPermanentNumber(int num) { //Add new permanent bubble GameObject bubbleGO = BubbleFactory.Instance.SpawnBubble(num, transform.position); Bubble bubble = bubbleGO.GetComponent <Bubble>(); CombineWith(bubble); //make sure they can't move the bubble StuckEquationState stuckState = bubbleGO.AddComponent <StuckEquationState>(); bubble.ChangeState(stuckState); isPermanent = true; if (bubble.number > 9) { renderer.enabled = false; } }
//Put other bubble script into this equation public override void CombineWith(Bubble other) { //Don't switch if we have a permanent bubble already if (isPermanent && bubble != null) { return; } //Debug.Log("holder combo ith bubble?"+other.number); //release current bubble ReleaseBubble(); //Hold the new bubble bubble = other; InEquationState equationState = other.GetComponent <InEquationState>(); other.ChangeState(equationState); equationState.holder = this; other.transform.position = transform.position; //attempt to solve the equation with the new bubble equation.AttemptSolve(); }