示例#1
0
    public void PlayAniGroup(Dictionary <int, DismantleAni> aniConfig, Transform stepParent, bool isEndActiveTogether, bool canForward = true, bool isForward = true)
    {
        if (!canForward)
        {
            isForward = true;
        }

        group = new AnimationGroup(stepParent, isForward);
        group.isEndActiveTogether = isEndActiveTogether;
        group.endActive           = aniConfig[0].endActive;

        Ani ani;

        foreach (var item in isForward == false ? aniConfig.Reverse() : aniConfig)
        {
            ani = new Ani(item.Value.EAni, stepParent.GetChild(item.Value.ID), item.Value.endPosOri,
                          item.Value.distance, item.Value.duration);
            ani.startActive = item.Value.startActive;
            ani.endActive   = item.Value.endActive;
            ani.count       = item.Value.count;
            ani.isForward   = isForward;

            group.AddGroup(ani, item.Value.isInsertLast, item.Value.insertDuration);
        }

        if (func != null)
        {
            group.OnComplete(func);
        }

        group.Play();
    }
示例#2
0
    private IEnumerator MeleeAttack()
    {
        IsAttack = true;
        IsChase  = false;
        yield return(new WaitForSeconds(0.25f));

        Ani.SetBool("isAttack", true);
        yield return(new WaitForSeconds(0.15f));

        AttackObject attack = GameManager.Instance.Pooling.GetAttackObject(PoolManager.AttackObjectList.MonsterMeleeAttack);

        attack.transform.SetParent(transform);
        attack.transform.localPosition = Vector3.zero;
        attack.transform.rotation      = transform.rotation;
        var attackInfo = new AttackInfo(this, Atk * MeleeAttackDamage, 0, "Player", transform.position, int.MaxValue,
                                        (HitInfo info) => { GameManager.Instance.Effect.HitEffect(info.HitUnit.transform.position); });

        attack.SetAttackInfo(attackInfo, AttackObject.IgnoreType.IgnoreWallAndFloor);
        attack.SetTimer(0.25f, InstantObject.TimerAction.Destory);
        yield return(new WaitForSeconds(1.85f));

        //공격 후딜레이
        yield return(new WaitForSeconds(0.25f));

        Ani.SetBool("isAttack", false);
        IsAttack = false;
        IsChase  = true;
    }
示例#3
0
 private void Update()
 {
     Ani.SetBool(m_MovingKey, Mathf.Abs(Movement.AimSpeed) > 0.01f);
     Ani.SetBool(m_JumpingKey, !Movement.IsGrounded && Mathf.Abs(Movement.SpeedY) > 0.1f);
     Ani.SetFloat(m_SpeedYKey, Movement.SpeedY);
     Ani.SetFloat(m_AttackingKey, Time.time > Attackness.NextAttackTime + 0.1f ? 0f : 1f);
 }
 public static Ani<Rect> BoundingBox(this Ani<Rect> rect1, Ani<Rect> rect2)
 {
     return rect1.Combine(rect2,
                          (r1, r2) => new Rect(
                              new Point(r1.X.Min(r2.X), r1.Y.Min(r2.Y)),
                              new Point(r1.Right.Max(r2.Right), r1.Bottom.Max(r2.Bottom))));
 }
示例#5
0
        private void Update()
        {
            Ani.SetFloat("SquatInex", Movement.IsSquating ? 1f : 0f);
            Ani.SetFloat("GrabIndex", Movement.GrabingPose == CharacterMovement.GrabPose.Top ? 1f : 0f);
            Ani.SetBool("IsGrounded", Movement.IsGrounded);
            Ani.SetBool("IsDushing", Movement.IsDushing && Movement.DushSpeedMuti > 0f);
            Ani.SetBool("IsGrabing", Movement.IsGrabing);
            Ani.SetFloat("Speed", Mathf.Abs(Movement.IsGrabing && Movement.GrabingPose != CharacterMovement.GrabPose.Top ? Movement.AimVelocity.y : Movement.AimVelocity.x));
            Ani.SetFloat("SpeedY", Movement.Velocity.y);


            if (Movement.IsGrounded && Mathf.Abs(Movement.AimVelocity.x) > 0.1f)
            {
                m_FootstepParticleRoot.gameObject.SetActive(true);
                if (Time.time > _LastFootstepTime + m_FootstepGap)
                {
                    _LastFootstepTime       = Time.time;
                    m_FootstepSource.volume = Random.Range(0.25f, 0.5f);
                    m_FootstepSource.pitch  = Random.Range(0.7f, 1f);
                    if (Movement.IsSquating)
                    {
                        m_FootstepSource.volume *= 0.1f;
                    }
                    m_FootstepSource.Play();
                }
            }
            else
            {
                m_FootstepParticleRoot.gameObject.SetActive(false);
            }
        }
示例#6
0
            void Update()
            {
                if (IsLive && !isExtra)
                {
                    float dis = Vector3.Distance(TargetTr.position, this.transform.position);

                    //공격 범위보다 멀리 있으면
                    //플레이어 추적
                    if (dis > attackDis)
                    {
                        Tracking();
                    }

                    if (dis <= attackDis)
                    {
                        Attack();
                    }
                }

                else if (isExtra)
                {
                    voice.IdlePlay();
                    Ani.EatingAni(isEatAni);
                }

                if (!IsLive && Hp == 0 && !isDead)
                {
                    isDead = true;
                    Ani.RunAni(false);
                    nav.velocity  = Vector3.zero;
                    nav.isStopped = true;

                    Ani.DeadAni();
                }
            }
示例#7
0
 protected void AllStopAni()
 {
     CBaseAni[] Anis = gameObject.GetComponentsInChildren <CBaseAni>();
     foreach (var Ani in Anis)
     {
         Ani.StopAni();
     }
 }
示例#8
0
        void StateUpdate()
        {
            //      -missTime    -perTime     perTime   missTime
            //  none    |     good   |    per    |   good  |    miss
            if (State != NoteState.None)
            {
                return;
            }
            NoteState prevState = State;

            if (Stage.TheStageSetting.AutoPlay)
            {
                BeatOffset = 0f;
                State      = Stage.Time > this.Time ? NoteState.Perfect : NoteState.None;
                if (prevState != State)
                {
                    StageScore.AddScore(State);
                }
            }
            else if (Stage.Time - Time > Stage.TheStageSetting.MissTime)
            {
                BeatOffset = Stage.TheStageSetting.MissTime;
                State      = NoteState.Miss;
                if (prevState != State)
                {
                    StageScore.AddScore(State);
                }
            }
            else if (BeatOffset < -Stage.TheStageSetting.MissTime)
            {
                State = NoteState.None;
            }
            else if (BeatOffset < -Stage.TheStageSetting.PerfectTime)
            {
                State = NoteState.Good;
            }
            else if (BeatOffset < Stage.TheStageSetting.PerfectTime)
            {
                State = NoteState.Perfect;
            }
            else if (BeatOffset < Stage.TheStageSetting.MissTime)
            {
                State = NoteState.Good;
            }
            else
            {
                State = NoteState.Miss;
            }



            if (prevState != State)
            {
                Ani.SetTrigger(State.ToString());
            }
        }
示例#9
0
        public void SwicthAnimation(string _newAniName)
        {
            if (_isInit)
            {
                Ani.ResetTrigger(_aniParamName);
            }

            _aniParamName = _newAniName;
            Ani.SetTrigger(_aniParamName);
        }
