Transform CreateGridPoint(int x, int y, int z) { Transform point = Instantiate <Transform>(prefab); if (point.GetComponent(typeof(ReferencePointBehaviour)) != null) { //Debug.Log("J: "+x + y + z); //POSTMORTEM The Multidimensonal array conundrum, Last time I had a bug over here that the Nodes always get populated with a 2,2,2 index node, turns out that I was accessing prefab instead of point transform, simple error but big mistake ReferencePointBehaviour prefabComponent = point.GetComponent(typeof(ReferencePointBehaviour)) as ReferencePointBehaviour; prefabComponent.SetIndex(x, y, z); Nodes[x, y, z] = prefabComponent; //Debug.Log(Nodes[x,y,z].gameObject.name); } else { Debug.Log("PREFAB ATTACHED DOESN'T HAVE REFERENCEPOINTBEHAVIOUR ATTACHED!"); } if (parentTransform) { point.parent = parentTransform; } point.localPosition = GetCoordinates(x, y, z); if (changeColorBasedOnResolution) { point.GetComponent <SpriteRenderer>().color = new Color( (float)x / gridResolution, (float)y / gridResolution, (float)z / gridResolution ); } return(point); }
void ChangeTargetPoint(ReferencePointBehaviour point) { textMeshComponent.color = anomalyWarningStateColor; textComponent.text = "ANOMALY"; textComponent.color = anomalyWarningStateColorTEXT; if (point == null) { if (target) { target.GetComponent <RingPointManager>().stateChange -= AnomalyFufilled; target = null; } } else if (point != target && target != null) { //Deregister from previous target target.GetComponent <RingPointManager>().stateChange -= AnomalyFufilled; target = point; target.GetComponent <RingPointManager>().stateChange += AnomalyFufilled; } else if (target == null) { target = point; target.GetComponent <RingPointManager>().stateChange += AnomalyFufilled; } if (target) { active = true; } else { active = false; } }
public void SpawnRingDataAtPoint(RingData ringData, ReferencePointBehaviour point) { GameObject ring = Instantiate(RingPrefab); RingBehaviour ringComponent = ring.GetComponent <RingBehaviour>(); ringComponent.CurrentRingData = ringData; point.GetComponent <RingPointManager>().AcceptSpawnedRing(ringComponent); }
// ----------------------- SPAWNING IMPLEMENTATION --------------------------------------- // public void SpawnRandomRingAtPoint(ReferencePointBehaviour point) { // Currently nothing calls this but its good to have GameObject ring = Instantiate(RingPrefab); RingBehaviour ringComponent = ring.GetComponent <RingBehaviour>(); ringComponent.CurrentRingData = GenerateNewRingData(); point.GetComponent <RingPointManager>().AcceptSpawnedRing(ringComponent); }
public void CheckNeighboursForColor(List <ColorIndex> colorcheck, bool isDragDrop) { //Debug.Log("CHECKING FOR: "+colorcheck[0].ToString()+" "+colorcheck[1].ToString()+" "+colorcheck[2].ToString()); int neighbourHasColor = 0; bool MatchFound = false; for (int i = 0; i < colorcheck.Count; i++) { //Debug.Log("CURRENTLY CHECKING FOR: "+colorcheck[i]); //Debug.Log("CHECKING FOR: "+colorcheck[i].ToString()); if (colorcheck[i] != ColorIndex.NONE) { foreach (ReferencePointBehaviour neighbour in neighbours) { if (neighbour.GetComponent <RingPointManager>().HaveColor(colorcheck[i])) { neighbourHasColor++; Vector3 currentPosition = new Vector3(Xcoor, Ycoor, Zcoor); Vector3 neighbourPosition = new Vector3(neighbour.Xcoor, neighbour.Ycoor, neighbour.Zcoor); Vector3 backwardsVector = currentPosition - neighbourPosition; Vector3 forwardVector = backwardsVector * -1; // DO FORWARD CHECK (ASSUMING ITS THE END OF A 3 MATCH) ReferencePointBehaviour forwardNeighbour = TransformationGrid.instance.GetReferencePointByIndex(neighbourPosition + forwardVector); ReferencePointBehaviour backwardNeighbour = TransformationGrid.instance.GetReferencePointByIndex(currentPosition + backwardsVector); if (forwardNeighbour != null) { if (forwardNeighbour.GetComponent <RingPointManager>().HaveColor(colorcheck[i])) { // OKAY! I FOUND 3 IN A LINE, NOW ADD THE MATCH IN MATCHMANAGER //Debug.Log("WE FOUND MATCH"); MatchData foundMatch = new MatchData(); foundMatch.colorMark = colorcheck[i]; foundMatch.markedObjects = new List <RingBehaviour>(); foundMatch.markedObjects.Add(gameObject.GetComponent <RingPointManager>().Ring); //Debug.Log("ADDED OWN"); foundMatch.markedObjects.Add(neighbour.GetComponent <RingPointManager>().Ring); //Debug.Log("ADDED neighbour"); foundMatch.markedObjects.Add(forwardNeighbour.GetComponent <RingPointManager>().Ring); //Debug.Log("ADDED forwardneighbour"); MatchFound = true; MatchController.instance.StoreMatch(foundMatch); } } // DO BACKWARD CHECK (ASSUME ITS THE MIDDLE OF A 3 MATCH) if (backwardNeighbour != null) { if (backwardNeighbour.GetComponent <RingPointManager>().HaveColor(colorcheck[i])) { //Debug.Log("WE FOUND MATCH"); MatchData foundMatch = new MatchData(); foundMatch.colorMark = colorcheck[i]; foundMatch.markedObjects = new List <RingBehaviour>(); foundMatch.markedObjects.Add(gameObject.GetComponent <RingPointManager>().Ring); //Debug.Log("ADDED OWN"); foundMatch.markedObjects.Add(neighbour.GetComponent <RingPointManager>().Ring); //Debug.Log("ADDED neighbour"); foundMatch.markedObjects.Add(backwardNeighbour.GetComponent <RingPointManager>().Ring); //Debug.Log("ADDED forwardneighbour"); MatchFound = true; MatchController.instance.StoreMatch(foundMatch); } } } } } } if (!MatchFound) { // NO MATCH FOUND, RESET THE COMBO :< if (isDragDrop) { GameController.instance.onNoMatchEvent(); ScoreController.instance.ResetCombo(); } } else { // CHECKS HAS BEEN DONE - CLEAR ALL MARKED RINGS OFF GAME CONTROLLERS MatchController.instance.ClearPendingMatches(); } //Debug.Log("NEIGHBOURS HAS " + neighbourHasColor + " SIMILAR COLORS TIERS"); }
private void AddNeighbour(ReferencePointBehaviour neighbour) { neighbours.Add(neighbour); }