コード例 #1
0
    IEnumerator WaitDoMove()
    {
        // 中断時の値変更対策
        if (m_currentTarget >= m_targets.Count)
        {
            if (isLoop)
            {
                m_currentTarget = 0;
            }
            else
            {
                StopAllCoroutines();
            }
        }

        // ターゲット情報をリストから取得
        m_nextTarget = m_targets[m_currentTarget].GetComponents <GimmickTarget>();

        // 待機時間
        float waitTime = 0.0f;

        // 次のターゲットオブジェクトのTweenを全て実行する
        foreach (var item in m_nextTarget)
        {
            Tween tween = item.GimmickTween(m_gimmick);
            float t     = tween.Duration() + tween.Delay();
            if (t > waitTime)
            {
                waitTime = tween.Duration() + tween.Delay();
            }
        }

        // ターゲットを次に進める
        m_currentTarget++;

        // 移動時間だけ待機する
        yield return(new WaitForSeconds(waitTime));

        // 次のターゲットの番号が全ターゲット数を越えていたら
        if (m_currentTarget >= m_targets.Count)
        {
            // ループフラグが立っていたら
            if (isLoop == true)
            {
                // ターゲット番号をはじめに戻す
                m_currentTarget = 0;
                // コルーチンの再帰
                StartCoroutine(WaitDoMove());
            }
        }
        else
        {
            // コルーチンの再帰
            StartCoroutine(WaitDoMove());
        }
    }
コード例 #2
0
    protected override void OnUpdate()
    {
        Entities.With(_ZoneQuery).ForEach(
            (Entity entity, ref Translation translation, ref NonUniformScale scale) =>
        {
            if (!_TweenRecord.Contains(entity))
            {
                var timeToShrink = HeraldsBootstrap.Settings.ZoneShrinkTime;

                var translationValue = firstShrink ? translation.Value : nextZoneCenter;
                var scaleValue       = scale.Value.x / 2f;

                _TweenRecord.Add(entity);
                Tween.MoveEntity(entity, timeToShrink,
                                 firstShrink
                            ? translation.Value
                            : nextZoneCenter, translation.Value);
                Tween.ScaleEntity(entity, timeToShrink, scale.Value / 2f, scale.Value)
                .OnTweenComplete(() =>
                {
                    firstShrink    = false;
                    nextZoneCenter = CalculateNewPosition(translationValue, scaleValue);
                    Tween.Delay(HeraldsBootstrap.Settings.TimeBetweenShrinks,
                                () => { _TweenRecord.Remove(entity); });
                });
            }
        });
    }
コード例 #3
0
 private void Appear()
 {
     Director.WindowOpened = true;
     Tween.To(this, "alpha", 1f, 0.5f, true,
              () => Tween.Delay(
                  this, 1, true, () => Tween.To(
                      this, "alpha", 0f, 0.5f, true, () => Director.WindowOpened = false
                      )
                  )
              );
 }
コード例 #4
0
 void OnEnable()
 {
     if (startOnAwake)
     {
         if (wait == 0)
         {
             Play();
         }
         else
         {
             tween = Tween.Delay(wait, () => Play());
             tween.Start();
         }
     }
 }
コード例 #5
0
ファイル: Attacker.cs プロジェクト: pzagora/ECS-Heralds
 private void Start()
 {
     gameObject.GetComponent <SphereCollider>().enabled = false;
     Tween.Delay(1f, () =>
     {
         GameObject go;
         (go = gameObject).GetComponent <SphereCollider>().enabled = true;
         Tween.Delay(0.1f, () =>
         {
             go.GetComponent <SphereCollider>().enabled = false;
             Destroy(go, 0.4f);
         });
     });
     _EntityManager   = World.Active.EntityManager;
     _AttackArchetype = _EntityManager.CreateArchetype(typeof(AttackData));
 }
