private StabilityNumberLine GetStabilityNumberLine() { if (this.stabilityNumberLine == null) { this.stabilityNumberLine = GameObject.FindObjectOfType <StabilityNumberLine> (); } return(this.stabilityNumberLine); }
/// <summary> /// Returns the stability number line. /// </summary> /// <returns>Stability Number Line</returns> public StabilityNumberLine GetNumberLine() { if (numberLine == null) { this.numberLine = FindObjectOfType <StabilityNumberLine> (); } return(this.numberLine); }
/// <summary> /// Spawns the blocks. /// </summary> /// <returns>None</returns> /// <param name="topic">Topic</param> /// <param name="skyBlocks">Sky blocks</param> /// <param name="numberLine">Number line</param> public IEnumerator SpawnBlocks(SceneTopic topic, SkyBlock[] skyBlocks, StabilityNumberLine numberLine) { if (!this.IsDoneSpawning()) { if (this.count > blockPlacements.Count) { this.count = blockPlacements.Count; } int spawnCount = this.count - hollowBlocks.Count; List <FractionData> fractionDataList = new List <FractionData>(); for (int i = 0; i < spawnCount; i++) { fractionDataList.Add(PedagogicalComponent_v2.Instance.RequestFraction()); yield return(null); } yield return(ComputeMaxPoint(fractionDataList)); numberLine.SetMaxPoint(this.maxPoint); EventBroadcaster.Instance.PostEvent(EventNames.SPAWN_BLOCKS_PROCESS_ON); for (int i = 0; i < spawnCount; i++) { HollowBlockParent temp = Instantiate <HollowBlockParent>(this.hollowBlockPrefab); if (topic == SceneTopic.SIMILAR_SUB || topic == SceneTopic.EQUIVALENT_SUB || topic == SceneTopic.DISSIMILAR_SUB) { PostSetMaxPointEvent(); //temp.GetHollowBlock().SetPreFilled(true); //temp.GetHollowBlock().SolvedFromPrefill(); //temp.GetHollowBlock().BlockProcessOn(); //temp.GetHollowBlock().SetFraction(PedagogicalComponent_v2.Instance.RequestFraction(), skyBlocks[i]); temp.GetHollowBlock().SetFraction(fractionDataList[i], skyBlocks[i]); } else { temp.GetHollowBlock().SetPreFilled(false); temp.GetHollowBlock().SetFraction(fractionDataList[i], null); //temp.GetHollowBlock().SetFraction(PedagogicalComponent_v2.Instance.RequestFraction(), null); } temp.GetHollowBlock().Init(); temp.GetHollowBlock().RegisterBlock(); temp.transform.position = blockPlacements[i].position; hollowBlocks.Add(temp); if (temp.GetHollowBlock().IsPreFilled()) { while (temp.GetHollowBlock().IsBeingProcessed()) { yield return(null); } } yield return(null); } } //EventBroadcaster.Instance.PostEvent(EventNames.RECONFIGURE_HIGHLIGHTS); yield return(null); }
/// <summary> /// Looks for controllers. /// </summary> private void LookForControllers() { if (this.hollowBlockController == null) { this.hollowBlockController = FindObjectOfType <HollowBlockController> (); } if (this.yarnballControl == null) { this.yarnballControl = FindObjectOfType <YarnballControl> (); } if (this.skyblockController == null) { this.skyblockController = FindObjectOfType <SkyBlockController> (); } // ADDED if (this.stabilityNumberLine == null) { this.stabilityNumberLine = FindObjectOfType <StabilityNumberLine>(); } }
/// <summary> /// Standard Unity Function. Called once in the game object's lifetime to initiate the script once it has been enabled. /// </summary> void Start() { // this.hollowBlocks.AddRange (FindObjectsOfType<HollowBlock> ()); numberLine = FindObjectOfType <StabilityNumberLine> (); UpdateSession(); }
/// <summary> /// Takes all currently registered ghost blocks and checks their values to determine what topic the puzzle is. /// Also updates the stability number line based on the currently registered blocks' values. /// </summary> private void UpdateSession() { List <int> denominators = new List <int> (); FractionSet fset = new FractionSet(); bool similar = true; bool oddEquiv = true; bool evenEquiv = true; int currentDenom = (int)hollowBlocks [0].GetDenominator(); for (int i = 0; i < hollowBlocks.Count; i++) { denominators.Add((int)hollowBlocks[i].GetDenominator()); FractionData fraction = hollowBlocks [i].GetFraction(); if (i > 0) { if (similar && currentDenom == fraction.denominator) { similar = true; } else { similar = false; } if (evenEquiv && currentDenom % 2 == 0 && (currentDenom % fraction.denominator == 0 || fraction.denominator % currentDenom == 0 || (General.SimplifyFraction(fraction.numerator, fraction.denominator) [0] == 1.0f && General.SimplifyFraction(fraction.numerator, fraction.denominator) [1] == 2.0f))) { evenEquiv = true; } else { evenEquiv = false; } if (oddEquiv && currentDenom % 3 == 0 && (currentDenom % fraction.denominator == 0 || fraction.denominator % currentDenom == 0 || (General.SimplifyFraction(fraction.numerator, fraction.denominator) [0] == 1.0f && General.SimplifyFraction(fraction.numerator, fraction.denominator) [1] == 3.0f) || (General.SimplifyFraction(fraction.numerator, fraction.denominator) [0] == 2.0f && General.SimplifyFraction(fraction.numerator, fraction.denominator) [1] == 3.0f))) { oddEquiv = true; } else { oddEquiv = false; } // if (similar && fraction.denominator == (int)hollowBlocks [i - 1].GetDenominator ()) // similar = true; // else // similar = false; // // if (evenEquiv && (fraction.denominator % 2) == ((int)hollowBlocks [i - 1].GetDenominator () % 2)) // evenEquiv = true; // else // evenEquiv = false; // // if (oddEquiv && (fraction.denominator % 3) == ((int)hollowBlocks [i - 1].GetDenominator () % 3)) // oddEquiv = true; // else // oddEquiv = false; } fset.fractions.Add(fraction); } if (similar) { topic = SessionTopic.SIMILAR; } else if (evenEquiv || oddEquiv) { topic = SessionTopic.EQUIVALENT; } else { topic = SessionTopic.DISSIMILAR; } this.currentSession = new StabilizationSession(topic, this.sceneAvgSolveTime); if (numberLine == null) { this.numberLine = FindObjectOfType <StabilityNumberLine> (); } FractionData target = this.stabilityController.UpdateStabilityNumberLine(hollowBlocks); // FractionData target = new FractionData (); // target.numerator = (int)numberLine.GetTargetNumerator (); // target.denominator = (int)numberLine.GetTargetDenominator (); foreach (FractionSet s in SubsetSumFractions.SubsetSum(fset, target)) { additionRight.Add(s); } }
/// <summary> /// Standard Unity Function. Used to initialize the instance if it is enabled. Only called once in its life. /// </summary> void Start() { this.numberLine = FindObjectOfType <StabilityNumberLine> (); }