示例#10
0
            /// <summary>
            /// 공격 범위 밖
            /// </summary>
            void Tracking()
            {
                //음성
                voice.IdlePlay();

                nav.isStopped   = false;
                nav.destination = TargetTr.position;

                Ani.RunAni(true);
                AttackCancle(); //공격 게이지(텍스트) 비활성화
            }
示例#11
0
            /// <summary>
            /// 공격 데미지 적용 타이밍
            /// </summary>
            /// <returns></returns>
            virtual protected IEnumerator AttackDelay()
            {
                delayTime  = 0;
                IsFire     = true;
                AttackWait = false;
                Ani.AttackAni();

                yield return(new WaitForSeconds(1.0f));

                IsFire = false;
            }
 public void Activate()
 {
     if (!Activated)
     {
         Activated = true;
         PlaySound("open2");//sounds better than the electronic switch.
         Ani.CurrentFrame = 1;
         Ani.SetImage();
         Ani.Update();
         Room.UnleashSecret();
     }
 }
示例#13
0
            /// <summary>
            /// 공격 범위에 들어오면 우선 정지
            /// 공격 상태에 따라 공격
            /// </summary>
            protected void Attack()
            {
                //음성
                voice.AttackPlay();

                nav.velocity  = Vector3.zero;
                nav.isStopped = true;

                Ani.RunAni(false);

                AttackDelayTime();
            }
示例#14
0
            protected override IEnumerator AttackDelay()
            {
                delayTime  = 0;
                IsFire     = true;
                AttackWait = false;
                Ani.AttackAni();

                //수류탄 던짐
                GreadeAttack();

                yield return(new WaitForSeconds(1.0f));

                IsFire = false;
            }
示例#15
0
        public override void Update()
        {
            var TD = Game.TM.CheckForTile(Position);

            if (TD != null && TD.solid && TD.visible && TD.opaque)
            {
            }
            else if (Alive)
            {
                Alive = false;
                CollectableItem P = new PointItem(Game);
                P.Position.CopyFrom(Position);
                P.collectionDelay /= 2;
                Game.AddEntity(P);
                if (Math.Random() < 0.15)
                {
                    P = new HealingItem(Game);
                    P.Position.CopyFrom(Position);
                    P.Vspeed           = -2;
                    P.collectionDelay /= 2;
                    Game.AddEntity(P);
                }
                return;
            }
            if (TD.CanSlope)
            {
                var redraw = false;
                if (TD.SlopeDirection != 0)
                {
                    redraw = true;
                }
                TD.CanSlope = false;
                if (redraw)
                {
                    TD.UpdateTile();
                }
            }
            if (Ani.Shadow > 0)
            {
                Ani.ImageSpeed = 0.25f;
            }
            else if (Ani.ImageSpeed > 0)
            {
                Ani.ImageSpeed   = 0;
                Ani.CurrentFrame = 0;
                Ani.SetImage();
            }
            base.Update();
        }
 public void ChangeAni(string animation, bool reset = false)
 {
     if (this.animation == animation)
     {
         return;
     }
     if (Ani == null)
     {
         Ani = new Animation(AnimationLoader.Get("images/enemies/mrghost" + animation));
     }
     else
     {
         Ani.ChangeAnimation(AnimationLoader.Get("images/enemies/mrghost" + animation), reset);
     }
     this.animation = animation;
 }
示例#17
0
    void Init()
    {
        _charcontrol = transform.GetComponent <CharacterController>();

        Module[] module = new Module[5];
        int      i      = 0;

        module[i++] = new Move();
        module[i++] = new Attack();
        module[i++] = new Ani();
        module[i++] = new CameraRot();
        module[i++] = new InputKey();

        foreach (Module j in module)
        {
            _list.Add(j);
        }
    }
    public void AddGroup(Ani ani, bool isInsertLast, float insertDuration)
    {
        ani.Play();

        if (!isEndActiveTogether)
        {
            ani.OnComplete();
        }

        if (isInsertLast)
        {
            sequence.Insert(insertDuration, ani.GetTween());
        }
        else
        {
            sequence.Append(ani.GetTween());
        }
    }
 public void ChangeAni(string animation, bool reset = false)
 {
     if (this.animation == animation)
     {
         return;
     }
     if (Ani == null)
     {
         Ani = new Animation(AnimationLoader.Get("images/cirno/" + animation));
     }
     else
     {
         Ani.ChangeAnimation(AnimationLoader.Get("images/cirno/" + animation), reset);
     }
     if (this.animation != "stand")
     {
         turntime = 0;
     }
     this.animation = animation;
 }
        // Token: 0x06000056 RID: 86 RVA: 0x0000621C File Offset: 0x0000441C
        public ePAnimation Clone(ePart eeP)
        {
            bool        isFakeTimer = this.IsFakeTimer;
            ePAnimation o;

            if (isFakeTimer)
            {
                o = new ePAnimation(new ePart(new Entity(EntityTypes.WayPoint)), this.DPos, this.DAngleLst.ToArray(), this.Looping, this.TimeLst.ToArray(), this.Axis);
            }
            else
            {
                o = new ePAnimation(eeP, this.DPos, this.DAngleLst.ToArray(), this.Looping, this.TimeLst.ToArray(), this.Axis);
            }
            foreach (ePAnimation Ani in this.Parellel_eAs)
            {
                ePAnimation ClA = Ani.Clone(eeP);
                ClA.ChildRotationGradient = Ani.ChildRotationGradient;
                o.Parellel_eAs.Add(ClA);
            }
            return(o);
        }
    protected override void OnOpen(object param = null)
    {
        base.OnOpen(param);
        mFillSprite.fillAmount = 1;
        foreach (var Ani in mAchieveAniList)
        {
            Ani.gameObject.SetActive(true);
            Ani.Reset();
            Ani.Stop();
            Ani.onFinished += OnAniFinish;
        }

        ChallengeModule    module = ModuleManager.Instance.FindModule <ChallengeModule>();
        ChallengeTableItem item   = module.GetChallengeTableItem(module.GetCurFloor());

        mFastTime = item.mAchieveParamOne;
        mMidTime  = item.mAchieveParamTwo;
        mSlowTime = item.mAchieveParamThree;

        State = 0;
    }
示例#22
0
        private void Update()
        {
            // Animation
            Ani.SetBool(m_MovingKey, Mathf.Abs(Movement.AimSpeed) > 0.01f);

            // Attacking
            if (m_Renderer)
            {
                bool attacking = Time.time < Attackness.PrevAttackTime + 0.1f;
                if (attacking != m_PrevAttacking)
                {
                    m_PrevAttacking = attacking;
                    m_Renderer.transform.localScale    = Vector3.one * (attacking ? Random.Range(m_AttackScaleMuti.x, m_AttackScaleMuti.y) : 1f);
                    m_Renderer.transform.localRotation = Quaternion.Euler(0f, 0f, attacking ? Random.Range(m_AttackRotationMuti.x, m_AttackRotationMuti.y) : 0f);
                }
            }

            // HP Color
            if (m_Renderer && m_Health)
            {
                m_Renderer.color = Color.Lerp(m_HPColorRed, m_HPColorGreen, m_Health.HP / m_Health.MaxHP);
            }
        }