コード例 #6
0
ファイル: CleanupSystem.cs プロジェクト: pzagora/ECS-Heralds
 protected override void OnUpdate()
 {
     Entities.With(_DeadObjects).ForEach(
         (Entity entity, ref Translation translation, Rigidbody rigidBody) =>
     {
         PostUpdateCommands.AddComponent(entity, new SinkedData());
         var newPosition = (Vector3)translation.Value + new Vector3(0, -5, 0);
         Tween.MoveGameObject(rigidBody.gameObject, 5f, newPosition);
         Tween.Delay(2f,
                     () =>
         {
             EntityManager.SetComponentData(entity,
                                            new Translation {
                 Value = new float3(9999f, 0, 9999f)
             });
         });
     });
 }
コード例 #7
0
    private static int Delay(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 1);
            Tween t   = (Tween)ToLua.CheckObject(L, 1, typeof(Tween));
            float num = t.Delay();
            LuaDLL.lua_pushnumber(L, (double)num);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
コード例 #8
0
        public void ShowDialogue(Dialogue dialogue)
        {
            last    = current;
            current = dialogue;

            manager.audio.Play(manager.GetAudio(_dialogueContainer.GetMusicName(dialogue.music)));

            if (last == null)
            {
                MoveLayout(0, current.isDictor ? -3000 : 3000, !current.isDictor, BgTransition);
            }
            else if (last != null)
            {
                if (current.person != last.person)
                {
                    if (_layoutPositionX == 0 && !last.isDictor)
                    {
                        MoveLayout(0, 3000, true, BgTransition);
                    }
                    else if (_layoutPositionY == 0 && last.isDictor)
                    {
                        MoveLayout(0, -3000, false, BgTransition);
                    }
                    else
                    {
                        BgTransition();
                    }
                }
                else
                {
                    ToggleSteps(true);
                    Tween.Delay((steps.Length + 1) * anim.stepDelay + anim.stepTime, BgTransition).Start();
                }
            }
            else
            {
                BgTransition();
            }
        }
コード例 #9
0
    protected override void OnUpdate()
    {
        Entity zoneEntity   = default;
        float3 zonePosition = Vector3.zero;
        var    zoneDistance = 0f;

        Entities.With(_ZoneQuery).ForEach(
            (Entity entity, ref Translation translation, ref NonUniformScale scale) =>
        {
            zoneEntity   = entity;
            zonePosition = translation.Value;
            zoneDistance = scale.Value.x;
        });


        Entities.With(_DamagableQuery).ForEach(
            (Entity entity, ref Translation translation, ref HealthData hp) =>
        {
            var position  = translation.Value;
            var heading   = (Vector3)(zonePosition - position);
            var magnitude = heading.magnitude;

            if (!_TweenRecord.Contains(entity) && magnitude > zoneDistance / 2)
            {
                _TweenRecord.Add(entity);
                _AttackEntity = _EntityManager.CreateEntity(_AttackArchetype);
                _EntityManager.SetComponentData(_AttackEntity, new AttackData
                {
                    Damage = HeraldsBootstrap.Settings.ZoneDamagePerTick,
                    Source = zoneEntity,
                    Target = entity
                });
                Tween.Delay(HeraldsBootstrap.Settings.TimePerTick, () => { _TweenRecord.Remove(entity); });
            }
        });
    }
