示例#1
0
        public void SwitchTo(Page page, int direction)
        {
            if (switchTimer != null && switchTimer.Enabled)
            {
                switchTimer.Stop();
                switchTimer.Dispose();
            }

            Size size = Size;

            Dock   = DockStyle.None;
            Size   = size;
            Anchor = AnchorStyles.None;

            page.Anchor   = AnchorStyles.None;
            page.Location = new Point(Width * -direction, 0);
            page.Size     = size;
            ParentForm.Controls.Add(page);

            switchTimer = new SwitchTimer(this, page, direction);
            switchTimer.Start();
        }
示例#2
0
        IEnumerator DoUpdate()
        {
            Vector3[]    vs        = Vector2DUtils.GetEdgeColliderPoints(tongueGuid, transform.position.z);
            Vector3      p0        = vs [0];
            Vector3      p1        = vs [vs.Length - 1];
            LineRenderer line      = null;
            float        length    = Mathf.Abs(Vector2.Distance(p1, p0));
            Vector3      tongnePos = p0;
            bool         attacking = false;

            _timer.maxMoveLength  = length;
            _timer.moveSpeed      = attackSpeed;
            _timer.switchDuration = attackInterval;
            _timer.Start();
            animIdle.StartPlay();

            while (true)
            {
                if (!pausing)
                {
                    float mv = _timer.Update();

                    Vector3 eggPos = GameController.GetSingleton().levelsController.eggController.transform.position;

                    eggPos.z = p0.z;

                    float angle = Vector2DUtils.Angle3(p0, p1, eggPos);

                    Vector3 postarget = p0 + (eggPos - p0).normalized * length;

                    if (_timer.phase == SwitchTimer.Phase.MovingOut)
                    {
                    }
                    else if (_timer.phase == SwitchTimer.Phase.MoveBackPrepare)
                    {
                        postarget = p0;
                    }
                    else if (_timer.phase == SwitchTimer.Phase.MoveingBack)
                    {
                        postarget = p0;
                    }
                    else if (_timer.phase == SwitchTimer.Phase.MoveOutPrepare)
                    {
                        attacking = false;
                        animAttack.StopPlay();
                        animIdle.StartPlay();
                    }

                    Vector3 tmppos = Vector3.MoveTowards(tongnePos, postarget, mv);

                    if (attacking)
                    {
                        Vector3[] points = new Vector3[] { p0, tongnePos };
                        tongnePos = tmppos;
                        line.SetPositions(points);
                        UpdateLineCollider(points);
                    }
                    else if (angle <= angleScope)
                    {
                        Vector3[] points = new Vector3[] { p0, tongnePos };
                        UpdateLineCollider(points);
                        tongnePos = tmppos;
                        attacking = true;
                        animIdle.StopPlay();
                        animAttack.StartPlay();
                        if (null == line)
                        {
                            line = DrawExtraLine(p0, tongnePos);
                        }
                        else
                        {
                            line.SetPositions(points);
                        }
                        UpdateLineCollider(points);
                    }
                    else
                    {
//						Log.Debug ("3333----");
                    }
                }

                yield return(null);
            }
        }