示例#23
0
    private IEnumerator Shot()
    {
        IsAttack = true;
        IsChase  = false;
        Ani.SetBool("isAttack", true);
        yield return(new WaitForSeconds(0.4f));

        AttackObject missile = GameManager.Instance.Pooling.GetAttackObject(PoolManager.AttackObjectList.Missile);

        missile.transform.position = transform.position;
        missile.transform.rotation = transform.rotation;
        var attackInfo = new AttackInfo(this, Atk * MissileDamage, 0, "Player", transform.position, 1, (HitInfo info) => { GameManager.Instance.Effect.ExplosionEffect(info.HitPosition + Vector3.up * 2); });

        missile.SetAttackInfo(attackInfo);
        missile.BulletFire(MissileSpeed, MissileRange);
        yield return(new WaitForSeconds(0.7f));

        //공격 후딜레이
        yield return(new WaitForSeconds(1f));

        Ani.SetBool("isAttack", false);
        IsAttack = false;
        IsChase  = true;
    }
 public static Animation ShowMatrixMultiplication(TimeSpan period,
                                             Rect pos,
                                             ComplexMatrix u,
                                             ComplexVector v,
                                             Ani<Brush> or,
                                             Ani<Brush> blu,
                                             Ani<Brush> bla)
 {
     var d = Math.Min(pos.Width/(u.Columns.Count + 2), pos.Height/u.Rows.Count)/2;
     pos = new Rect(pos.TopLeft, new Size(d * (u.Columns.Count + 2)*2, d*u.Rows.Count*2));
     var ur = d;
     var animation = new Animation {
         new RectDesc(new Rect(pos.X + d * 2, pos.Y, pos.Width - d * 4, pos.Height),
                      Brushes.Black,
                      strokeThickness: 0.6,
                      dashed: 5),
         new RectDesc(new Rect(pos.X, pos.Y, d * 2, pos.Height),
                      Brushes.Black,
                      strokeThickness: 0.6,
                      dashed: 5),
         new RectDesc(new Rect(pos.Right - d*2, pos.Y, d * 2, pos.Height),
                      Brushes.Black,
                      strokeThickness: 0.6,
                      dashed: 5)
     };
     var per = animation.Periodic(period);
     var s0 = per.LimitedSameTime(0.Seconds(), period.DividedBy(4));
     foreach (var r in u.Rows.Count.Range()) {
         var pp = s0.Proper;
         // input vector
         var p1 = pos.TopLeft + new Vector(d, d + r*d*2);
         var p2 = pos.TopLeft + new Vector(d*3 + r*d*2, 0);
         var p3 = pos.TopLeft + new Vector(d*3 + r*d*2, u.Rows.Count*d*2);
         s0.Add(ShowComplex(pp.Combine(blu, (p, b) => b.LerpToTransparent(p.SmoothTransition(0, 0, 1))),
                            pp.Combine(bla, (p, b) => b.LerpToTransparent(p.SmoothTransition(0, 0, 1))),
                            v.Values[r],
                            pp.Select(p => p.SmoothTransition(p1, p1, p2, p3)),
                            ur,
                            rotation: pp.Select(t => Turn.FromNaturalAngle(t.SmoothTransition(0, Math.PI/2, Math.PI/2)))));
         foreach (var c in u.Columns.Count.Range()) {
             // vector copied into matrix
             s0.Add(ShowComplex(pp.Combine(blu, (p, b) => b.LerpToTransparent(p.SmoothTransition(1, 1, 0))),
                                pp.Combine(bla, (p, b) => b.LerpToTransparent(p.SmoothTransition(1, 1, 0))),
                                v.Values[c],
                                (pos.TopLeft + new Vector(d*3 + c*d*2, d + r*d*2)),
                                ur,
                                Brushes.Transparent,
                                rotation: Turn.FromNaturalAngle(Math.PI/2)));
             // matrix
             s0.Add(ShowComplex(pp.Combine(or, (p, b) => b.LerpToTransparent(p.SmoothTransition(0, 0, 0))),
                                pp.Combine(bla, (p, b) => b.LerpToTransparent(p.SmoothTransition(0, 0, 0))),
                                u.Rows[r][c],
                                (pos.TopLeft + new Vector(d*3 + c*d*2, d + r*d*2)),
                                ur));
         }
     }
     var s1 = per.LimitedSameTime(period.Times(0.25), period.Times(0.5));
     foreach (var r in u.Rows.Count.Range()) {
         foreach (var c in u.Columns.Count.Range()) {
             s1.Add(
                 ShowComplexProduct(
                     blu,
                     or,
                     bla,
                     bla,
                     v.Values[c],
                     u.Rows[r][c],
                     (pos.TopLeft + new Vector(d*3 + c*d*2, d + r*d*2)),
                     ur,
                     s1.Proper));
         }
     }
     var s2 = per.LimitedSameTime(period.Times(0.5), period);
     foreach (var r in u.Rows.Count.Range()) {
         s2.Add(
             ShowComplexSum(
                 blu,
                 blu,
                 bla,
                 u.Rows[r].Count.Range()
                          .Select(e => u.Rows[r][e]*v.Values[e])
                          .Select(e => new ConstantAni<Complex>(e)),
                 (pos.TopLeft + new Vector(d*3, d + r*d*2)),
                 (pos.TopLeft + new Vector(d*3 + u.Columns.Count*d*2, d + r*d*2)),
                 new Vector(d*2, 0),
                 ur,
                 s2.Proper));
     }
     return animation;
 }
        private static Animation MakeTransformAnimation(Point center, IEnumerable<Complex> input, Ani<ComplexMatrix> transform, string[] labels = null)
        {
            var vector = new ComplexVector(input);
            var aniValues = from m in transform
                            select (m * vector).Values;
            var valuesAni = vector.Values.Count.Range().Select(i => from values in aniValues
                                                                    select values[i]);
            var colors = new[] { 0x3366CC, 0xdc3912, 0xff9900, 0x109618, 0x990099, 0x0099c6, 0xdd4477, 0x66aa00,
                                 0xb82e2e, 0x316395, 0x994499, 0x22aa99, 0xaaaa11, 0x6633cc, 0xe67300, 0x8b0707}
                .Select(e => Color.FromRgb((byte)(e >> 16), (byte)(e >> 8), (byte)(e >> 0)))
                .Select(e => new SolidColorBrush(e))
                .Cast<Brush>()
                .ToArray();

            labels = labels ?? new[] { "c₁", "c₂", "c₃", "c₄", "c₅", "c₆", "c₇", "c₈", "c₉", "c₁₀", "c₁₁", "c₁₂", "c₁₃", "c₁₄", "c₁₅", "c₁₆" };
            var labelledAniValues = labels
                .Zip(valuesAni, (label, v) => new KeyValuePair<string, Ani<Complex>>(label, v))
                .ToDictionary(e => e.Key, e => e.Value);
            var ani = new Animation {
                MakeSuperpositionAnimation(
                    center,
                    labelledAniValues,
                    colors)
            };
            return ani;
        }
        private static Animation CreateNetworkAnimation(Animation animation, Ani<GraphMessages> state, Lifetime life)
        {
            // --- end points
            // timeline
            animation.LinkMany(
                state.Select(s => s.Graph.EndPoints.Select(
                    p => new LineSegmentDesc(
                             new Point(s.Graph.GetX(p.Skew), s.Graph.GetY(p)).Sweep(new Vector(1000, 0)),
                             Brushes.Black,
                             3))),
                life);
            // timeline label
            animation.LinkMany(
                state.Select(s => s.Graph.EndPoints.Select(
                    p => new TextDesc(
                             text: p.Name,
                             pos: new Point(s.Graph.GetX(p.Skew), s.Graph.GetY(p)),
                             fontWeight: FontWeights.Bold,
                             reference: new Point(1.1, 0.5)))),
                life);
            // tick marks
            animation.LinkMany(
                state.Select(s => s.Graph.EndPoints.SelectMany(
                    p => 10.Range().Select(
                        j => new LineSegmentDesc(
                                 new Point(s.Graph.GetX(p.Skew + j.Seconds()), s.Graph.GetY(p) - 5).Sweep(new Vector(0, 10)),
                                 Brushes.Black,
                                 2)))),
                life);
            // tick labels
            animation.LinkMany(
                state.Select(s => s.Graph.EndPoints.SelectMany(
                    p => 10.Range().Select(
                        j => new TextDesc(
                                 text: (j + "s"),
                                 pos: new Point(s.Graph.GetX(p.Skew + j.Seconds()), s.Graph.GetY(p) - 5) + new Vector(0, -2),
                                 fontSize: 10)))),
                life);

            // --- measurements
            var measurements =
                from s in state
                select from m in s.Measurements
                       let x1 = s.Graph.GetX(m.X1)
                       let y1 = s.Graph.GetY(m.V1)
                       let x2 = s.Graph.GetX(m.X2)
                       let y2 = s.Graph.GetY(m.V2)
                       let y = m.Y ?? ((y1 + y2)/2)
                       select new {s, m, x1, y1, x2, y2, y};
            animation.LinkMany(
                measurements.LiftSelect(
                    e => new LineSegmentDesc(
                             new LineSegment(new Point(e.x1, e.y), new Point(e.x2, e.y)),
                             Brushes.Black,
                             2,
                             1)),
                life);
            animation.LinkMany(
                measurements.LiftSelect(
                    e => new LineSegmentDesc(
                             new LineSegment(new Point(e.x1, e.y1), new Point(e.x1, e.y)),
                             Brushes.Red,
                             dashed: 1)),
                    life);
            animation.LinkMany(
                measurements.LiftSelect(
                    e => new LineSegmentDesc(
                             new LineSegment(new Point(e.x2, e.y2), new Point(e.x2, e.y)),
                             Brushes.Red,
                             dashed: 1)),
                    life);
            var off1 = new Vector(5, -5);
            var off2 = new Vector(5, 12);
            animation.LinkMany(
                measurements.LiftSelect(
                    e => new TextDesc(
                        text: e.m.Text,
                        pos: new Point(Math.Max(e.x1, e.x2), e.y) + off1.Rotate(e.m.Angle),
                        direction: e.m.Angle)),
                    life);
            animation.LinkMany(
                measurements.LiftSelect(
                    e => new TextDesc(
                             text: string.Format("{0:0.00}s", (e.m.X2 - e.m.X1).TotalSeconds),
                             pos: new Point(Math.Max(e.x1, e.x2), e.y) + off2.Rotate(e.m.Angle),
                             direction: e.m.Angle)),
                life);

            // messages
            animation.LinkMany(
                state.Select(e => e.Messages).LiftSelect(
                    e => new LineSegmentDesc(
                             e.Pos,
                             Brushes.Black)),
                life);
            animation.LinkMany(
                state.Select(e => e.Messages.SelectMany(
                    m => new[] {m.PosSourcePoint, m.PosEndPoint}.Select(
                        p => new PointDesc(
                                 p,
                                 Brushes.Transparent,
                                 Brushes.Black,
                                 3,
                                 0)))),
                life);
            animation.LinkMany(
                state.Select(e => e.Messages).LiftSelect(
                    e => new TextDesc(
                             text: "-> " + e.Text + " ->",
                             pos: e.Pos.LerpAcross(0.1),
                             fontSize: 10,
                             direction: Dir.FromVector(e.Pos.Delta.X, e.Pos.Delta.Y),
                             foreground: Brushes.Gray)),
                life);

            return animation;
        }