コード例 #10
0
        void Start()
        {
            m_LastMove  = moveProp;
            m_LastScale = scaleProp;

            Time.timeScale = timeScale;

            Entity prefab        = GameObjectConversionUtility.ConvertGameObjectHierarchy(this.prefab, World.Active);
            var    entityManager = World.Active.EntityManager;

            float   halfX = CountX / 2.0f;
            float   halfY = CountX / 2.0f;
            Vector2 c     = new Vector2(halfX, halfY);

            for (int x = 0; x < CountX; x++)
            {
                for (int y = 0; y < CountY; y++)
                {
                    var instance = entityManager.Instantiate(prefab);
                    var position = transform.TransformPoint(new float3(x * 1.3F,
                                                                       noise.cnoise(new float2(x, y) * 0.21F) * 2, y * 1.3F));

                    if (entityManager.HasComponent(instance, typeof(Translation)))
                    {
                        entityManager.SetComponentData(instance, new Translation {
                            Value = position
                        });
                    }
                    else
                    {
                        entityManager.AddComponentData(instance, new Translation {
                            Value = position
                        });
                    }

                    if (entityManager.HasComponent(instance, typeof(NonUniformScale)))
                    {
                        entityManager.SetComponentData(instance, new NonUniformScale {
                            Value = Vector3.one
                        });
                    }
                    else
                    {
                        entityManager.AddComponentData(instance, new NonUniformScale {
                            Value = Vector3.one
                        });
                    }

                    if (entityManager.HasComponent(instance, typeof(RotationEulerXYZ)))
                    {
                        entityManager.SetComponentData(instance, new RotationEulerXYZ());
                    }
                    else
                    {
                        entityManager.AddComponentData(instance, new RotationEulerXYZ());
                    }


                    float offset = 1.0f - Vector2.Distance(new Vector2(x, y), c) / c.magnitude;
                    offset *= height;

                    float tx = timeOffsetX * Mathf.Min(Mathf.Abs(CountX - x), x);
                    float ty = timeOffsetY; // * Mathf.Abs(y - halfY);// * Mathf.Min(Mathf.Abs(CountY - y), y);

                    Tween.Delay((tx + ty), () =>
                    {
//
                        Tween.MoveEntity(instance, moveProp.duration,
                                         position + Vector3.up * offset, position,
                                         moveProp.easeType, moveProp.loop, moveProp.pinPong, x);

                        Tween.ScaleEntity(instance, scaleProp.duration,
                                          Vector3.one * 0.01f, Vector3.one,
                                          scaleProp.easeType, scaleProp.loop, scaleProp.pinPong, x);

                        Tween.RotateEntity(instance, rotateProp.duration,
                                           new Vector3(-30, 0, 0) * Mathf.Deg2Rad,
                                           new Vector3(60, 360, 0) * Mathf.Deg2Rad,
                                           rotateProp.easeType, rotateProp.loop, rotateProp.pinPong, x);
                    });
                }
            }
        }
コード例 #11
0
    protected override void OnUpdate()
    {
        float3 closestEntityPosition = Vector3.negativeInfinity;
        var    entityPositions       = new Dictionary <Entity, float3>();
        var    playerHp = 0;

        Entities.With(_EnemyQuery).ForEach(
            (Entity entity, ref Translation translation, ref HealthData hp) =>
        {
            entityPositions.Add(entity, translation.Value);
            playerHp = hp.Value;
        });

        Entities.With(_PlayerQuery).ForEach(
            (Entity entity, ref Translation translation, ref HealthData hp) =>
        {
            entityPositions.Add(entity, translation.Value);
            playerHp = hp.Value;
        });

        if (playerHp <= 0)
        {
            return;
        }

        Entities.With(_EnemyQuery).ForEach(
            (Entity entity, ref Translation translation, ref HealthData hp) =>
        {
            if (hp.Value > 0 && !_TweenRecord.Contains(entity))
            {
                var position    = translation.Value;
                Vector3 heading = default;
                float magnitude;

                foreach (var entityPosition in entityPositions)
                {
                    if (entityPosition.Key.Index != entity.Index)
                    {
                        var currentEntityMagnitude = ((Vector3)(entityPosition.Value - position)).magnitude;
                        heading   = closestEntityPosition - position;
                        magnitude = heading.magnitude;

                        if (currentEntityMagnitude < magnitude)
                        {
                            closestEntityPosition = entityPosition.Value;
                        }
                    }
                }

                heading   = closestEntityPosition - position;
                magnitude = heading.magnitude;

                if (magnitude < 5)
                {
                    _TweenRecord.Add(entity);
                    var damageObject = Object.Instantiate(HeraldsBootstrap.Settings.DamagePrefab,
                                                          closestEntityPosition + new float3(
                                                              Random.Range(-MaxShootOffset, MaxShootOffset),
                                                              0,
                                                              Random.Range(-MaxShootOffset, MaxShootOffset)), Quaternion.identity);
                    damageObject.GetComponent <Attacker>().SetSource(entity);
                    Tween.Delay(
                        Random.Range(HeraldsBootstrap.Settings.EnemyMinShootingDelay, HeraldsBootstrap.Settings.EnemyMaxShootingDelay),
                        () => { _TweenRecord.Remove(entity); });
                }
            }
        });
    }
