public static void Angle() { Vector2 v1 = new Vector2(0, 0); Vector2 v0 = new Vector2(0, 0); float an = 0; v1 = new Vector2(1, 1); an = Vector2DUtils.XAngleOfLineSegment(v0, v1); Log.Debug("{0} angle is {1}", v1, an); v1 = new Vector2(-1, 1); an = Vector2DUtils.XAngleOfLineSegment(v0, v1); Log.Debug("{0} angle is {1}", v1, an); v1 = new Vector2(-1, -1); an = Vector2DUtils.XAngleOfLineSegment(v0, v1); Log.Debug("{0} angle is {1}", v1, an); v1 = new Vector2(1, -1); an = Vector2DUtils.XAngleOfLineSegment(v0, v1); Log.Debug("{0} angle is {1}", v1, an); }
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); } } }