示例#27
0
    //Start animation sequence
    public bool StartAnimation(Ani.Animate Mode, GameObject CallbackObj, object CallbackMsg, object CallbackParams)
    {
        //Start animation is we're not already animating
        if (mAnimating == false)
        {
            //Must be active to start coroutine
            gameObject.active = true;

            mAnimating = true;
            mCallbackObj = CallbackObj;
            mCallbackMsg = (string) CallbackMsg;
            mCallbackParams = CallbackParams;
            mAnimateMode = Mode;
            StartCoroutine(AnimateEngine());
            return true;
        }

        return false;
    }
示例#28
0
            private void Update()
            {
                if (IsLive)
                {
                    //다음 위치로 이동
                    if (NextMove != null && !IsStop)
                    {
                        transform.position = Vector3.MoveTowards(transform.position,
                                                                 NextMove.position, Speed * Time.deltaTime);

                        isRun = true;
                    }


                    float dis = Vector3.Distance(targetTr.position, transform.position);


                    #region 이동 제어 변경 되어 사용 안함
                    //범위에서 벗어나면 이동 상태
                    //if (dis > grenadeDis)
                    //{
                    //    //Debug.Log("EnemyMove");
                    //    AttackCancle(); //공격 상태 초기화 ..이거 활성화 될때 초기화 되는거;;

                    //    IsStop = false;

                    //    if (NextMove != null)
                    //    {
                    //        transform.position = Vector3.MoveTowards(transform.position,
                    //                   NextMove.position, Speed * Time.deltaTime);
                    //    }

                    //    isRun = true;
                    //}
                    #endregion

                    //일반 공격 범위에서 벗어나고
                    //수류탄 공격 범위일때
                    if (dis > meleeDis && dis < grenadeDis)
                    {
                        // Debug.Log("Grenade");
                        AttackDelayTime(); //공격
                        transform.LookAt(new Vector3(targetTr.position.x, transform.position.y, targetTr.position.z));

                        ////수류탄 던짐
                        //GreadeAttack();

                        IsStop = true;
                        isRun  = false;
                    }

                    //일반 공격
                    if (dis < meleeDis)
                    {
                        // Debug.Log("Melee");

                        transform.LookAt(new Vector3(targetTr.position.x, transform.position.y, targetTr.position.z));
                        AttackDelayTime(); //공격
                        IsStop = true;
                        isRun  = false;
                    }
                }

                if (!IsLive && Hp == 0 && !isDead)
                {
                    isDead = true;
                    isRun  = false;

                    Ani.DeadAni();
                    stageManager.StageEnd();
                }

                Ani.RunAni(isRun);
            }
 // Save instance
 public void Awake()
 {
     Ani._mate = this;
 }
示例#30
0
 private static Animator<string> MakeTextAnimator(Ani<Brush> foreground = null, Ani<double> fontSize = null, Ani<FontWeight> fontWeight = null)
 {
     var t = new TextBlock();
     return (value, visible, topLeft) => Tuple.Create(
         new Animation {
             new TextDesc(
                 value.Combine(visible, (v1, v2) => v2 ? (v1 ?? "") : ""),
                 topLeft,
                 new Point(0,0),
                 fontSize: fontSize,
                 fontWeight: fontWeight,
                 foreground: foreground)
         },
         value.Select(e => {
             t.Text = e;
             t.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
             return t.DesiredSize;
         }));
 }
