void MakeInstance() { if (instance == null) { instance = this; } }
private void InstantiateRings() { for (int i = 0; i < totalRings; i++) { float width = Random.Range(-volumeDimensions.x / 2, volumeDimensions.x / 2); width = width + minDistance; float height = Random.Range(0, volumeDimensions.y); height = height + heightOffset; float depth = Random.Range(0, volumeDimensions.z); depth = depth + minDistance; cameraPos = Camera.main.transform.position; Vector3 position = new Vector3(cameraPos.x + width, cameraPos.y + height, cameraPos.z + depth); GameObject newRingGO = Instantiate(ringPrefab, position, Quaternion.identity, this.transform); RingController newRing = newRingGO.GetComponent <RingController>(); newRing.Index = i; Debug.Log("New ring index: " + newRing.Index); rings.Add(newRing); ringCount++; if (i < panelCount) { GameObject newPanelGO = Instantiate(ringPanelPrefab, ringPanelParent); RingDistancePanelController newPanel = newPanelGO.GetComponent <RingDistancePanelController>(); newPanel.Index = i; Debug.Log("New ring panel index: " + newPanel.Index); newPanel.SetLabel("RING " + (i + 1).ToString()); panels.Add(newPanel); } } }
private void HandleRingDestroyed(params object[] args) { RingController ring = (RingController)args[0]; int index = ring.Index; Debug.Log(index); rings.Remove(ring); ringPanelParent.GetChild(index).gameObject.SetActive(false); ringCount--; if (ringCount <= 0) { DestroyRingLabels(); InstantiateRings(); } }
void showTitlePopup() { if ((focus == true) && (popupOn == false)) // && (Input.GetButton("Fire3"))) { { if (popupStartTime == 0) { popupStartTime = Time.time; } else if ((Time.time - popupStartTime) > popupWaitTime) { popupOn = true; popdownStartTime = 0; RingController parentRing = transform.parent.parent.parent.gameObject.GetComponent <RingController>(); parentRing.showPopup(objectName + " (" + objectType + ")", fromPoint, hitPoint); } } else if ((focus == false) && (popupOn == true)) { if (popdownStartTime == 0) { popdownStartTime = Time.time; } else if ((Time.time - popdownStartTime) > popupWaitTime) { RingController parentRing = transform.parent.parent.parent.gameObject.GetComponent <RingController>(); parentRing.hidePopup(); popupOn = false; popupStartTime = 0; } } else if ((focus == false) && (popupOn == false) && (popupStartTime > 0)) { popupStartTime = 0; } else if ((focus == true) && (popupOn == true) && (popdownStartTime > 0)) { popdownStartTime = 0; } }
int ComboLine(int firstDot, int secondDot, int thirdDot) { int combo = 0; bool hasDestroy = false; //Check first dot for (int i = 0; i < dots[firstDot].transform.childCount; i++) { int colorIndexOfChild = dots[firstDot].transform.GetChild(i).GetComponent <RingController>().colorIndex; //Check second dot for (int j = 0; j < dots[secondDot].transform.childCount; j++) { RingController secondDotRingControlller = dots[secondDot].transform.GetChild(j).GetComponent <RingController>(); if (secondDotRingControlller.colorIndex == colorIndexOfChild) { //Check third dot for (int k = 0; k < dots[thirdDot].transform.childCount; k++) { RingController thirdDotRingController = dots[thirdDot].transform.GetChild(k).GetComponent <RingController>(); if (thirdDotRingController.colorIndex == colorIndexOfChild) { dots[thirdDot].transform.GetChild(k).GetComponent <RingController>().destroyed = true; dots[secondDot].transform.GetChild(j).GetComponent <RingController>().destroyed = true; dots[firstDot].transform.GetChild(i).GetComponent <RingController>().destroyed = true; AddForListLine(firstDot, secondDot, colorIndexOfChild); hasDestroy = true; } } } } } if (hasDestroy) { combo = 1; } return(combo); }
void Update() { // Detect death by ring RingController ringController = FindObjectOfType <RingController>(); if (ringController != null && ringController.OutsideRange(HeadPosition.position)) { Health = 0; return; } // Regen health if (m_Health < MaxHealth) { m_RegenTimer -= Time.deltaTime; if (m_RegenTimer < 0.0f) { Health++; m_RegenTimer = RegenRate; } } DetectJump(); }
// creates a ring as needed for an opportunity private static void createRing(Opportunity opp, int i, Transform parentTransform, Transform Ring, Transform Block, Transform blockBox) { //Vector3 resetRotation = parentTransform.rotation.eulerAngles; //resetRotation.x = 90.0f; Transform currentRing = (Transform)Instantiate(Ring, new Vector3(0, 0, 0), Quaternion.identity); currentRing.SetParent(GameObject.Find("Rings").transform); currentRing.localScale = new Vector3(5, 5, 5); //currentRing.rotation = Quaternion.Euler(resetRotation); currentRing.localPosition = new Vector3(0, 0, i); //get an instance of the component. Transform ringInstance = currentRing.GetComponent <Transform>(); RingController ringController = ringInstance.GetComponent <RingController>(); ringController.speed = opp.urgent; ringController.vertOrder = (float)i + 1f; ringController.transform.position = currentRing.transform.position; ringController.originPosition = new Vector3(0, 0, i); ringController.shiftedPosition = new Vector3(0, 0, i); ringController.zone = i; // set the title of the current opportunity // used by the opportuntiy popup. ringController.titleTextValue = opp.oppName; // get reference to the subRingDisk controller // as the subObjects are built and rendered to the enviroment - // construct the subRingDisk object // This is used for rotation management based on priorit Transform subRingDisk = ringInstance.FindChild("subRingDisk"); subRingDisk.SetParent(ringInstance); SubRingDiskController subRingDiskCtrl = subRingDisk.GetComponent <SubRingDiskController>(); //subRingDisk.RotateAround(subRingDisk.position,Vector3.up, 180f); // create Account object and block if (opp.account != null) { Vector3 setRotation = parentTransform.rotation.eulerAngles; //setRotation.x = -90.0f; setRotation.y = 0.0f; Transform currentBlockBox = (Transform)Instantiate(blockBox, new Vector3(0, 0, 0), Quaternion.identity); currentBlockBox.SetParent(subRingDisk); currentBlockBox.localScale = new Vector3(1f, 1f, 1f); currentBlockBox.rotation = Quaternion.Euler(setRotation); currentBlockBox.localPosition = new Vector3(0f, 0f, 0f); SubObjectUtil.createAccountBlock(opp.account, 0, currentBlockBox, Block, subRingDiskCtrl); subRingDiskCtrl.accounts.Add(opp.account); } // create Opportunity Products objects and blocks if (opp.oppProducts != null) { int o = 0; Vector3 setRotation = parentTransform.rotation.eulerAngles; //setRotation.x = -90.0f; setRotation.y = 45.0f; Transform currentBlockBox = (Transform)Instantiate(blockBox, new Vector3(0, 0, 0), Quaternion.identity); currentBlockBox.SetParent(subRingDisk); currentBlockBox.localScale = new Vector3(1f, 1f, 1f); currentBlockBox.rotation = Quaternion.Euler(setRotation); currentBlockBox.localPosition = new Vector3(0f, 0f, 0f); foreach (OpportunityProduct oppProduct in opp.oppProducts) { SubObjectUtil.createOppProductBlock(oppProduct, o, currentBlockBox, Block, subRingDiskCtrl); subRingDiskCtrl.opportuniutyProducts.Add(oppProduct); o++; } } // create campaign object and block if (opp.campaign != null) { Vector3 setRotation = parentTransform.rotation.eulerAngles; //setRotation.x = -90.0f; setRotation.y = 180f; Transform currentBlockBox = (Transform)Instantiate(blockBox, new Vector3(0, 0, 0), Quaternion.identity); currentBlockBox.SetParent(subRingDisk); currentBlockBox.localScale = new Vector3(1f, 1f, 1f); currentBlockBox.rotation = Quaternion.Euler(setRotation); currentBlockBox.localPosition = new Vector3(0f, 0f, 0f); SubObjectUtil.createCampaignBlock(opp.campaign, 0, currentBlockBox, Block, subRingDiskCtrl); subRingDiskCtrl.campaigns.Add(opp.campaign); } if (opp.contract != null) { Vector3 setRotation = parentTransform.rotation.eulerAngles; //setRotation.x = -90.0f; setRotation.y = 270f; Transform currentBlockBox = (Transform)Instantiate(blockBox, new Vector3(0, 0, 0), Quaternion.identity); currentBlockBox.SetParent(subRingDisk); currentBlockBox.localScale = new Vector3(1f, 1f, 1f); currentBlockBox.rotation = Quaternion.Euler(setRotation); currentBlockBox.localPosition = new Vector3(0f, 0f, 0f); SubObjectUtil.createContractBlock(opp.contract, 0, currentBlockBox, Block, subRingDiskCtrl); subRingDiskCtrl.contracts.Add(opp.contract); } //TODO: figure out order query issue. // SubObjectUtil.createOrderBlock(4,currentRing,Block); //TODO: Write a query for this Events // SubObjectUtil.createEventBlock(4,currentRing,Block); //TODO: Write a query for Tasks // SubObjectUtil.createTaskBlock(7,currentRing,Block); //TODO: Write a query for Pricebooks // SubObjectUtil.createPriceBookBlock(1,currentRing,Block); }
void Start() { ringController = GetComponentInParent<RingController>(); lineSegmentPool = ringController.lineSegmentPool; }
//Check to allow drop ring to the dot or not bool AllowDrop(GameObject theNearestDot) { DotController dotController = theNearestDot.GetComponent <DotController>(); if (dotController.isFullRing) //Has 3 rings { return(false); } //--------------------Has 2 rings else if (dotController.hasBigRing && dotController.hasNormalRing && !dotController.hasSmallRing) //Has big and normal ring { //Loop all child of random point and check, if it has big ring or normal ring -> return false for (int i = 0; i < randomPoint.transform.childCount; i++) { RingController ringController = randomPoint.transform.GetChild(i).GetComponent <RingController>(); if (ringController.ringType == RingType.BIG_RING || ringController.ringType == RingType.NORMAL_RING) { return(false); } } return(true); } else if (dotController.hasBigRing && dotController.hasSmallRing && !dotController.hasNormalRing) //Has big and small ring { //Loop all child of random point and check, if it has big ring or small ring -> return false for (int i = 0; i < randomPoint.transform.childCount; i++) { RingController ringController = randomPoint.transform.GetChild(i).GetComponent <RingController>(); if (ringController.ringType == RingType.BIG_RING || ringController.ringType == RingType.SMALL_RING) { return(false); } } return(true); } else if (dotController.hasNormalRing && dotController.hasSmallRing && !dotController.hasBigRing) //Has normal and small ring { //Loop all child of random point and check, if it has normal ring or small ring -> return false for (int i = 0; i < randomPoint.transform.childCount; i++) { RingController ringController = randomPoint.transform.GetChild(i).GetComponent <RingController>(); if (ringController.ringType == RingType.NORMAL_RING || ringController.ringType == RingType.SMALL_RING) { return(false); } } return(true); } //-------------------Has 1 ring else if (dotController.hasBigRing && !dotController.hasNormalRing && !dotController.hasSmallRing) //Has big ring { //Loop all child of random point and check, if it has big ring -> return false for (int i = 0; i < randomPoint.transform.childCount; i++) { RingController ringController = randomPoint.transform.GetChild(i).GetComponent <RingController>(); if (ringController.ringType == RingType.BIG_RING) { return(false); } } return(true); } else if (dotController.hasNormalRing && !dotController.hasBigRing && !dotController.hasSmallRing) //Has normal ring { //Loop all child of random point and check, if it has normal ring -> return false for (int i = 0; i < randomPoint.transform.childCount; i++) { RingController ringController = randomPoint.transform.GetChild(i).GetComponent <RingController>(); if (ringController.ringType == RingType.NORMAL_RING) { return(false); } } return(true); } else if (dotController.hasSmallRing && !dotController.hasBigRing && !dotController.hasNormalRing) //Has small ring { //Loop all child of random point and check, if it has small ring -> return false for (int i = 0; i < randomPoint.transform.childCount; i++) { RingController ringController = randomPoint.transform.GetChild(i).GetComponent <RingController>(); if (ringController.ringType == RingType.SMALL_RING) { return(false); } } return(true); } else //Has no ring { return(true); } }
// Update is called once per frame public void CheckRing() { hasBigRing = false; hasNormalRing = false; hasSmallRing = false; isSameColor = false; isFullRing = false; isEmptyRing = false; if (transform.childCount == 1) //Has one ring { RingController ringChildController = transform.GetChild(0).GetComponent <RingController>(); if (ringChildController.ringType == RingType.BIG_RING) //Is big ring { hasBigRing = true; } else if (ringChildController.ringType == RingType.NORMAL_RING) //Is normal ring { hasNormalRing = true; } else //Is small ring { hasSmallRing = true; } } else if (transform.childCount == 2) //Has two rings { for (int i = 0; i < transform.childCount; i++) { if (transform.GetChild(i).GetComponent <RingController>().ringType == RingType.BIG_RING) { hasBigRing = true; } else if (transform.GetChild(i).GetComponent <RingController>().ringType == RingType.NORMAL_RING) { hasNormalRing = true; } else { hasSmallRing = true; } } } else if (transform.childCount == 3) //Has three rings { RingController ring_0Controller = transform.GetChild(0).GetComponent <RingController>(); RingController ring_1Controller = transform.GetChild(1).GetComponent <RingController>(); RingController ring_2Controller = transform.GetChild(2).GetComponent <RingController>(); if (ring_0Controller.colorIndex == ring_1Controller.colorIndex && ring_1Controller.colorIndex == ring_2Controller.colorIndex) { isSameColor = true; } hasBigRing = true; hasNormalRing = true; hasSmallRing = true; isFullRing = true; } else { isEmptyRing = true; } }