public static RotateBy Create(float duration, Vector3 axis, float deltaAngle, Space space) { RotateBy rotateby = new RotateBy(); if (rotateby.InitWithDuration(duration, axis, deltaAngle, space)) { return(rotateby); } return(null); }
//deprecated public void FlipFinal(float delay = 0f, bool withAnimation = true) { /* #region NEW_ADD * int sceneIndex = UnityEngine.SceneManagement.SceneManager.GetActiveScene ().buildIndex; * if (sceneIndex != (int)EScene.SCENE_Demo) { * return; * } #endregion */ Vector3 oldPos = transform.position; if (withAnimation) { _flipActionList.Clear(); FiniteTimeAction delayTime = null; if (delay > 0f) { delayTime = DelayTime.Create(delay); } //上移 FiniteTimeAction mby = MoveBy.Create(0.2f, Vector3.up * 10f); //翻过来 FiniteTimeAction mbt1 = RotateBy.Create(0.2f, Vector3.forward, 180f, Space.Self); //下移到原来的地方 FiniteTimeAction mbt2 = MoveTo.Create(0.2f, oldPos); FiniteTimeAction mbt3 = MoveTo.Create(0.2f, Vector3.up * 5f); FiniteTimeAction mbt4 = RotateTo.Create(0.2f, Vector3.zero); FiniteTimeAction mbt5 = InvokeAction.Create(delegate(GameObject target, object userdata) { //TableController.Instance.SetCurrentPlayedTile (this); }); if (delayTime != null) { _flipActionList.Add(delayTime); } _flipActionList.Add(mby); _flipActionList.Add(mbt1); _flipActionList.Add(mbt2); _flipActionList.Add(mbt3); _flipActionList.Add(mbt4); _flipActionList.Add(mbt5); ActionManager.Instance.RunAction(gameObject, _flipActionList); } else { //transform.Rotate (Vector3.forward, 180f, Space.Self); transform.rotation = Quaternion.identity; transform.position = Vector3.up * 5f; //TableController.Instance.SetCurrentPlayedTile (this); } }
public async void Rotate() { if (planeNode == null) //not created yet { return; } var moveAction = new MoveBy(1f, new Vector3(0, 0, 5)); var rotateAction = new RotateBy(duration: 1, deltaAngleX: 0, deltaAngleY: 90, deltaAngleZ: 20); //planeNode.GetComponent<StaticModel>().Model = CoreAssets.Models.Sphere; //planeNode.SetScale(7f); await planeNode.RunActionsAsync(new Urho.Actions.Parallel(moveAction, rotateAction)); await planeNode.RunActionsAsync(new RepeatForever(new RotateBy(duration: 1, deltaAngleX: 0, deltaAngleY: 90, deltaAngleZ: 0))); }
// Update is called once per frame void Update() { if (bulletTimer <= 0) { // Timer bulletTimer = bulletCooldown; // Calculating Rotation var r = 0f; if (isRandomRotation) { r = Random.Range(-rotationSpeed, rotationSpeed); } else { r = rotationSpeed * rF; rF *= -1; } // Instantiating Bullet var bSpread = BulletSpread.Create(transform.position, numOfBullets, bulletSpeed: bulletSpeed, runTimer: false, translate: true, isParent: true); bSpread.transform.eulerAngles = new Vector3(0, 0, r); var bullets = bSpread.GetComponent <BulletSpread>().Attack(customObj: customObject); bulletSpreads.Add(bSpread); // Checking for Max Bullets if (bulletSpreads.Count >= maxBulletSpreads) { Destroy(bulletSpreads[0] as GameObject); bulletSpreads.RemoveAt(0); } // If we want a customSprite the custom Sprite will be applied to each of the bullets if (customSprite != null) { foreach (var bullet in bullets) { bullet.GetComponent <SpriteRenderer>().sprite = customSprite; } } RotateBy.Add(bSpread, r); } bulletTimer -= Time.deltaTime; }
//deprecated public void Flip(float delay = 0f, bool withAnimation = true) { /* #region NEW_ADD * int sceneIndex = UnityEngine.SceneManagement.SceneManager.GetActiveScene ().buildIndex; * if (sceneIndex != (int)EScene.SCENE_Demo) { * return; * } #endregion */ Vector3 oldPos = transform.position; if (withAnimation) { _flipActionList.Clear(); FiniteTimeAction delayTime = null; if (delay > 0f) { delayTime = DelayTime.Create(delay); } //上移 FiniteTimeAction mby = MoveBy.Create(0.2f, Vector3.up * 10f); //翻过来 FiniteTimeAction mbt1 = RotateBy.Create(0.2f, Vector3.forward, 180f, Space.Self); //下移到原来的地方 FiniteTimeAction mbt2 = MoveTo.Create(0.2f, oldPos); if (delayTime != null) { _flipActionList.Add(delayTime); } _flipActionList.Add(mby); _flipActionList.Add(mbt1); _flipActionList.Add(mbt2); ActionManager.Instance.RunAction(gameObject, _flipActionList); } else { transform.Rotate(Vector3.forward, 180f, Space.Self); } }
public bool IsRotateByMB() { return(RotateBy.Equals(ROTATE_BY_MB)); }
public bool IsRotateByMin() { return(RotateBy.Equals(ROTATE_BY_MIN)); }
public static void MoveCharacter(string direction) { var vector3 = scene1.PrimayCharacter.Location; Vector3 vector = new Vector3(vector3.X, vector3.Y, vector3.Z); if (vector.X % 5f == 0 && vector.Y % 5f == 0 && vector.Z % 5f == 0) { RotateBy rotate = null; RotateTo rotateTo = null; const float distance = 5; const float duration = distance / 5; switch (direction) { case "L": rotateTo = new RotateTo(duration: duration, deltaAngleX: 0, deltaAngleY: 0, deltaAngleZ: 90); vector.X -= distance; break; case "R": rotateTo = new RotateTo(duration: duration, deltaAngleX: 0, deltaAngleY: 0, deltaAngleZ: -90); vector.X += distance; break; case "D": rotate = new RotateBy(duration: duration, deltaAngleX: 0, deltaAngleY: -90, deltaAngleZ: 0); vector.Y -= distance; break; case "U": rotate = new RotateBy(duration: duration, deltaAngleX: 0, deltaAngleY: 90, deltaAngleZ: 0); vector.Y += distance; break; case "B": rotate = new RotateBy(duration: duration, deltaAngleX: 0, deltaAngleY: 0, deltaAngleZ: 0); vector.Z -= distance; break; case "F": rotate = new RotateBy(duration: duration, deltaAngleX: -90, deltaAngleY: 0, deltaAngleZ: 0); vector.Z += distance; break; default: rotate = new RotateBy(duration: duration, deltaAngleX: 90, deltaAngleY: 0, deltaAngleZ: 0); break; } if (scene1.CheckBlockLocationIsEmpty(vector)) { var moveTo = new MoveTo(duration, vector); var ease = GetRandomActionEase(moveTo); scene1.PrimayCharacter.BlockNode.RunActions(ease); //if (rotate == null) //{ // scene1.PrimayCharacter.BlockNode.RunActionsAsync(new Urho.Actions.Parallel(ease, rotateTo)); //} //else //{ // scene1.PrimayCharacter.BlockNode.RunActionsAsync(new Urho.Actions.Parallel(ease, rotate)); //} } } }
public override void Execute() { if (m_DOTweenAction == null) { Debug.LogError("무브 액션이 설정안된 객체입니다. 설정해주시기 바랍니다. 에러객체 이름 및 좌표 : " + m_MonoBehaviour.gameObject.name + " / " + m_MonoBehaviour.gameObject.transform.position); return; } switch (m_DOTweenActionType) { case DOTweenActionType.MoveTo: { MoveTo to = m_DOTweenAction as MoveTo; m_MonoBehaviour.gameObject.transform .DOMove(to.GetEndPoint(), to.GetDuration()) .OnComplete(() => m_IsCompleted = true); } break; case DOTweenActionType.MoveBy: { MoveBy by = m_DOTweenAction as MoveBy; m_MonoBehaviour.gameObject.transform .DOBlendableMoveBy(by.GetEndPoint(), by.GetDuration()) .OnComplete(() => m_IsCompleted = true); } break; case DOTweenActionType.MovePaths: { MovePaths paths = m_DOTweenAction as MovePaths; m_MonoBehaviour.gameObject.transform .DOPath(paths.GetPaths(), paths.GetDuration(), paths.GetPathType()) .OnComplete(() => m_IsCompleted = true); } break; case DOTweenActionType.RotateTo: { RotateTo roateto = m_DOTweenAction as RotateTo; m_MonoBehaviour.gameObject.transform .DORotate(roateto.GetEndPoint(), roateto.GetDuration()) .OnComplete(() => m_IsCompleted = true); } break; case DOTweenActionType.RotateBy: { RotateBy roateby = m_DOTweenAction as RotateBy; m_MonoBehaviour.gameObject.transform .DOBlendableLocalRotateBy(roateby.GetEndPoint(), roateby.GetDuration()) .OnComplete(() => m_IsCompleted = true); } break; case DOTweenActionType.ColorTo: { ColorTo colorto = m_DOTweenAction as ColorTo; m_MonoBehaviour.gameObject.GetComponentInChildren <MeshRenderer>().material .DOColor(colorto.GetEndPoint(), colorto.GetDuration()) .OnComplete(() => m_IsCompleted = true); } break; case DOTweenActionType.ColorRewind: { ColorTo colorto = m_DOTweenAction as ColorTo; Material material = m_MonoBehaviour.gameObject.GetComponentInChildren <MeshRenderer>().material; Color oriColor = material.color; float duration = colorto.GetDuration() / 2; DOTween.Sequence() .Append(material.DOColor(oriColor, duration)) .Append(material.DOColor(colorto.GetEndPoint(), duration)) .OnComplete(() => m_IsCompleted = true); } break; case DOTweenActionType.ScaleTo: { ScaleTo scaleTo = m_DOTweenAction as ScaleTo; m_MonoBehaviour.gameObject.transform .DOScale(scaleTo.GetEndPoint(), scaleTo.GetDuration()) .OnComplete(() => m_IsCompleted = true); } break; } }
private bool showPocketList(Transform locator, bool lastGap = true) { TileDef def = null; MahjongTile tile = null; FiniteTimeAction delay = null; FiniteTimeAction rb = null; float angle = 0f; if (_direction == Vector3.right) { //self angle = 0f; } else if (_direction == Vector3.forward) { //right angle = -270f; } else if (_direction == Vector3.left) { //front angle = -180; } else if (_direction == -Vector3.forward) { //left angle = -90f; } for (int i = 0; i < _sortPocketList.Count; ++i) { tile = _sortPocketList [i]; tile.transform.parent = null; tile.Direction = MahjongTile.Face.PLANE_NEGTIVE; tile.transform.Rotate(Vector3.up, angle, Space.Self); tile.transform.parent = locator; tile.transform.localPosition = i * _direction * MahjongTile.Width; } if (lastGap) { tile.transform.localPosition = tile.transform.localPosition + _direction * 0.2f * MahjongTile.Width; } for (int i = 0; i < locator.transform.childCount; ++i) { tile = locator.transform.GetChild(i).GetComponent <MahjongTile> (); List <FiniteTimeAction> list = new List <FiniteTimeAction> (); /* * if (_DelayShowHand > 0f) { * delay = DelayTime.Create (_DelayShowHand); * list.Add (delay); * } */ rb = RotateBy.Create(0.1f, Vector3.right, 180f, Space.Self); list.Add(rb); ActionManager.Instance.RunAction(tile.gameObject, list); } return(true); }
private IEnumerator initDraw(bool banker) { _initDrawFinished = false; float angle = 0f; if (_direction == Vector3.right) { //self angle = 0f; } else if (_direction == Vector3.forward) { //right angle = -270f; } else if (_direction == Vector3.left) { //front angle = -180; } else if (_direction == -Vector3.forward) { //left angle = -90f; } RotateBy rb = null; TileDef def = null; MahjongTile tile = null; Transform locator = PocketLocator; float duration = 0.1f; float waitDuration = 0.3f; int index = 0; int drawCountPerTime = 4; for (int i = 0; i < 4; ++i) { if (i == 3) { drawCountPerTime = 1; } for (int j = 0; j < drawCountPerTime; ++j) { //_pile.PopOneTile (); def = _proxy.PocketList [index]; tile = MahjongTile.Create(def); tile.Direction = MahjongTile.Face.PLANE_NEGTIVE; tile.transform.Rotate(Vector3.up, angle, Space.Self); tile.transform.parent = locator.transform; tile.transform.localPosition = index * _direction * MahjongTile.Width; rb = RotateBy.Create(duration, Vector3.right, 90f, Space.Self); ActionManager.Instance.RunAction(tile.gameObject, rb); //yield return new WaitForSeconds (duration); ++index; } yield return(new WaitForSeconds(waitDuration)); } for (int i = 0; i < locator.childCount; ++i) { tile = locator.GetChild(i).GetComponent <MahjongTile> (); rb = RotateBy.Create(duration, Vector3.right, -90f, Space.Self); ActionManager.Instance.RunAction(tile.gameObject, rb); } yield return(new WaitForSeconds(waitDuration)); //_proxy.SortPocketList (TileDef.Comparison); _sortPocketList = SortMahjongTile(locator); for (int i = 0; i < _sortPocketList.Count; ++i) { tile = _sortPocketList [i]; tile.transform.localPosition = i * _direction * MahjongTile.Width; rb = RotateBy.Create(duration, Vector3.right, 90f, Space.Self); ActionManager.Instance.RunAction(tile.gameObject, rb); } yield return(new WaitForSeconds(waitDuration)); if (banker) { if (_proxy.PocketList.Count == 14) { def = _proxy.PocketList [13]; _proxy.RemovePocketList(def, 1); Draw(def); _drawTile = null; } else { def = TileDef.Create(); Draw(def); _drawTile = null; } } _initDrawFinished = true; }