示例#31
0
 public static Ani<Rect> WithTopLeft(this Ani<Size> size, Ani<Point> point)
 {
     return size.Combine(point, (s, p) => new Rect(p, s));
 }
 private static Animation MakeScalingAnimation(Point center, IEnumerable<Complex> input, Ani<Complex> scale, Point? scalingTextPos = null)
 {
     var n = input.Count();
     var I = ComplexMatrix.MakeIdentity(n);
     var ani = new Animation {
         MakeTransformAnimation(center,
                                input,
                                from s in scale
                                select I*s)
     };
     if (scalingTextPos.HasValue) {
         ani.Add(new TextDesc(text: from s in scale
                                    select string.Format("Current Scale Factor =        = {0}",
                                                         s.Imaginary == 0
                                                             ? s.Real.ToString("0.0")
                                                             : s.ToPrettyString("0.0")),
                              pos: scalingTextPos));
         ani.Add(new RectDesc(
             new Rect(scalingTextPos.Value + new Vector(130, -5) + new Vector(-10, -5), new Size(20, 10)),
             stroke: from s in scale select s.Imaginary != 0 ? (Brush)Brushes.Transparent : Brushes.Black,
             strokeThickness: 1,
             dashed: 3));
         ani.Add(new RectDesc(
             from s in scale select new Rect(scalingTextPos.Value + new Vector(130, -5) + new Vector(s.Real.Min(0)*10, -5), new Size(s.Real.Abs()*10, 10)),
             fill: from s in scale select s.Imaginary != 0 ? (Brush)Brushes.Transparent : Brushes.Green));
         ani.Add(QuantumCircuit.ShowComplex(
             Brushes.Transparent,
             from s in scale select s.Imaginary == 0 ? (Brush)Brushes.Transparent : Brushes.Black,
             scale,
             scalingTextPos.Value + new Vector(130, -5),
             10,
             sweepFill: from s in scale select s.Imaginary == 0 ? (Brush)Brushes.Transparent : Brushes.Green,
             valueGuideStroke: from s in scale select s.Imaginary == 0 ? (Brush)Brushes.Transparent : Brushes.Black));
     }
     return ani;
 }
 private void OnisHoldingChange(bool holdingChange)
 {
     isHolding = holdingChange;
     Ani.SetBool("HoldingItem", isHolding);
 }
 public static Animation ShowMatrix(Rect pos,
                               ComplexMatrix u,
                               Ani<Brush> or,
                               Ani<Brush> bla)
 {
     var d = Math.Min(pos.Width / (u.Columns.Count +2), pos.Height / (u.Rows.Count)) / 2;
     pos = new Rect(pos.TopLeft, new Size(d * (u.Columns.Count + 2) * 2, d * u.Rows.Count * 2));
     var ur = d;
     return new Animation {
         new RectDesc(new Rect(pos.X + d*2, pos.Y, pos.Width - d*4, pos.Height),
                      Brushes.Black,
                      strokeThickness: 0.6,
                      dashed: 5),
         new RectDesc(new Rect(pos.X, pos.Y, d*2, pos.Height),
                      Brushes.Black,
                      strokeThickness: 0.6,
                      dashed: 5),
         new RectDesc(new Rect(pos.Right - d*2, pos.Y, d*2, pos.Height),
                      Brushes.Black,
                      strokeThickness: 0.6,
                      dashed: 5),
         // matrix
         u.Rows.Count.Range().SelectMany(
             r => u.Columns.Count.Range().Select(
                 c => ShowComplex(
                     or,
                     bla,
                     u.Rows[r][c],
                     (pos.TopLeft + new Vector(d*3 + c*d*2, d + r*d*2)),
                     ur)))
     };
 }
 public static Animation ShowComplex(Ani<Brush> fill,
                                 Ani<Brush> valueStroke,
                                 Ani<Complex> value,
                                 Ani<Point> position,
                                 Ani<double> unitRadius,
                                 Ani<Brush> valueGuideStroke = null,
                                 Ani<double> phaseOffset = null,
                                 Ani<Turn> rotation = null,
                                 Ani<Brush> sweepFill = null,
                                 Ani<double> squish = null,
                                 Ani<double> sweepScale = null)
 {
     phaseOffset = phaseOffset ?? 0;
     rotation = rotation ?? Turn.Zero;
     sweepFill = sweepFill ?? fill;
     squish = squish ?? 1.0;
     sweepScale = sweepScale ?? 0.5;
     var phaseRadius = from v in value
                       from s in sweepScale
                       select s * Math.Max(0.05, v.Magnitude);
     var mag = value.Select(e => e.Magnitude*e.Magnitude);
     return new Animation {
         new PolygonDesc(
             phaseOffset.Combine(value, position, unitRadius, phaseRadius, (o, v, p, r, f) => PhaseCurve(v.Phase, f * r, o).Select(e => e + p).ToArray().AsEnumerable()),
             stroke: sweepFill.Select(e => e.LerpTo(Brushes.Black, 0.5, lerpAlpha: false)),
             fill: sweepFill.Select(e => e.LerpToTransparent(0.5)),
             strokeThickness: value.Select(e => Math.Min(Math.Abs(e.Phase)*10,Math.Min(e.Magnitude*3,1)))),
         new RectDesc(
             pos: position.Combine(unitRadius, (e, r) => new Rect(e.X - r, e.Y - r, 2*r, 2*r)),
             stroke: valueGuideStroke ?? valueStroke,
             strokeThickness: 0.5,
             dashed: 4,
             rotation: rotation,
             rotationOrigin: new Point(0.5, 0.5)),
         // squared magnitude filling
         new RectDesc(
             pos: position.Combine(unitRadius, mag, squish, (e, r, v, s) => new Rect(e.X - r, e.Y + (1 - 2 * v) * r, 2 * r * s, 2 * r * v)),
             fill: fill,
             rotation: rotation,
             rotationOrigin: mag.Combine(squish, (v,s) => new Point(s < 0.001 ? 0 : (1/s)/2, 1 - 0.5/v))),
         // current value arrow
         Arrow(position,
               value.Combine(phaseOffset, (e, p) => e*Complex.Exp(Complex.ImaginaryOne*p))
                    .Combine(unitRadius, (v, r) => r*new Vector(v.Real, -v.Imaginary)),
               stroke: valueStroke)
     };
 }
示例#36
0
    //Start animation sequence
    public bool StartAnimation(Ani.Animate ModeType, GameObject CallbackObj, object CallbackMsg, object CallbackParams)
    {
        //Start animation is we're not already animating
        if (mAnimating == false)
        {
            mAnimating = true;
            mCallbackObj = CallbackObj;
            mCallbackMsg = (string) CallbackMsg;
            mCallbackParams = CallbackParams;
            mAnimateMode = ModeType;
            StartCoroutine(Animator());
            return true;
        }

        return false;
    }
