Exemplo n.º 1
0
        IEnumerator DoAttack()
        {
            attacking = true;
            Vector3 startPos = transform.position;
            Vector3 endPos   = transform.position + new Vector3(0, attackDistance, 0);

            while (transform.position.y - startPos.y < attackDistance)
            {
                if (!pausing)
                {
                    Vector2DUtils.MoveToSmoothly(transform, endPos, attackSpeed);
                }

                yield return(null);
            }

            while (transform.position.y - startPos.y > Mathf.Epsilon)
            {
                if (!pausing)
                {
                    Vector2DUtils.MoveToSmoothly(transform, startPos, attackSpeed);
                }

                yield return(null);
            }

            attacking = false;
            animRun.StartPlay();
            tracer.OnResume();
        }
Exemplo n.º 2
0
 void OnAnimateEventDelegate(string eventName, SpriteAnimator animator)
 {
     if (SpriteAnimator.EVENT_LOOPEND == eventName)
     {
         tracer.OnResume();
         animRun.StartPlay();
     }
     else if (SpriteAnimator.EVENT_LOOP_INDEX == eventName)
     {
         if (adjustPolygonColliderIndexs.Contains(animStare.loopIndex))
         {
             ResetTriggerPolygionCollider(null);
         }
     }
 }
Exemplo n.º 3
0
        void OnAnimateEventDelegate(string eventName, SpriteAnimator animator)
        {
            if (animator == activeIdleAnimate)
            {
                if (SpriteAnimator.EVENT_LOOPEND == eventName)
                {
                    if (tracer.started)
                    {
                        activeIdleAnimate.StopPlay();
                        tracer.OnResume();

                        Transform egg    = GameController.GetSingleton().levelsController.eggController.transform;
                        int       mindex = tracer.movingIndex;
                        Vector3   mpos   = tracer.movePoints [mindex];
                        bool      up     = mpos.y > transform.position.y;
                        //left side or right side
                        activeJumpAnimate = up ? animJumpUp : animJumpDown;
                        if (mpos.x < transform.position.x)
                        {
                            //left
                            transform.Rotate(new Vector3(0, 180, 0));
                        }
                        activeJumpAnimate.StartPlay();
                    }
                    else
                    {
                        DoIdle();
                    }
                }
            }
        }
Exemplo n.º 4
0
 public override void OnResume()
 {
     base.OnResume();
     animRun.OnResume();
     animJump.OnResume();
     tracer.OnResume();
 }
Exemplo n.º 5
0
        void OnAnimateEventDelegate(string eventName, SpriteAnimator animator)
        {
            if (animator == animAttack)
            {
                if (SpriteAnimator.EVENT_LOOPEND == eventName)
                {
                    tracer.OnResume();
                    animClimb.StartPlay();
                }
                else if (SpriteAnimator.EVENT_LOOP_INDEX == eventName)
                {
                    if (startThrowAttackAnimateIndex == animAttack.loopIndex)
                    {
                        LevelsController lc     = GameController.GetSingleton().levelsController;
                        E9AttackThing    at     = lc.objectPoolController.InitiateFromPool <E9AttackThing>(LevelsController.PK_E9AttackThing);
                        Vector3          locpos = localAtackThingStartPos.localPosition;
                        locpos = transform.TransformPoint(locpos);
                        at.Attack(locpos, lc.eggController.transform.position, attackSpeed);
                    }
                }
            }
            else if (animator == animActive)
            {
                if (SpriteAnimator.EVENT_LOOPEND == eventName)
                {
                    animActive.StopPlay();
                    animJump.StartPlay();
                    Vector3 pos0 = moveGuideStartPoint;
                    _cor = StartCoroutine(DoJump(pos0));
                }
            }
            else if (animator == animIdle)
            {
                if (SpriteAnimator.EVENT_LOOP_INDEX == eventName)
                {
                    if (animIdle.loopIndex >= idleStartSensibleIndex)
                    {
                        Transform egg        = GameController.GetSingleton().levelsController.eggController.transform;
                        float     angle      = Vector2DUtils.XAngleOfLineSegment(transform.position, egg.position);
                        bool      startTrace = false;
                        if (transform.position.x < egg.position.x)
                        {
                            //left to egg
                            if (angle < sensibleAngle && angle > -sensibleAngle)
                            {
                                startTrace = true;
                                Log.Debug("E9 left start trace... {0}", angle);
                            }
                            else
                            {
//								Log.Debug ("1 {0}", angle);
                            }
                        }
                        else
                        {
                            if (angle > 180 - sensibleAngle || angle < -(180 - sensibleAngle))
                            {
                                startTrace = true;
                                Log.Debug("E9 right start trace... {0}", angle);
                            }
                            else
                            {
//								Log.Debug ("2 {0}", angle);
                            }
                        }
                        if (startTrace)
                        {
                            animIdle.StopPlay();
                            animActive.StartPlay();
                        }
                    }
                    else
                    {
//						Log.Debug ("3 {0}", animIdle.loopIndex);
                    }
                }
                else
                {
//					Log.Debug ("4 {0}", animIdle.loopIndex);
                }
            }
        }