/// <summary> /// Fades the out backlay on destroy. /// </summary> public void FadeOutBacklayOnDestroy() { if (doFadeOutBacklayOnDestroy) { BackLay.gameObject.ValueTo(EGTween.Hash("From", 0.5F, "To", 0F, "Time", TransitionDuration, "onupdate", "OnOpacityUpdate", "onupdatetarget", gameObject)); } }
public void OnWindowRemove() { if ((doAnimateOnDestroy && (WindowContent != null))) { WindowContent.MoveTo(EGTween.Hash("x", 600F, "easeType", EGTween.EaseType.easeInBack, "time", TransitionDuration, "islocal", true, "ignoretimescale", true)); if (doFadeOutBacklayOnDestroy) { BackLay.gameObject.ValueTo(EGTween.Hash("From", TransitionDuration, "To", 0F, "Time", TransitionDuration, "onupdate", "OnOpacityUpdate", "ignoretimescale", true)); } Invoke("OnRemoveTransitionComplete", 0.5F); } else { if (doFadeOutBacklayOnDestroy) { BackLay.gameObject.ValueTo(EGTween.Hash("From", TransitionDuration, "To", 0F, "Time", TransitionDuration, "onupdate", "OnOpacityUpdate")); Invoke("OnRemoveTransitionComplete", 0.5F); } else { OnRemoveTransitionComplete(); } } }
public void FadeInBackLayOnLoad() { if (doFadeInBackLayOnLoad) { BackLay.gameObject.ValueTo(EGTween.Hash("From", 0F, "To", 0.5F, "Time", TransitionDuration, "onupdate", "OnOpacityUpdate")); } }
public void AnimateWindowOnLoad() { if (doAnimateOnLoad && (WindowContent != null)) { WindowContent.MoveFrom(EGTween.Hash("x", 600, "easeType", EGTween.EaseType.easeOutBack, "time", TransitionDuration, "islocal", true)); } FadeInBackLayOnLoad(); }
public void AnimateWindowOnDestroy() { if (doAnimateOnDestroy && (WindowContent != null)) { WindowContent.MoveTo(EGTween.Hash("x", -600F, "easeType", EGTween.EaseType.easeInBack, "time", TransitionDuration, "islocal", true)); } FadeOutBacklayOnDestroy(); }
/// <summary> /// Raises the end drag event. /// </summary> /// <param name="eventData">Event data.</param> public virtual void OnEndDrag(PointerEventData eventData) { Vector2 points = btnToggleGraphics.rectTransform.anchoredPosition; points [0] = Mathf.Clamp(points.x, -(Mathf.Abs(btnToggleGraphicsPosition.x)), (Mathf.Abs(btnToggleGraphicsPosition.x))); btnToggleGraphics.rectTransform.anchoredPosition = points; bool toggleStatus = (points.x < 0F) ? false : true; EGTween.MoveTo(btnToggleGraphics.gameObject, EGTween.Hash("x", (toggleStatus ? (Mathf.Abs(btnToggleGraphicsPosition.x)) : -(Mathf.Abs(btnToggleGraphicsPosition.x))), "isLocal", true, "time", 0.5F, "easeType", EGTween.EaseType.easeOutExpo)); OnToggleStatusChanged(toggleStatus); }
IEnumerator LoadGameOver(string reason) { txtGameOverReason.text = reason.ToString(); txtGameOverReason.transform.parent.gameObject.ScaleTo(EGTween.Hash("X", 1, "Y", 1, "Z", 1, "Time", 0.7F)); yield return(new WaitForSeconds(2F)); txtGameOverReason.transform.parent.gameObject.ScaleTo(EGTween.Hash("X", 0, "Y", 0, "Z", 0, "Time", 0.7F)); yield return(new WaitForSeconds(0.4F)); GameController.instance.SpawnUIScreen("GameOver", true).GetComponent <GameOver> ().setScore(GamePlayMode, Score, BestScore, reason); AudioManager.instance.PlayOneShotClip(SFX_GameOver); }
/// <summary> /// This will execute on the time of screen spawn. /// </summary> public void OnWindowAdded() { if (doAnimateOnLoad && (WindowContent != null)) { WindowContent.MoveFrom(EGTween.Hash("x", -600, "easeType", EGTween.EaseType.easeOutBack, "time", TransitionDuration, "islocal", true, "ignoretimescale", true)); } if (doFadeInBackLayOnLoad) { BackLay.gameObject.ValueTo(EGTween.Hash("From", 0, "To", 0.7F, "Time", TransitionDuration, "onupdate", "OnOpacityUpdate", "onupdatetarget", gameObject, "ignoretimescale", true)); } }
/// <summary> /// Sets the timer For Bar Progress /// this method will set and reset the timer on clearing row and column /// </summary> /// <param name="timerToIncrease">Timer to increase.</param> public void SetTimer(int timerToIncrease = 0) { if (GamePlayMode == GameMode.timer) { EGTween.Stop(gameObject); TimerValue = TimerValue + timerToIncrease; TimerValue = Mathf.Clamp(TimerValue, 0, TotalTimerValue); float currentBarProgress = ((float)TimerValue / (float)TotalTimerValue) * 100F; float barFillValue = (555.0F / (100 / currentBarProgress)); Timer.sizeDelta = new Vector2(barFillValue, Timer.sizeDelta.y); EGTween.ValueTo(gameObject, EGTween.Hash("from", (float)Timer.sizeDelta.x, "to", 0.0f, "time", TimerValue, "onUpdate", "BarProgress", "onComplete", "OnBarCompelete", "onCompleteTarget", gameObject)); } }
/// <summary> /// Starts the game. /// </summary> public void startGame() { int placedBlocks = 0; if (GameDataManager.instance.isHelpRunning == 0) { //OnPlacingBlock (); // string suggestedblock1 = GameController.instance.GameDoc.Root.Element("suggestedObject1").Attribute("objectName").Value; // string suggestedblock2 = GameController.instance.GameDoc.Root.Element("suggestedObject2").Attribute("objectName").Value; // string suggestedblock3 = GameController.instance.GameDoc.Root.Element("suggestedObject3").Attribute("objectName").Value; // // Debug.Log (suggestedblock1 + " : " + suggestedblock2 + " : " + suggestedblock3); for (int i = 0; i < 3; i++) { GameObject obj = null; string ObjectName = GameDataManager.instance.GameDoc.Root.Element("suggestedObject" + (i + 1)).Attribute("objectName").Value; ObjectName = ObjectName.Replace("(Clone)", ""); int index = blockList.FindIndex(o => o.name == ObjectName); if (index != -1) { //index = ProbabilityPool [UnityEngine.Random.Range (0, ProbabilityPool.Count)]; obj = (GameObject)Instantiate(blockList [index].gameObject); obj.transform.SetParent(blockContainer.GetChild(i).transform); obj.GetComponent <RectTransform> ().anchoredPosition3D = Vector3.zero; obj.transform.localScale = new Vector3(0.6f, 0.6f, 1); obj.gameObject.SetActive(true); placedBlocks++; } } EGTween.MoveFrom(blockContainer.gameObject, EGTween.Hash("isLocal", true, "x", 50, "time", blockTransitionTime)); } if (placedBlocks == 0) { OnPlacingBlock(); StartCoroutine("UpdateBlocksInCurrentMoveData"); } }
void HandAnimation() { if (HelpContent.FindChild("txt-help1").gameObject.activeSelf) { targetPosition = BlockManager.instance.BlockList.Find(o => o.rowId == 2 && o.columnId == 1).block.transform.position; blockPosition = blockContainer.GetChild(0).GetChild(0).position; } else { targetPosition = BlockManager.instance.BlockList.Find(o => o.rowId == 1 && o.columnId == 2).block.transform.position; blockPosition = blockContainer.GetChild(2).GetChild(0).position; } blockPosition.z = 0; targetPosition.z = 0; handImage.transform.position = blockPosition; handImage.gameObject.SetActive(true); EGTween.MoveTo(handImage.gameObject, EGTween.Hash("Delay", 1F, "x", targetPosition.x, "y", targetPosition.y, "time", 2.5f, "easeType", EGTween.EaseType.linear)); Invoke("RepeatHandAnimation", 4.5f); }
public void SpawnSuggetedBlocks() { for (int i = 0; i < 3; i++) { if (blockContainer.GetChild(i).childCount > 0) { Destroy(blockContainer.GetChild(i).GetChild(0).gameObject); } } int placedBlocks = 0; XDocument doc = XDocument.Parse(GameDataManager.instance.lastMoveData); for (int i = 0; i < 3; i++) { GameObject obj = null; string ObjectName = doc.Root.Element("suggestedObject" + (i + 1)).Attribute("objectName").Value; ObjectName = ObjectName.Replace("(Clone)", ""); int index = blockList.FindIndex(o => o.name == ObjectName); if (index != -1) { //index = ProbabilityPool [UnityEngine.Random.Range (0, ProbabilityPool.Count)]; obj = (GameObject)Instantiate(blockList [index].gameObject); obj.transform.SetParent(blockContainer.GetChild(i).transform); obj.GetComponent <RectTransform> ().anchoredPosition3D = Vector3.zero; obj.transform.localScale = new Vector3(0.6f, 0.6f, 1); obj.gameObject.SetActive(true); placedBlocks++; } } EGTween.MoveFrom(blockContainer.gameObject, EGTween.Hash("isLocal", true, "x", 50, "time", blockTransitionTime)); }
public static void RotateBy(this GameObject target, Vector3 amount, float time) { EGTween.RotateBy(target, EGTween.Hash("amount", amount, "time", time)); }
/// <summary> /// Starts the rotation. /// </summary> public void StartRotation() { EGTween.RotateBy(gameObject, EGTween.Hash("z", -1.0F, "speed", (rotateSpeed), "easeType", EGTween.EaseType.linear, "loopType", EGTween.LoopType.loop)); }
void RepeatHandAnimation() { handImage.transform.position = blockPosition; EGTween.MoveTo(handImage.gameObject, EGTween.Hash("Delay", 0.5F, "x", targetPosition.x, "y", targetPosition.y, "time", 2.5f, "easeType", EGTween.EaseType.linear)); Invoke("RepeatHandAnimation", 4.0f); }
/// <summary> /// Swaps the object. /// </summary> /// <param name="parentBlock">Parent block.</param> /// <param name="blockToTansit">Block to tansit.</param> public void swapObject(Transform parentBlock, Transform blockToTansit) { blockToTansit.SetParent(parentBlock); EGTween.MoveTo(blockToTansit.gameObject, EGTween.Hash("isLocal", true, "x", 0, "time", blockTransitionTime)); }
public static void RotateFrom(this GameObject target, Vector3 rotation, float time) { EGTween.RotateFrom(target, EGTween.Hash("rotation", rotation, "time", time)); }
public static void ScaleFrom(this GameObject target, Vector3 scale, float time) { EGTween.ScaleFrom(target, EGTween.Hash("scale", scale, "time", time)); }
public static void MoveFrom(this GameObject target, Vector3 position, float time) { EGTween.MoveFrom(target, EGTween.Hash("position", position, "time", time)); }
/// <summary> /// Raises the placing block event. /// </summary> public void OnPlacingBlock() { int blockRemained = 0; foreach (Transform t in blockContainer) { if (t.childCount > 0) { blockRemained++; } } // if (blockRemained == 2) // { // for (int i = 1; i <= 3; i++) { // if (blockContainer.GetChild (i - 1).childCount <= 0) { // if (i == 1) { // if (blockContainer.GetChild (i).childCount > 0) { // swapObject (blockContainer.GetChild (i - 1), blockContainer.GetChild (i).GetChild (0)); // swapObject (blockContainer.GetChild (i), blockContainer.GetChild (i + 1).GetChild (0)); // } // } else if (i == 2) { // if (blockContainer.GetChild (i).childCount >= 0) { // swapObject (blockContainer.GetChild (i - 1), blockContainer.GetChild (i).GetChild (0)); // } // } else { // GameObject obj = (GameObject)Instantiate (blockList [ProbabilityPool [UnityEngine.Random.Range (0, ProbabilityPool.Count)]].gameObject); // obj.transform.SetParent (blockContainer.GetChild (i - 1).transform); // obj.GetComponent<RectTransform> ().anchoredPosition3D = Vector3.zero; // obj.transform.localScale = new Vector3 (0.6f, 0.6f, 1); // obj.gameObject.SetActive (true); // EGTween.MoveFrom (obj, EGTween.Hash ("isLocal", true, "x", 50, "time", blockTransitionTime)); // } // } // } // } // else if (blockRemained == 0) // { // for (int i = 0; i < 3; i++) { // GameObject obj = null; // if (GameController.instance.PlayFromLastStatus) { // string ObjectName = GameController.instance.GameDoc.Root.Element("suggestedObject"+(i+1)).Attribute("objectName").Value; // ObjectName = ObjectName.Replace ("(Clone)", ""); // int index = blockList.FindIndex (o => o.name == ObjectName); // if (index == -1) { // index = ProbabilityPool [UnityEngine.Random.Range (0, ProbabilityPool.Count)]; // } // obj = (GameObject)Instantiate (blockList [index].gameObject); // } // else // { // obj = (GameObject)Instantiate (blockList [ProbabilityPool [UnityEngine.Random.Range (0, ProbabilityPool.Count)]].gameObject); // } // // obj.transform.SetParent (blockContainer.GetChild (i).transform); // obj.GetComponent<RectTransform> ().anchoredPosition3D = Vector3.zero; // obj.transform.localScale = new Vector3 (0.6f, 0.6f, 1); // obj.gameObject.SetActive (true); // } // EGTween.MoveFrom (blockContainer.gameObject, EGTween.Hash ("isLocal", true, "x", 50, "time", blockTransitionTime)); // } // // if (GamePlay.instance != null && GameController.instance.GameDoc != null) { // GameController.instance.GameDoc.Root.Element ("suggestedObject1").Attribute ("objectName").SetValue (blockContainer.GetChild (0).GetChild(0).transform.name); // GameController.instance.GameDoc.Root.Element ("suggestedObject2").Attribute ("objectName").SetValue (blockContainer.GetChild (1).GetChild(0).transform.name); // GameController.instance.GameDoc.Root.Element ("suggestedObject3").Attribute ("objectName").SetValue (blockContainer.GetChild (2).GetChild(0).transform.name); // } // if (blockRemained == 0) // { // for (int i = 0; i < 3; i++) // { // GameObject obj = null; // if (GameDataManager.instance.PlayFromLastStatus) { // string ObjectName = GameDataManager.instance.GameDoc.Root.Element("suggestedObject"+(i+1)).Attribute("objectName").Value; // ObjectName = ObjectName.Replace ("(Clone)", ""); // int index = blockList.FindIndex (o => o.name == ObjectName); // if (index == -1) { // index = ProbabilityPool [UnityEngine.Random.Range (0, ProbabilityPool.Count)]; // } // obj = (GameObject)Instantiate (blockList [index].gameObject); // } // else // { // obj = (GameObject)Instantiate (blockList [ProbabilityPool [UnityEngine.Random.Range (0, ProbabilityPool.Count)]].gameObject); // } // // obj.transform.SetParent (blockContainer.GetChild (i).transform); // obj.GetComponent<RectTransform> ().anchoredPosition3D = Vector3.zero; // obj.transform.localScale = new Vector3 (0.6f, 0.6f, 1); // obj.gameObject.SetActive (true); // } // EGTween.MoveFrom (blockContainer.gameObject, EGTween.Hash ("isLocal", true, "x", 50, "time", blockTransitionTime)); // } string block1Name = ""; string block2Name = ""; string block3Name = ""; if (blockContainer.GetChild(0).childCount > 0) { block1Name = blockContainer.GetChild(0).GetChild(0).name; } if (GamePlay.instance.upcomingBlockFillMode == UpcomingBlockFillMode.AddNewOnAllEmpty) { if (blockRemained == 0) { for (int i = 0; i < 3; i++) { GameObject obj = null; if (GameDataManager.instance.PlayFromLastStatus) { string ObjectName = GameDataManager.instance.GameDoc.Root.Element("suggestedObject" + (i + 1)).Attribute("objectName").Value; ObjectName = ObjectName.Replace("(Clone)", ""); int index = blockList.FindIndex(o => o.name == ObjectName); if (index == -1) { index = ProbabilityPool [UnityEngine.Random.Range(0, ProbabilityPool.Count)]; } obj = (GameObject)Instantiate(blockList [index].gameObject); } else { obj = (GameObject)Instantiate(blockList [ProbabilityPool [UnityEngine.Random.Range(0, ProbabilityPool.Count)]].gameObject); } obj.transform.SetParent(blockContainer.GetChild(i).transform); obj.GetComponent <RectTransform> ().anchoredPosition3D = Vector3.zero; obj.transform.localScale = new Vector3(0.6f, 0.6f, 1); obj.gameObject.SetActive(true); } EGTween.MoveFrom(blockContainer.gameObject, EGTween.Hash("isLocal", true, "x", 50, "time", blockTransitionTime)); } } else { if (blockRemained == 2) { for (int i = 1; i <= 3; i++) { if (blockContainer.GetChild(i - 1).childCount <= 0) { if (i == 1) { if (blockContainer.GetChild(i).childCount > 0) { swapObject(blockContainer.GetChild(i - 1), blockContainer.GetChild(i).GetChild(0)); swapObject(blockContainer.GetChild(i), blockContainer.GetChild(i + 1).GetChild(0)); } } else if (i == 2) { if (blockContainer.GetChild(i).childCount >= 0) { swapObject(blockContainer.GetChild(i - 1), blockContainer.GetChild(i).GetChild(0)); } } else { GameObject obj = (GameObject)Instantiate(blockList [ProbabilityPool [UnityEngine.Random.Range(0, ProbabilityPool.Count)]].gameObject); obj.transform.SetParent(blockContainer.GetChild(i - 1).transform); obj.GetComponent <RectTransform> ().anchoredPosition3D = Vector3.zero; obj.transform.localScale = new Vector3(0.6f, 0.6f, 1); obj.gameObject.SetActive(true); EGTween.MoveFrom(obj, EGTween.Hash("isLocal", true, "x", 50, "time", blockTransitionTime)); } } } } else if (blockRemained == 0) { for (int i = 0; i < 3; i++) { GameObject obj = null; if (GameDataManager.instance.PlayFromLastStatus) { string ObjectName = GameDataManager.instance.GameDoc.Root.Element("suggestedObject" + (i + 1)).Attribute("objectName").Value; ObjectName = ObjectName.Replace("(Clone)", ""); int index = blockList.FindIndex(o => o.name == ObjectName); if (index == -1) { index = ProbabilityPool [UnityEngine.Random.Range(0, ProbabilityPool.Count)]; } obj = (GameObject)Instantiate(blockList [index].gameObject); } else { obj = (GameObject)Instantiate(blockList [ProbabilityPool [UnityEngine.Random.Range(0, ProbabilityPool.Count)]].gameObject); } obj.transform.SetParent(blockContainer.GetChild(i).transform); obj.GetComponent <RectTransform> ().anchoredPosition3D = Vector3.zero; obj.transform.localScale = new Vector3(0.6f, 0.6f, 1); obj.gameObject.SetActive(true); } EGTween.MoveFrom(blockContainer.gameObject, EGTween.Hash("isLocal", true, "x", 50, "time", blockTransitionTime)); } } if (blockContainer.GetChild(1).childCount > 0) { block2Name = blockContainer.GetChild(1).GetChild(0).name; } if (blockContainer.GetChild(2).childCount > 0) { block3Name = blockContainer.GetChild(2).GetChild(0).name; } GameDataManager.instance.GameDoc.Root.Element("suggestedObject1").Attribute("objectName").SetValue(block1Name); GameDataManager.instance.GameDoc.Root.Element("suggestedObject2").Attribute("objectName").SetValue(block2Name); GameDataManager.instance.GameDoc.Root.Element("suggestedObject3").Attribute("objectName").SetValue(block3Name); // Debug.Log ("This is called.."); // // GameController.instance.currentMoveData = GameController.instance.GameDoc.ToString (); }
public void PlaceObject() { int blockRemained = 0; List <Transform> blockList = BlockTrayManager.instance.blockList; foreach (Transform t in blockContainer) { if (t.childCount > 0) { blockRemained++; } } if (blockRemained == 2) { for (int i = 1; i <= 3; i++) { if (blockContainer.GetChild(i - 1).childCount <= 0) { if (i == 1) { if (blockContainer.GetChild(i).childCount > 0) { swapObject(blockContainer.GetChild(i - 1), blockContainer.GetChild(i).GetChild(0)); swapObject(blockContainer.GetChild(i), blockContainer.GetChild(i + 1).GetChild(0)); } } else if (i == 2) { if (blockContainer.GetChild(i).childCount >= 0) { swapObject(blockContainer.GetChild(i - 1), blockContainer.GetChild(i).GetChild(0)); } } else { GameObject obj = (GameObject)Instantiate(blockList [2].gameObject); obj.transform.SetParent(blockContainer.GetChild(i - 1).transform); obj.GetComponent <RectTransform> ().anchoredPosition3D = Vector3.zero; obj.transform.localScale = new Vector3(0.6f, 0.6f, 1); obj.gameObject.SetActive(true); EGTween.MoveFrom(obj, EGTween.Hash("isLocal", true, "x", 50, "time", blockTransitionTime)); } } } blockContainer.GetChild(1).GetComponent <Image> ().raycastTarget = true; blockContainer.GetChild(helpMode == "Horizontal" ? 2 : 0).GetComponent <Image> ().raycastTarget = true; } else if (blockRemained == 0) { blockContainer.GetChild(1).GetComponent <Image> ().raycastTarget = false; blockContainer.GetChild(helpMode == "Horizontal" ? 2 : 0).GetComponent <Image> ().raycastTarget = false; for (int i = 0; i < 3; i++) { GameObject obj = (GameObject)Instantiate(blockList [helpMode == "Horizontal" ? i:i + 2].gameObject); obj.transform.SetParent(blockContainer.GetChild(i).transform); obj.GetComponent <RectTransform> ().anchoredPosition3D = Vector3.zero; obj.transform.localScale = new Vector3(0.6f, 0.6f, 1); obj.gameObject.SetActive(true); } EGTween.MoveFrom(blockContainer.gameObject, EGTween.Hash("isLocal", true, "x", 50, "time", blockTransitionTime)); } }
/// <summary> /// Raises the enable event. /// </summary> void OnEnable() { EGTween.ScaleTo(gameObject, EGTween.Hash("x", 0, "y", 0, "time", 0.5f, "oncomplete", "DestroyObject", "oncompletetarget", gameObject)); }