示例#37
0
 // Save instance
 public void Awake()
 {
     Ani._mate = this;
 }
        private static Animation MakeSuperpositionAnimation(Ani<Point> aniCenter, IReadOnlyDictionary<string, Ani<Complex>> vector, Brush[] colors)
        {
            var tau = 2*Math.PI;
            var aniVector =
                (from keyVal in vector
                 select from component in keyVal.Value
                        select new {
                            label = keyVal.Key,
                            value = new Complex(component.Real, -component.Imaginary),
                            scale = component.Magnitude < 0.1 ? component.Magnitude * 10 : 1
                }).ToArray()
                 .AniAll();
            var aniStartingPhase = from component in aniVector
                                   select (from e in component
                                           where e.value.Magnitude > 0
                                           select -e.scale * e.value / e.value.Magnitude
                                          ).Sum()
                                           .Phase;

            var aniBars =
                from component in aniVector
                from startingPhase in aniStartingPhase
                select component.Select((e, i) => new {
                    Label = e.label,
                    Width = 20*e.scale,
                    Height = e.value.Magnitude * (e.scale < 0.001 ? 0 : (100 / e.scale)),
                    Angle = e.value.Phase.ProperMod(tau),
                    Color = colors[i%colors.Length]
                }).OrderBy(e => (e.Angle - startingPhase).ProperMod(tau)).ToArray();

            var ani = new Animation();
            var c = 0;

            Func<double, Vector> angleToVector = theta => new Vector(Math.Cos(theta), Math.Sin(theta));

            var aniBorderDisplacements = from bars in aniBars
                                         select bars.Stream(
                                             default(Vector),
                                             (acc, bar) => acc + angleToVector(bar.Angle + tau/4)*bar.Width,
                                             streamSeed: true).ToArray();
            var aniAvgDisplacement = from borderDisplacements in aniBorderDisplacements
                                     select borderDisplacements.Average();

            var aniBorderPoints = from center in aniCenter
                                  from avgDisplacement in aniAvgDisplacement
                                  from borderDisplacements in aniBorderDisplacements
                                  select (from borderDisplacement in borderDisplacements
                                          select center + borderDisplacement - avgDisplacement).ToArray();
            foreach (var i in vector.Count.Range()) {
                var aniPt = from borderPoints in aniBorderPoints
                            select borderPoints[i];
                var aniBar = from bars in aniBars
                             select bars[i];
                var dw = from bar in aniBar
                         select angleToVector(bar.Angle + tau/4)*bar.Width;
                var dh = from bar in aniBar
                         select angleToVector(bar.Angle)*bar.Height;
                ani.Add(new PolygonDesc(pos: from pt in aniPt
                                             from w in dw
                                             from h in dh
                                             select new[] {
                                                 pt + w*c,
                                                 pt + w*(1 - c),
                                                 pt + w*(1 - c) + h,
                                                 pt + w*c + h
                                             }.AsEnumerable(),
                                        fill: from bar in aniBar
                                              select bar.Color));
                ani.Add(new TextDesc(text: from bar in aniBar
                                           select bar.Label,
                                     pos: from h in dh
                                          from w in dw
                                          from pt in aniPt
                                          select pt + h + w/2 + h.Normal()*5 - w.Normal()*2,
                                     reference: new Point(0, 0.5),
                                     fontSize: from bar in aniBar
                                               select bar.Width*1.2,
                                     direction: from bar in aniBar
                                                select Dir.FromNaturalAngle(bar.Angle)));
            }
            ani.Add(new PolygonDesc(aniBorderPoints.Select(e => e.AsEnumerable()), Brushes.Gray, 1, 2));
            return ani;
        }
 private void Update()
 {
     Ani.SetBool(m_MovingKey, Mathf.Abs(Movement.AimSpeed) > 0.01f);
     Ani.SetBool(m_JumpingKey, !Movement.IsGrounded && Mathf.Abs(Movement.SpeedY) > 0.1f);
     Ani.SetFloat(m_SpeedYKey, Movement.SpeedY);
 }
示例#40
0
 public static Ani<Rect> SweepRightAndDown(this Ani<Point> point, Ani<Size> size)
 {
     return size.Combine(point, (s, p) => new Rect(p, s));
 }
示例#41
0
 // Start is called before the first frame update
 void Start()
 {
     Life = 3;
     Ani.SetInteger("Life", Life);
 }
示例#42
0
        private static Animation MakeLinkAnimation(Ani<Rect> src, Ani<Rect?> dst)
        {
            var p1 = src.Select(e => new Point(e.Right, e.Top.LerpTo(e.Bottom, 0.5)));
            var p4 = src.Combine(dst, (s, d) => {
                var cy = d.GetValueOrDefault().Top.LerpTo(d.GetValueOrDefault().Bottom, 0.5);
                var sy = s.Top.LerpTo(s.Bottom, 0.5);

                return new Point(
                    d.GetValueOrDefault().Right,
                    cy + (sy-cy)/10);
            });
            var xmax = p1.Combine(p4, (e1, e2) => e1.X.Max(e2.X) + 10);

            var p2 = p1.Combine(xmax, (e, x) => new Point(x, e.Y));
            var p3 = p4.Combine(xmax, (e, x) => new Point(x, e.Y));
            var p3a = p4.Select(e => e + new Vector(2, 2));
            var p3b = p4.Select(e => e + new Vector(2, -2));
            var stroke = dst.Select(e => e.HasValue ? (Brush)Brushes.Black : Brushes.Transparent);
            return new Animation {
                new LineSegmentDesc(p1.Combine(p2, (e1, e2) => e1.To(e2)), stroke: stroke),
                new LineSegmentDesc(p2.Combine(p3, (e1, e2) => e1.To(e2)), stroke: stroke),
                new LineSegmentDesc(p3.Combine(p4, (e1, e2) => e1.To(e2)), stroke: stroke),
                new LineSegmentDesc(p3a.Combine(p4, (e1, e2) => e1.To(e2)), stroke: stroke),
                new LineSegmentDesc(p3b.Combine(p4, (e1, e2) => e1.To(e2)), stroke: stroke),
            };
        }
