Ejemplo n.º 1
0
    public override void Execute(BulletController entityType)
    {
        if (entityType.Target != null)
        {
            // if (entityType.BulletType == BulletType.ChainLightning)
            // {
            //     if (entityType.SelfSprite != null)
            //     {
            //         if (entityType.SelfSprite.scale.x - entityType.chainLightningToScale > -0.05f || entityType.SelfSprite.scale.x >= entityType.chainLightningToScale)
            //         {
            //             entityType.GetFSM().ChangeState(BulletState_Arrival.Instance());
            //         }
            //         else
            //         {
            //            entityType.SelfSprite.scale = new Vector3(entityType.SelfSprite.scale.x + Time.deltaTime * entityType.MoveSpeed, 1f, 1f);
            //         }
            //      }
            //  }
            //  else
            //   {
            Vector3 moveDistance = entityType.MoveSpeed * Time.deltaTime
                                   * (entityType.Target.transform.position - entityType.MyTransform.position).normalized;
            entityType.MyTransform.Translate(moveDistance, Space.World);

            if ((entityType.Target.transform.position - entityType.MyTransform.position).sqrMagnitude <= 1)
            {
                entityType.GetFSM().ChangeState(BulletState_Arrival.Instance());
            }
            //  }
        }
        else
        {
            entityType.GetFSM().ChangeState(BulletState_Destroy.Instance());
        }
    }
Ejemplo n.º 2
0
 public override void Enter(BulletController entityType)
 {
     if (entityType.Target != null && entityType.Target is ActorController)
     {
         if (entityType.BulletType == BulletType.SiegeStone)
         {
             GameObject effect = (GameObject)Object.Instantiate(Resources.Load("GameScene/ActorSkillEffect"));
             effect.transform.parent        = entityType.Target.transform;
             effect.transform.localPosition = entityType.Target.transform.localScale.y == 0 ? new Vector3(10, 0, -1) : new Vector3(10, 0, 1);
             tk2dSpriteAnimator animator = effect.GetComponent <tk2dSpriteAnimator>();
             animator.Play("FireBomb");
             animator.AnimationCompleted = delegate
             {
                 Object.Destroy(effect);
             };
         }
     }
     entityType.GetFSM().ChangeState(BulletState_Destroy.Instance());
 }