コード例 #12
0
    protected override void OnUpdate()
    {
        float3 closestEntityPosition = Vector3.negativeInfinity;
        var    entityPositions       = new Dictionary <Entity, float3>();
        var    playerHp = 0;

        Entities.With(enemyQuery).ForEach(
            (Entity entity, ref Translation translation, ref HealthData hp) =>
        {
            entityPositions.Add(entity, translation.Value);
            playerHp = hp.Value;
        });

        Entities.With(playerQuery).ForEach(
            (Entity entity, ref Translation translation, ref HealthData hp) =>
        {
            entityPositions.Add(entity, translation.Value);
            playerHp = hp.Value;
        });

        if (playerHp <= 0)
        {
            return;
        }

        float3 zonePosition = Vector3.zero;
        var    zoneDistance = 0f;

        Entities.With(zoneQuery).ForEach(
            (Entity entity, ref Translation translation, ref NonUniformScale scale) =>
        {
            zonePosition = translation.Value;
            zoneDistance = scale.Value.x;
        });

        var timeToMove = HeraldsBootstrap.Settings.PlayerMoveSpeed;

        Entities.With(enemyQuery).ForEach(
            (Entity entity, Rigidbody rigidBody, ref Translation translation, ref HealthData hp, ref CollisionData collisionData) =>
        {
            if (hp.Value > 0)
            {
                var position    = translation.Value;
                Vector3 heading = default;
                float magnitude;

                foreach (var entityPosition in entityPositions)
                {
                    if (entityPosition.Key != entity)
                    {
                        var currentEntityMagnitude = ((Vector3)(entityPosition.Value - position)).magnitude;
                        heading   = closestEntityPosition - position;
                        magnitude = heading.magnitude;

                        if (currentEntityMagnitude < magnitude)
                        {
                            closestEntityPosition = entityPosition.Value;
                        }
                    }
                }

                heading   = closestEntityPosition - position;
                magnitude = heading.magnitude;

                if (magnitude < 5)
                {
                    rigidBody.transform.LookAt(closestEntityPosition);
                }
                else
                {
                    rigidBody.transform.LookAt(zonePosition);
                }

                if (!_TweenRecord.Contains(entity) && hp.Value > 0)
                {
                    bool wasSorted;

                    if (magnitude < 5)
                    {
                        if (magnitude > 1.5f)
                        {
                            wasSorted = true;
                            _MovementVectors.Sort((v1, v2) =>
                                                  (v1 + (Vector3)position - (Vector3)closestEntityPosition).sqrMagnitude.CompareTo(
                                                      (v2 + (Vector3)position - (Vector3)closestEntityPosition).sqrMagnitude));
                        }
                        else
                        {
                            wasSorted = Random.Range(0, 100) > 90;
                        }
                    }
                    else
                    {
                        wasSorted = true;
                        _MovementVectors.Sort((v1, v2) =>
                                              (v1 + (Vector3)position - (Vector3)zonePosition).sqrMagnitude.CompareTo(
                                                  (v2 + (Vector3)position - (Vector3)zonePosition).sqrMagnitude));
                    }

                    if (wasSorted)
                    {
                        Vector2 move;
                        Vector3 movement;
                        Vector3 newPos = default;
                        var condition  = false;

                        for (var i = 0; i < _MovementVectors.Count; i++)
                        {
                            condition = false;
                            move      = new Vector2(_MovementVectors[i].x, _MovementVectors[i].z);
                            movement  = new Vector3(Mathf.RoundToInt(move.x), 0, Mathf.RoundToInt(move.y));
                            newPos    = new Vector3(Mathf.RoundToInt(position.x), 0f, Mathf.RoundToInt(position.z)) +
                                        movement;

                            unsafe
                            {
                                condition = collisionData.CollisionMatrix[
                                    Mathf.RoundToInt(move.x) + 1 + (-Mathf.RoundToInt(move.y) + 1) * 3];
                            }

                            if (!condition)
                            {
                                break;
                            }
                        }

                        EntityManager.SetComponentData(entity, new CollisionData());

                        if (!condition)
                        {
                            EntityManager.SetComponentData(entity, new Translation {
                                Value = newPos
                            });

                            _TweenRecord.Add(entity);
                            Tween.MoveGameObject(rigidBody.gameObject, timeToMove, newPos, EaseType.easeInOutQuint)
                            .OnTweenComplete(() =>
                            {
                                Tween.Delay(
                                    magnitude > 4
                                                ? Random.Range(HeraldsBootstrap.Settings.EnemyMovePauseOutsideRange.x, HeraldsBootstrap.Settings.EnemyMovePauseOutsideRange.y)
                                                : Random.Range(HeraldsBootstrap.Settings.EnemyMinMovePause, HeraldsBootstrap.Settings.EnemyMaxMovePause),
                                    () => { _TweenRecord.Remove(entity); });
                            });
                        }
                    }
                }
            }
        });
    }