示例#43
0
        private void Open(PlayerCharacter player)
        {
            if (!Opened)
            {
                PlaySound("chestopen");
                Ani.CurrentFrame = 1;
                Ani.SetImage();
                Ani.Update();
                Opened = true;
                //TODO:give player a permanent upgrade, and display text above the chest telling the player what they just got
                var      M      = "";
                var      ok     = true;
                var      S      = "";
                var      color  = "#FFFFFF";
                string[] picker = null;
                while (ok)
                {
                    //var common = new string[] { "point", "point", "point", "point", "point", "point", "heart", "heart", "tripleheart", "singleorb" };
                    var common    = new string[] { "point", "point", "point", "point", "point", "point", "tripleheart" /*, "singleorb"*/ };
                    var rare      = new string[] { "attackpower", "defensepower", "mining" };
                    var legendary = new string[] { "triplejump", "cheaperblocks", "invincibility", "repeater", "movespeed" };

                    var heartTable = new string[] { "supertripleheart" };


                    var    R = Math.Random();
                    string C;
                    if (Heart)
                    {
                        C     = heartTable.Pick();
                        S     = "common";
                        color = "#FFFFFF";
                    }
                    else
                    {
                        if (picker == null || Math.Random() < 0.20)
                        {
                            //if (R < 0.60 && !Golden && !Premium)
                            var commonchance = 0.65 - (Game.level * 0.25);

                            /*if (Game.level > 5)
                             * {
                             *  commonchance *= 0.8;
                             *  if (Game.level > 10)
                             *  {
                             *      commonchance *= 0.8;
                             *  }
                             * }*/
                            if (R < commonchance && !Golden && !Premium)
                            {
                                picker = common;
                                S      = "common";
                                color  = "#FFFFFF";
                            }
                            else
                            {
                                R = Math.Random();
                                if (Premium)
                                {
                                    R += 0.04;//adds a 4% to the chance of a legendary power up.
                                }
                                if (R < 0.91)
                                {
                                    picker = rare;
                                    S      = "rare";
                                    color  = "#FFBB33";
                                }
                                else
                                {
                                    picker = legendary;
                                    S      = "legendary";
                                    color  = "#FF55FF";
                                }
                            }
                        }
                        if (true)
                        {
                            C = picker.Pick();
                        }
                        else
                        {
                            picker = legendary;
                            S      = "legendary";
                            color  = "#FF55FF";
                            C      = "movespeed";
                        }
                    }
                    ok = false;
                    CollectableItem CI;
                    switch (C)
                    {
                    case "point":
                        var P = new PointItem(Game);
                        P.Position.CopyFrom(Position);
                        P.Vspeed          = -2f;
                        P.Hspeed          = -2f;
                        P.collectionDelay = 30;
                        Game.AddEntity(P);

                        P = new PointItem(Game);
                        P.Position.CopyFrom(Position);
                        P.Vspeed          = -2f;
                        P.Hspeed          = 2f;
                        P.collectionDelay = 30;
                        Game.AddEntity(P);

                        M = "Points";

                        break;

                    case "heart":
                        if (player.HP >= player.maxHP)
                        {
                            ok = true;
                            break;
                        }
                        var H = new HealingItem(Game);
                        H.Position.CopyFrom(Position);
                        H.Vspeed          = -2f;
                        H.collectionDelay = 30;
                        Game.AddEntity(H);
                        M = "Heal";
                        break;

                    case "tripleheart":
                        if ((player.HP > player.maxHP / 3) && !Heart)
                        {
                            ok = true;
                            break;
                        }
                        var H1 = new HealingItem(Game);
                        H1.Position.CopyFrom(Position);
                        H1.Vspeed          = -2f;
                        H1.Hspeed          = -2f;
                        H1.collectionDelay = 30;
                        Game.AddEntity(H1);

                        H1 = new HealingItem(Game);
                        H1.Position.CopyFrom(Position);
                        H1.Vspeed          = -2f;
                        H1.Hspeed          = 0;
                        H1.collectionDelay = 30;
                        Game.AddEntity(H1);

                        H1 = new HealingItem(Game);
                        H1.Position.CopyFrom(Position);
                        H1.Vspeed          = -2f;
                        H1.Hspeed          = 2f;
                        H1.collectionDelay = 30;
                        Game.AddEntity(H1);
                        M = "Heal x3";
                        break;

                    case "supertripleheart":
                        if ((player.HP > player.maxHP / 3) && !Heart)
                        {
                            ok = true;
                            break;
                        }
                        H1 = new HealingItem(Game);
                        H1.Position.CopyFrom(Position);
                        H1.Vspeed          = -2f;
                        H1.Hspeed          = -2f;
                        H1.healingPower   *= 1.5f;
                        H1.collectionDelay = 30;
                        Game.AddEntity(H1);

                        H1 = new HealingItem(Game);
                        H1.Position.CopyFrom(Position);
                        H1.Vspeed          = -2f;
                        H1.Hspeed          = 0;
                        H1.healingPower   *= 1.5f;
                        H1.collectionDelay = 30;
                        Game.AddEntity(H1);

                        H1 = new HealingItem(Game);
                        H1.Position.CopyFrom(Position);
                        H1.Vspeed          = -2f;
                        H1.Hspeed          = 2f;
                        H1.healingPower   *= 1.5f;
                        H1.collectionDelay = 30;
                        Game.AddEntity(H1);
                        M = "Heal+";
                        break;

                    case "singleorb":
                        if (Game.timeRemaining > 0)
                        {
                            ok = true;
                            break;
                        }
                        CI = new Orb(Game);
                        CI.Position.CopyFrom(Position);
                        CI.Vspeed          = -2f;
                        CI.Hspeed          = -2f;
                        CI.collectionDelay = 30;
                        Game.AddEntity(CI);

                        /*CI = new Orb(Game);
                        *  CI.Position.CopyFrom(Position);
                        *  CI.Vspeed = -2f;
                        *  CI.Hspeed = 2f;
                        *  CI.collectionDelay = 30;
                        *  Game.AddEntity(CI);*/

                        M = "Orb";
                        break;

                    case "mining":
                        if (player.digpower < 2.0f)
                        {
                            player.digpower += 0.5f;
                        }
                        else
                        {
                            ok = true;
                        }
                        M = "Mining Power " + (player.digpower) + "x";
                        break;

                    case "triplejump":
                        var PC = player.GetBehavior <PlatformerControls>();
                        if (PC.maxAirJumps < 2)
                        {
                            PC.maxAirJumps = 2;
                        }
                        else
                        {
                            ok = true;
                        }
                        M = "Triple Jump";
                        break;

                    case "cheaperblocks":
                        if (player.blockprice != 3)
                        {
                            ok = true;
                            break;
                        }
                        player.blockprice = 1;
                        M = "Blocks are cheaper now";
                        break;

                    case "movespeed":
                        if (player.data.ContainsKey("movespeed"))
                        {
                            ok = true;
                            break;
                        }
                        player.data["movespeed"] = true;
                        var Plat = player.GetBehavior <PlatformerControls>();
                        Plat.maxSpeed *= 1.07f;
                        Plat.accel    *= 1.07f;
                        M              = "Movement speed+";
                        break;

                    case "invincibility":
                        if (player.invincibilitymod != 1)
                        {
                            ok = true;
                            break;
                        }
                        player.invincibilitymod = 2;
                        M = "Invincibility extended";
                        break;

                    case "attackpower":
                        player.attackpower += 1;
                        M = "Attack Power " + (int)(player.attackpower);
                        break;

                    case "defensepower":
                        player.defensepower += 1;
                        M = "Defensive Power " + (int)(player.defensepower);
                        break;

                    case "repeater":
                        if (player.totalshots > 2)
                        {
                            ok = true;
                            break;
                        }
                        player.totalshots += 1;
                        M = TupleNames[player.totalshots] + " shot";
                        break;

                    default:
                        ok = true;
                        break;
                    }
                }
                if (!ok && M != "")
                {
                    FloatingMessage FM = new FloatingMessage(Game, M);
                    FM.Text.TextColor = color;
                    //FM.Position = new Vector2(x - 8, y - 20);
                    FM.Position = new Vector2(x + 8, y - 20);
                    Game.AddEntity(FM);
                    if (S != "" && S != "common")
                    {
                        PlaySound("ok2B");
                    }
                    else
                    {
                        PlaySound("jump");
                    }
                }
            }
        }
 private static Animation Arrow(Ani<Point> start,
                                Ani<Vector> delta,
                                Ani<Brush> stroke = null,
                                Ani<double> thickness = null,
                                Ani<double> wedgeLength = null,
                                Ani<double> dashed = null)
 {
     wedgeLength = wedgeLength ?? 5;
     thickness = thickness ?? 1;
     return new Animation {
         new PointDesc(start, fill: stroke, radius: thickness.Select(e => e*0.5)),
         new LineSegmentDesc(
             pos: start.Combine(delta, (p, d) => new LineSegment(p, d)),
             stroke: stroke,
             thickness: thickness,
             dashed: dashed),
         new[] {+1, -1}.Select(
             s => new LineSegmentDesc(
                      pos: start.Combine(
                          delta,
                          wedgeLength,
                          (p, d, w) =>
                          new LineSegment(p + d, (s*d.Perp().Normal() - d.Normal()).Normal()*Math.Min(w, d.Length/2))),
                      stroke: stroke,
                      thickness: thickness,
                      dashed: dashed))
     };
 }
