private void GenerateMemoryPhaseSymbols(int count) { for (int i = 0; i < count; i++) { var clone = Instantiate(memorySymbolPrefab, transform.position, Quaternion.identity); MemorySymbols memorySymbols = clone.GetComponent <MemorySymbols>(); memorySymbols.BackgroundColor.GetComponent <Image>().color = RandomColour(); memorySymbols.Rune.GetComponent <Image>().sprite = earth; clone.transform.parent = transform; } }
private void SetTestSlotItems() { List <GameObject> symbolList = RandomLevelGenerator_V2.Instance.CurrentLevelSymbols; for (int i = 0; i < symbolList.Count; i++) { MemorySymbols memSymbolsScript = symbolList[i].GetComponent <MemorySymbols>(); TestSlot slot = new TestSlot(); slot.ColourCode = memSymbolsScript.ColourCode.ToString(); slot.ShapeCode = memSymbolsScript.ShapeCode.ToString(); slot.CellNumber = (i + 1).ToString(); session.TestSlots.Add(slot); } }
//Switch Colour of symbols when symbol count is 3 or less. private void ColourSwitchSymbols() { bool isSelectable = true; for (int i = 0; i < memoryPhaseSymbols.Count; i++) { for (int x = 0; x < memoryPhaseSymbols.Count; x++) { //Debug.Log( "Names : " + memoryPhaseSymbols[i].Name + " " + memoryPhaseSymbols[x].Name ); if (memoryPhaseSymbols[i].Name != memoryPhaseSymbols[x].Name) { isSelectable = true; //Debug.Log( "No Match Found So im going to do my thing...." ); while (isSelectable) { //Pick a random symbol from the list. GameObject selectedMemorySymbol = cloneSymbols[Random.Range(0, cloneSymbols.Count)]; //Debug.Log( "SELECTED SYMBOL : " + selectedMemorySymbol ); MemorySymbols memorySymbolsScript = selectedMemorySymbol.GetComponent <MemorySymbols>(); //If the random symbol isnt a winning symbol //and it hasnt already been colour switched if (!memorySymbolsScript.IsCorrect && !memorySymbolsScript.IsColourSwitched) { //Set the background colour memorySymbolsScript.BackgroundColor.GetComponent <Image>().color = memoryPhaseSymbols[x].BackgroundColor.Color; //Set the symbol memorySymbolsScript.Rune.GetComponent <Image>().sprite = memoryPhaseSymbols[i].Rune.sprite; //Mark this memory symbol as colour switched memorySymbolsScript.IsColourSwitched = true; isSelectable = false; } } } } } }
private void ColourSwitchSymbols() { //bool isSelectable = false; if (tmpColours.Count > 0) { tmpColours.Clear(); } if (tmpColoursShuffled.Count > 0) { tmpColoursShuffled.Clear(); } //List<Colour> tmpColours = backgroundColours; for (int x = 0; x < memoryPhaseSymbols.Count; x++) { tmpColours.Add(memoryPhaseSymbols[x].BackgroundColor.Color); } tmpColoursShuffled = new List <Color>(tmpColours); //tmpColoursShuffled.ShuffleList(); if (memoryPhaseSymbols.Count <= 2) { var tmp = tmpColoursShuffled[0]; tmpColoursShuffled[0] = tmpColoursShuffled[1]; tmpColoursShuffled[1] = tmp; } if (memoryPhaseSymbols.Count == 3) { var tmp = tmpColoursShuffled[0]; tmpColoursShuffled[0] = tmpColoursShuffled[2]; tmpColoursShuffled[2] = tmp; tmp = tmpColoursShuffled [1]; tmpColoursShuffled[1] = tmpColoursShuffled[2]; tmpColoursShuffled[2] = tmp; } if (memoryPhaseSymbols.Count == 4) { var tmp = tmpColoursShuffled[0]; tmpColoursShuffled[0] = tmpColoursShuffled[2]; tmpColoursShuffled[2] = tmp; tmp = tmpColoursShuffled[1]; tmpColoursShuffled[1] = tmpColoursShuffled[3]; tmpColoursShuffled[3] = tmp; } for (int i = 0; i < memoryPhaseSymbols.Count; i++) { //Find all symbols with matching colour List <GameObject> symbols = levelSymbols.FindAll(x => x.GetComponent <MemorySymbols>().BackgroundColor.GetComponent <Image>().color == tmpColoursShuffled[i]); for (int x = 0; x < symbols.Count; x++) { MemorySymbols memorySymbolScript = symbols[x].GetComponent <MemorySymbols>(); if (!memorySymbolScript.IsCorrect && !memorySymbolScript.IsColourSwitched) { //Set the symbol memorySymbolScript.Rune.GetComponent <Image>().sprite = memoryPhaseSymbols[i].Rune.sprite; memorySymbolScript.Letter.text = memoryPhaseSymbols[i].Letter; memorySymbolScript.IsColourSwitched = true; break; } } } }
private void ColourSwitchFiveSymbols() { int rand = 0; Color tmp = Color.clear; bool foundMatch = false; bool isSelectable = false; //List<Symbol> symbolsToSwitch = new List<Symbol>(); //Create new list of symbols from the current list of memoryphase symbols //My shitty way of doing a deep copy //Find a better way to do this !!!!!! for (int i = 0; i < memoryPhaseSymbols.Count; i++) { Symbol symbol = new Symbol(); symbol.Name = memoryPhaseSymbols[i].Name; symbol.BackgroundColor = memoryPhaseSymbols[i].BackgroundColor; symbol.Rune = memoryPhaseSymbols[i].Rune; symbolsToSwitch.Add(symbol); colourSwitchList.Add(memoryPhaseSymbols[i].BackgroundColor.Color); } //Load List of colours // for( int i = 0; i< symbolsToSwitch.Count; i++ ) // { // colourSwitchList.Add( symbolsToSwitch[i].BackgroundColor ); // } //Randomize Colours for the 5 symbols foreach (Symbol symbol in symbolsToSwitch) { //Remove the colour that matches the current symbol colour for (int x = 0; x < colourSwitchList.Count; x++) { if (colourSwitchList.Contains(symbol.BackgroundColor.Color)) { tmp = colourSwitchList[x]; colourSwitchList.RemoveAt(x); foundMatch = true; } } //Pick a colour from the remaining coloours rand = Random.Range(0, colourSwitchList.Count - 1); symbol.BackgroundColor.Color = colourSwitchList[rand]; //Remove the random Colour colourSwitchList.RemoveAt(rand); //Add the Colour that matched the current symbol back into the list if (foundMatch) { colourSwitchList.Add(tmp); foundMatch = false; } } for (int x = 0; x < symbolsToSwitch.Count; x++) { //Debug.Log( "Names : " + memoryPhaseSymbols[i].Name + " " + memoryPhaseSymbols[x].Name ); isSelectable = true; //Debug.Log( "No Match Found So im going to do my thing...." ); Debug.Log(symbolsToSwitch[x].Name + " " + symbolsToSwitch[x].BackgroundColor); while (isSelectable) { //Pick a random symbol from the list. GameObject selectedMemorySymbol = cloneSymbols[Random.Range(0, cloneSymbols.Count)]; //Debug.Log( "SELECTED SYMBOL : " + selectedMemorySymbol ); MemorySymbols memorySymbolsScript = selectedMemorySymbol.GetComponent <MemorySymbols>(); //If the random symbol isnt a winning symbol //and it hasnt already been colour switched if (!memorySymbolsScript.IsCorrect && !memorySymbolsScript.IsColourSwitched) { //Set the background colour memorySymbolsScript.BackgroundColor.GetComponent <Image>().color = symbolsToSwitch[x].BackgroundColor.Color; //Set the symbol memorySymbolsScript.Rune.GetComponent <Image>().sprite = symbolsToSwitch[x].Rune.sprite; //Mark this memory symbol as colour switched memorySymbolsScript.IsColourSwitched = true; isSelectable = false; } } } //Randomly insert the Symbols into the level. //ColourSwitchSymbols(); colourSwitchList.Clear(); symbolsToSwitch.Clear(); }