コード例 #13
0
ファイル: TweenMoveTest.cs プロジェクト: pzagora/ECS-Heralds
 void Awake()
 {
     Tween.Delay(delay,
                 () => { Tween.MoveGameObject(gameObject, duration, transform.position + target, ease, isLoop ? -1 : 0, isPingPong); });
 }
コード例 #14
0
 void DelayAction(float delay, Action action)
 {
     Tween
     .Delay(delay, action)
     .Start();
 }
コード例 #15
0
    void Next()
    {
        if (!isPlaying)
        {
            return;
        }
        if (index >= nodes.Length)
        {
            playedCount++;

            // finished
            index = 0;
            if (playCount > 0 && playCount <= playedCount)
            {
                isPlaying = false;
                if (onComplete != null)
                {
                    onComplete();
                }
                return;
            }
        }

        Node      node = nodes[index++];
        Transform t    = node.transform == null ? transform : node.transform;

        tween = null;

        switch (node.action)
        {
        case Action.Activate:
            t.gameObject.SetActive(node.active);
            break;

        case Action.Wait:
            tween = Tween.Delay(node.time + node.delay, null).Target(this);
            break;

        case Action.Run:
            if (t != null)
            {
                TweenPath[] pathes = t.GetComponents <TweenPath>();
                foreach (TweenPath tp in pathes)
                {
                    if (tp.pathName == node.runName)
                    {
                        tp.Play();
                        break;
                    }
                }
            }
            break;

        case Action.Move:
            if (node.time == 0 && node.delay == 0)
            {
                t.localPosition = node.position;
            }
            else
            {
                tween = Tween.Move(t, node.time, node.delay).To(node.position);
                ((Tween.TweenMove)tween).SetSnap(snap);
            }
            break;

        case Action.Rotate:
            if (node.time == 0 && node.delay == 0)
            {
                t.localEulerAngles = node.position;
            }
            else
            {
                tween = Tween.Rotate(t, node.time, node.delay).To(node.position);
            }
            break;

        case Action.Scale:
            if (node.time == 0 && node.delay == 0)
            {
                t.localScale = node.position;
            }
            else
            {
                tween = Tween.Scale(t, node.time, node.delay).To(node.position);
            }
            break;
        }

        if (tween != null)
        {
            tween.Ease(node.easeType);
            if (tweenTag != null)
            {
                tween.Tags(tweenTag);
            }
            if (node.waitForEnd)
            {
                tween.OnComplete(Next);
            }
            tween.Start();
        }
        if (tween == null || !node.waitForEnd)
        {
            Next();
        }
    }
コード例 #16
0
 public AnimDoTween(Tween tween)
 {
     this._tween = tween;
     _duration   = tween.Delay() + tween.Duration();
 }
コード例 #17
0
 /// <summary>
 /// Delay this instance.
 /// </summary>
 public float Delay()
 {
     return(tween.Delay());
 }