示例#45
0
 // Save instance
 public void Awake() {
     if (Ani._mate) {
         return;
     }
     Ani._mate = this;
 }
示例#46
0
 protected override void Animate()
 {
     Ani.SetBool("IsFlying", IsFlying);
     Ani.SetBool("IsClick", IsClick);
 }
        private static Animation ShowComplexProduct(Ani<Brush> fill1,
                                                    Ani<Brush> fill2,
                                                    Ani<Brush> valueStroke1,
                                                    Ani<Brush> valueStroke2,
                                                    Ani<Complex> value1,
                                                    Ani<Complex> value2,
                                                    Ani<Point> position,
                                                    Ani<double> unitRadius,
                                                    Ani<double> time,
                                                    Ani<Brush> fill3 = null)
        {
            if (fill1 == null) throw new ArgumentNullException("fill1");
            if (fill2 == null) throw new ArgumentNullException("fill2");
            if (valueStroke1 == null) throw new ArgumentNullException("valueStroke1");
            if (valueStroke2 == null) throw new ArgumentNullException("valueStroke2");
            if (value1 == null) throw new ArgumentNullException("value1");
            if (value2 == null) throw new ArgumentNullException("value2");
            if (position == null) throw new ArgumentNullException("position");
            if (unitRadius == null) throw new ArgumentNullException("unitRadius");
            if (time == null) throw new ArgumentNullException("time");
            fill3 = fill3 ?? fill1;
            return new Animation {
                // vertical input
                ShowComplex(fill1.Combine(time, (s, t) => s.LerpToTransparent(t.LerpTransition(0, 1, 1, 1, 1))),
                            valueStroke1,
                            time.Combine(value1,
                                         value2,
                                         (t, v1, v2) => Complex.FromPolarCoordinates(
                                             v1.Magnitude.LerpTo(v1.Magnitude*v2.Magnitude, t.SmoothTransition(0, 0, 1, 1, 1)),
                                             v1.Phase)),
                            position,
                            unitRadius,
                            rotation: Turn.FromNaturalAngle(Math.PI/2),
                            phaseOffset: time.Combine(value2, (t, v) => t.SmoothTransition(0, 0, 0, 1, 1)*v.Phase.ProperMod(Math.PI*2)),
                            sweepFill: fill1.Combine(time, (f, t) => f.LerpToTransparent(t.SmoothTransition(0, 0, 0, 0, 1))),
                            valueGuideStroke: Brushes.Transparent),

                // horizontal input
                ShowComplex(fill2.Combine(time,
                                          (s, t) => s.LerpToTransparent(t.LerpTransition(0, 1, 1, 1, 1))),
                            valueStroke2.Combine(time, (s, t) => s.LerpToTransparent(t.LerpTransition(0, 0, 0, 0, 1))),
                            time.Combine(value1,
                                         value2,
                                         (t, v1, v2) => Complex.FromPolarCoordinates(
                                             v2.Magnitude.LerpTo(v1.Magnitude*v2.Magnitude, t.SmoothTransition(0, 0, 1, 1, 1)),
                                             v2.Phase)),
                            position,
                            unitRadius,
                            sweepFill: fill2.Combine(time, (s, t) => s.LerpToTransparent(t.LerpTransition(0, 0, 0, 0, 1))),
                            valueGuideStroke: Brushes.Transparent),

                // result
                ShowComplex(fill3.Combine(time,
                                          (s, t) => s.LerpToTransparent(t.LerpTransition(1, 0, 0, 0, 0))),
                            Brushes.Transparent,
                            time.Combine(value1,
                                         value2,
                                         (t, v1, v2) => Complex.FromPolarCoordinates(
                                             v1.Magnitude < 0.001 ? 0 : v2.Magnitude.LerpTo(v1.Magnitude*v2.Magnitude, t.SmoothTransition(0, 0, 1, 1, 1)),
                                             v2.Phase + v1.Phase)),
                            position,
                            unitRadius,
                            valueGuideStroke: valueStroke1,
                            sweepFill: fill3.Combine(time, (f, t) => f.LerpToTransparent(t.SmoothTransition(1, 1, 1, 1, 0))),
                            squish: time.Combine(value1, (t, v) => Math.Pow(t.SmoothTransition(v.Magnitude, v.Magnitude, 1, 1, 1), 2)))
            };
        }
示例#48
0
 //Start animation sequence
 public void StartAnimation(Ani.Animate AnimateMode, GameObject CallbackObj, object CallbackMsg, object CallbackParams)
 {
     //Wrapper function
     switch (AnimateMode)
     {
         case Ani.Animate.OneShot:
             pAnimator.StartAnimation(Ani.Animate.OneShot, CallbackObj, CallbackMsg, CallbackParams);
             break;
         case Ani.Animate.Loop:
             pAnimator.StartAnimation(Ani.Animate.Loop, CallbackObj, CallbackMsg, CallbackParams);
             break;
     }
 }
 private static Animation ShowComplexSum(Ani<Brush> fill1,
                                    Ani<Brush> fill2,
                                    Ani<Brush> valueStroke,
                                    IReadOnlyList<Ani<Complex>> values,
                                    Ani<Point> position,
                                    Ani<Point> target,
                                    Ani<Vector> positionDelta,
                                    Ani<double> unitRadius,
                                    Ani<double> time)
 {
     var sum = (Ani < Complex > )Complex.Zero;
     var animation = new Animation();
     foreach (var i in values.Count.Range()) {
         animation.Things.Add(
             ShowComplex(
                 fill1.Combine(time, (s, t) => s.LerpToTransparent(t.SmoothTransition(0, 2, 1, 1, 1))),
                 valueStroke.Combine(time, (s, t) => s.LerpToTransparent(t.SmoothTransition(0, 0.1, 0.1, 1, 1))),
                 values[i],
                 position.Combine(positionDelta,
                                  time,
                                  sum,
                                  unitRadius,
                                  target,
                                  (p, d, t, s, u, p2) => (p + d*i).LerpTo(p2 + new Vector(s.Real*u, s.Imaginary*-u), t.SmoothTransition(0, 0, 1, 1, 1))),
                 unitRadius,
                 valueStroke.Combine(time, (s, t) => s.LerpToTransparent(t.SmoothTransition(0, 1, 1, 1, 1))),
                 sweepFill: fill1.Combine(time, (s, t) => s.LerpToTransparent(t.SmoothTransition(0, 0, 1, 1, 1)))),
             Lifetime.Immortal);
         sum = sum.Combine(values[i], (s, v) => s + v);
     }
     animation.Things.Add(
         ShowComplex(
             fill2.Combine(time, (s, t) => s.LerpToTransparent(t.SmoothTransition(1, 1, 1, 1,0, 0))),
             valueStroke.Combine(time, (s, t) => s.LerpToTransparent(t.SmoothTransition(1, 1, 1,0, 0, 0))),
             sum,
             target,
             unitRadius,
             valueStroke.Combine(time, (s, t) => s.LerpToTransparent(t.SmoothTransition(1, 1, 1,0, 0, 0))),
             sweepFill: fill2.Combine(time, (s, t) => s.LerpToTransparent(t.SmoothTransition(1, 1, 1, 0, 0)))),
         Lifetime.Immortal);
     return animation;
 }