private void ScaleUp(Vector3 scale) { Vector3 currentScale = transform.localScale; ScaleTo scaleTo = new ScaleTo(this, currentScale, scale, AnimationTime); RunTask(scaleTo); }
public void ScaleFurniture(Furniture_Recepteur recepteur, Vector3 oldScaling, Vector3 newScaling) { Commande commande = new ScaleTo(recepteur.getGameObject(), oldScaling, newScaling); commande.Do(); commandeList.Push(commande); editManager.RefreshInfos(); }
/// <summary> /// 让角色缩放指定大小 /// </summary> /// /// <param name="o"></param> /// <param name="sx"></param> /// <param name="sy"></param> /// <returns></returns> public ScaleTo CallScaleTo(Loon.Action.ActionBind o, float sx, float sy) { if (isClose) { return(null); } ScaleTo scale = new ScaleTo(sx, sy); AddActionEvent(scale, o); return(scale); }
private void InitAnimation() { const float FinalAlpha = 1.0f; ScaleTo grow = new ScaleTo(this, InitialScale, FinalScale, AnimationTime); FadeTo fadeIn = new FadeTo(this, InitialAlpha, FinalAlpha, FadeTime); Delay fadeDelay = new Delay(this, AnimationTime - (2 * FadeTime)); FadeTo fadeOut = new FadeTo(this, FinalAlpha, 0, FadeTime); Sequence fadeSequence = new Sequence(fadeIn, fadeDelay, fadeOut); Animation = new ConcurrentGameTask(grow, fadeSequence); Animation.FinishSelf(); }
private void Init(int level, float scale, float duration) { BulletLevel = level; Scale = scale; Duration = duration; var scaleIn = new ScaleTo(this, InitialScale, Scale, ScaleTime); ScaleIn = new EaseIn3(scaleIn); Delay = new Delay(this, Duration); var scaleOut = new ScaleTo(this, Scale, InitialScale, ScaleTime); ScaleOut = new EaseOut3(scaleOut); Behavior = new Sequence(ScaleIn, EnableProjectiles, Delay, DisableProjectiles, ScaleOut); }
protected override void OnInit() { var initialSize = GetComponent <Renderer>().bounds.size; float spawnMinX = SpaceUtil.WorldMap.Left.x + initialSize.x; float spawnMinY = (SpaceUtil.WorldMap.Bottom.y + SpaceUtil.WorldMap.Center.y) * 0.5f; SpawnMin = new Vector2(spawnMinX, spawnMinY); float spawnMaxX = SpaceUtil.WorldMap.Right.x - initialSize.x; float spawnMaxY = (SpaceUtil.WorldMap.Center.y + SpaceUtil.WorldMap.Top.y) * 0.5f; SpawnMax = new Vector2(spawnMaxX, spawnMaxY); var activateCanCollide = new GameTaskFunc(this, () => CanCollide = true); float fullBrightAlpha = Alpha; var entranceFadeIn = new FadeTo(this, 0f, fullBrightAlpha, FadeTime); var entranceScaleIn = new ScaleTo(this, float.Epsilon, LocalScale, FadeTime); var entranceSequence = new Sequence(entranceFadeIn, entranceScaleIn, activateCanCollide); var fadeOut = new FadeTo(this, fullBrightAlpha, TravelAlpha, FadeTime); var fadeOutEase = new EaseIn3(fadeOut); var scaleOut = new ScaleTo(this, LocalScale, TravelSizeScale, FadeTime); var scaleOutEase = new EaseIn3(scaleOut); var fadeOutConcurrence = new ConcurrentGameTask(fadeOutEase, scaleOutEase); TravelMove = MoveTo.Default(this, 1.0f); TravelMoveEase = new EaseInOut(TravelMove); var fadeIn = new FadeTo(this, TravelAlpha, fullBrightAlpha, FadeTime); var scaleIn = new ScaleTo(this, TravelSizeScale, LocalScale, FadeTime); var fadeInConcurrence = new ConcurrentGameTask(fadeIn, scaleIn); TravelSequence = new Sequence(fadeOutConcurrence, TravelMoveEase, fadeInConcurrence, activateCanCollide); CanCollide = false; LocalScale = float.Epsilon; transform.position = SpaceUtil.WorldMap.Center; RunTask(entranceSequence); }
// esplode l'aereo con l'animazione public async Task Explode() { Health = 0; // crea uno speciale nodo indipendente nella scena per l'esplosione var explosionNode = Scene.CreateChild(); SoundSource soundSource = explosionNode.CreateComponent <SoundSource>(); soundSource.Play(Application.ResourceCache.GetSound(Assets.Sounds.BigExplosion)); soundSource.Gain = 0.5f; explosionNode.Position = Node.WorldPosition; OnExplode(explosionNode); var scaleAction = new ScaleTo(1f, 0f); Node.RemoveAllActions(); Node.Enabled = false; await explosionNode.RunActionsAsync(scaleAction, new DelayTime(1f)); liveTask.TrySetResult(true); explosionNode.Remove(); }
//飞机爆炸的动画 public async Task Explode() { health = 0; //在场景中创建用于爆炸的特殊独立节点 var explosionNode = Scene.CreateChild(); SoundSource soundSource = explosionNode.CreateComponent <SoundSource>(); soundSource.Play(Application.ResourceCache.GetSound(Assets.Sounds.BigExplosion)); soundSource.Gain = 0.5f; explosionNode.Position = Node.WorldPosition; OnExplode(explosionNode); var scaleAction = new ScaleTo(1f, 0f); //Scale是比例尺 Node.RemoveAllActions(); Node.Enabled = false; await explosionNode.RunActionsAsync(scaleAction, new DelayTime(1f)); liveTask.TrySetResult(true); explosionNode.Remove(); }
public override async void OnHit(Aircraft target, bool killed, Node bulletNode) { // mostra una piccola esplosione quando il missile raggiunge un aereo base.OnHit(target, killed, bulletNode); var cache = Application.ResourceCache; var explosionNode = Scene.CreateChild(); // riprodurre il suono "boom" SoundSource soundSource = explosionNode.CreateComponent <SoundSource>(); soundSource.Play(Application.ResourceCache.GetSound(Assets.Sounds.SmallExplosion)); soundSource.Gain = 0.2f; explosionNode.Position = target.Node.WorldPosition; explosionNode.SetScale(1f); var particleEmitter = explosionNode.CreateComponent <ParticleEmitter2D>(); particleEmitter.Effect = cache.GetParticleEffect2D(Assets.Particles.MissileTrace); var scaleAction = new ScaleTo(0.5f, 0f); await explosionNode.RunActionsAsync(scaleAction, new DelayTime(0.5f)); explosionNode.Remove(); }
public override async void OnHit(Aircraft target, bool killed, Node bulletNode) { // show a small explosion when the missile reaches an aircraft. base.OnHit(target, killed, bulletNode); var cache = Application.ResourceCache; var explosionNode = Scene.CreateChild(); // play "boom" sound SoundSource soundSource = explosionNode.CreateComponent <SoundSource>(); soundSource.Play(Application.ResourceCache.GetSound(Assets.Sounds.SmallExplosion)); soundSource.Gain = 0.2f; explosionNode.Position = target.Node.WorldPosition; explosionNode.SetScale(1f); var particleEmitter = explosionNode.CreateComponent <ParticleEmitter2D>(); particleEmitter.Effect = cache.GetParticleEffect2D(Assets.Particles.MissileTrace); var scaleAction = new ScaleTo(0.5f, 0f); await explosionNode.RunActionsAsync(scaleAction, new DelayTime(0.5f)); explosionNode.Remove(); }
//private Delay DeactivateDelay { get; set; } //private Sequence FallbackDeactivate { get; set; } //public float FallbackDeactivationTime //{ // get => _fallbackDeactivationTime; // set // { // const float TimeDelta = 5f / 60f; // if (_fallbackDeactivationTime != value) // { // _fallbackDeactivationTime = value; // DeactivateDelay.Duration = (value - FadeInTime) + TimeDelta; // FallbackDeactivate.RecalculateDuration(); // } // } //} protected override void OnPlayerBulletInit() { float worldHeight = SpaceUtil.WorldMap.Height; float spriteHeight = Sprite.size.y; float heightScale = worldHeight / spriteHeight; transform.localScale = new Vector3(0f, heightScale, 1f); Alpha = 0f; Vector3 scaleInitial = new Vector3(0f, heightScale, 1f); Vector3 scaleFinal = new Vector3(1f, heightScale, 1f); ScaleIn = new ScaleTo(this, scaleInitial, scaleFinal, FadeInTime); var fadeIn = new FadeTo(this, MaxAlpha, float.Epsilon); // FadeInTime * 0.25f SpawnAnimation = new ConcurrentGameTask(ScaleIn, fadeIn); //DeactivateDelay = new Delay(this, FallbackDeactivationTime - FadeInTime); //var deactivate = new GameTaskFunc(this, DeactivateSelf); //FallbackDeactivate = new Sequence(concurrence, DeactivateDelay, deactivate); }
protected override void OnPermanentVelocityBulletInit() { Scale = SpaceUtil.WorldMap.Height; var scaleIn = new ScaleTo(this, float.Epsilon, Scale, ScaleInTime); var scaleEase = new EaseIn3(scaleIn); MoveToCenter = new MoveTo(this, Vector3.zero, new Vector3(1f, 1f), ScaleInTime); var scaleAndMove = new ConcurrentGameTask(scaleEase, MoveToCenter); var calmExplosion = new GameTaskFunc(this, () => IsExploding = false); var fade = new FadeTo(this, 0, FadeTime); var fadeEase = new EaseOut(fade); Sequence = new Sequence(scaleAndMove, calmExplosion, fadeEase); //ManagedMiscSprites = new List<ValkyrieSprite>(); ManagedEnemies = new TrackedPooledObjectSet <Enemy>(); ManagedEnemyBullets = new TrackedPooledObjectSet <EnemyBullet>(); ManagedPlayerBullets = new TrackedPooledObjectSet <PlayerBullet>(); ManagedPickups = new TrackedPooledObjectSet <Pickup>(); }
public void RefreshUI(rep_message_start_ready readyInfo) { struct_player_info opponentInfo = readyInfo.PlayerInfo; Debug.Log("UIReady.RefreshUI readyInfo = " + readyInfo); //我的头像 if (!string.IsNullOrEmpty(PlayerData.userIcon)) { var headIcon = transform.Find("PlayerInfo/LeftHeadImage/Mask/Image").GetComponent <Image>(); StartCoroutine(Function.DownloadImage(headIcon, PlayerData.userIcon)); } //对手头像 if (!string.IsNullOrEmpty(opponentInfo.UserIcon)) { var headIcon = transform.Find("PlayerInfo/RightHeadImage/Mask/Image").GetComponent <Image>(); StartCoroutine(Function.DownloadImage(headIcon, opponentInfo.UserIcon)); } //倒计时 float totalTime = (float)(readyInfo.StartTime - Function.GetServerTime()); Image countdownImage = transform.Find("Countdown/Bar").GetComponent <Image>(); Scheduler.Instance.CreateScheduler("UIReady.Countdown", 0, 0, 0.01f, (param) => { float lastTime = (float)(readyInfo.StartTime - Function.GetServerTime()); countdownImage.fillAmount = lastTime / totalTime; //Debug.Log("UIReady.Countdown lastTime = " + lastTime + " totalTime = " + totalTime); if (countdownImage.fillAmount <= 0) { Scheduler.Instance.Stop("UIReady.Countdown"); //请求开始 CommonRequest.ReqSatrtGame(readyInfo.Innings, (repMsg) => { //关闭UI //this.Close(); }); } }); //第几回合 transform.Find("Countdown/Text").GetComponent <Text>().text = Language.GetTextByKey(InningsTextKey[readyInfo.Innings]); //展示要随机的玩法 playViewList.RegisterInitCallback((Transform obj, int index) => { int playID = readyInfo.RandPlayId[index]; //获取配置 play_data playData = PlayDataConfig.Instance.GetDataByID(playID); //icon Function.SetImageSprite(obj.Find("Icon/Image").GetComponent <Image>(), playData.Icon); //名字 obj.Find("Name").GetComponent <Text>().text = playData.Name; }); //刷新列表 playViewList.totalCount = readyInfo.RandPlayId.Count; playViewList.RefillCells(); //随机选中玩法 int randCount = 0; Transform randRoot = transform.Find("RandPlay/Viewport/Content"); Scheduler.Instance.CreateScheduler("UIReady.RandPlay", 0, 0, 0.3f, (param) => { for (int idx = 0; idx < randRoot.childCount; idx++) { randRoot.GetChild(idx).Find("Icon/Choose").gameObject.SetActive(idx == randCount); } if (readyInfo.RandPlayId[randCount] == readyInfo.PlayId && readyInfo.StartTime - Function.GetServerTime() < 1.0) { //结束定时器 Scheduler.Instance.Stop("UIReady.RandPlay"); //播放一个放大效果 ScaleTo scaleTo = randRoot.GetChild(randCount).Find("Icon").GetComponent <ScaleTo>(); scaleTo.Play(); } randCount = (randCount + 1) % readyInfo.RandPlayId.Count; }); }
void CallFuncTest() { btn_text.text = "点击停止"; var action = Sequence.Create( CallFunc.Create(CallBackO, "延时0.5秒"), DelayTime.Create(0.5f), CallFunc.Create(CallBackO, "图片移动"), MoveTo.Create(1f, 200, 100).InitSubjectTransform(image.transform), MoveTo.Create(1f, 0, 0).InitSubjectTransform(image.transform), CallFunc.Create(CallBackO, "颜色渐变"), ColorTo.Create(0.5f, 1, 0, 0, 1f).InitSubjectComponent(image), ColorTo.Create(0.5f, 0, 1, 0, 1f).InitSubjectComponent(image), ColorTo.Create(0.5f, 0, 0, 1, 1f).InitSubjectComponent(image), CallFunc.Create(CallBackO, "颜色reset"), ColorTo.Create(0.5f, 1, 1, 1, 1).InitSubjectComponent(image), CallFunc.Create(CallBackO, "渐隐"), FadeOut.Create(1f).InitSubjectComponent(image), CallFunc.Create(CallBackO, "渐出"), FadeIn.Create(1f).InitSubjectComponent(image), CallFunc.Create(CallBackO, "1秒闪烁5次"), Blink.Create(1f, 5), CallFunc.Create(CallBackO, "二阶贝塞尔曲线"), BezierTo.Create(2.0f, new Vector3(200, 100, 0), new Vector3(-100, 50, 0), new Vector3(100, 80, 0)).InitSubjectTransform(image.transform), CallFunc.Create(CallBackO, "移动回原点"), MoveTo.Create(1f, 0, 0).InitSubjectTransform(image.transform), CallFunc.Create(CallBackO, "边移动边放大"), Spawn.Create(MoveTo.Create(1.0f, 200, 100f), ScaleTo.Create(1.0f, 3.0f, 3.0f, 3.0f)), CallFunc.Create(CallBackO, "缩放位置回原位"), Spawn.Create(MoveTo.Create(1.0f, 0, 0), ScaleTo.Create(1.0f, 1f, 1f, 1f)), NumberBy.Create(2.0f, "数字跳跃,从100到200:{0:f2}", 100, 100).InitSubjectComponent(text), DelayTime.Create(0.5f), NumberTo.Create(2.0f, "数字跳跃,从200到0:{0:f2}", 200, 0).InitSubjectComponent(text), DelayTime.Create(0.5f), CallFunc.Create(CallBackO, "Image Filled"), FillAmountTo.Create(1.5f, 0f).InitSubjectComponent(image), FillAmountTo.Create(1.5f, 1.0f).InitSubjectComponent(image), CallFunc.Create(CallBackO, "reset"), CallFunc.Create(CallBackO, "旋转 放大2倍,复原。重复3次"), Repeat.Create(Spawn.Create( RotationBy.Create(1.0f, 0, 0, 360f), Sequence.Create( ScaleTo.Create(0.5f, 2.0f, 2.0f, 2.0f), ScaleTo.Create(0.5f, 1.0f, 1.0f, 1.0f))).InitSubjectTransform(image.transform), 3), ExtraAction.Create() ); float toX = 300f; var easeAction = Sequence.Create( CallFunc.Create(CallBackO, "变速运动演示,图一正常,图二是变速运动"), DelayTime.Create(1f), CallFunc.Create(CallBackO, "当前变速是EaseIn"), DelayTime.Create(0.5f), Spawn.Create( MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image.transform), EaseIn.Create(MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)), CallFunc.Create(CallBackO, "复位"), Spawn.Create( MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image.transform), EaseIn.Create(MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)), CallFunc.Create(CallBackO, "当前变速是EaseOut"), DelayTime.Create(0.5f), Spawn.Create( MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image.transform), EaseOut.Create(MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)), CallFunc.Create(CallBackO, "复位"), Spawn.Create( MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image.transform), EaseOut.Create(MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)), CallFunc.Create(CallBackO, "当前变速是EaseInOut"), DelayTime.Create(0.5f), Spawn.Create( MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image.transform), EaseInOut.Create(MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)), CallFunc.Create(CallBackO, "复位"), Spawn.Create( MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image.transform), EaseInOut.Create(MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)), CallFunc.Create(CallBackO, "变速运动未完待续"), DelayTime.Create(1f), ExtraAction.Create() ); CCActionManager.Instance.AddAction(Sequence.Create(action, easeAction, CallFunc.Create(CallBackEnd)), transform); }
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; } }