예제 #1
0
    void GenKAniColl()
    {
        initlayid();
        if (collobj == null)
        {
            collobj = new Dictionary <string, BoxCollider2D>();
        }



        KAnim.DrawFrame frame = anicontroller.GetFrame();
        foreach (var b in collobj.Values)
        {
            b.gameObject.SetActive(false);
        }
        foreach (var b in frame.bounds)
        {
            if (b.Key.IndexOf("f:") >= 0)
            {
                continue;
            }
            if (b.Key.IndexOf("state:") >= 0)
            {
                continue;
            }

            //Rect? rect = frame.GetBounds(Vector2.zero, Vector2.one);

            BoxCollider2D box = null;
            if (b.Key == "" && KAniColllayerid > 0)
            {
                box = GetSubCollObj(b.Key);
                box.gameObject.layer = KAniColllayerid;
            }
            else if (b.Key == "hit" && KAniCollHitlayerid > 0)
            {
                box = GetSubCollObj(b.Key);
                box.gameObject.layer = KAniCollHitlayerid;
            }

            if (box != null)
            {
                box.gameObject.SetActive(true);


                Rect?_b = frame.GetBounds(Vector2.zero, Vector2.one, b.Key);
                box.center = new Vector2((_b.Value.center.x) / 64.0f
                                         , -(_b.Value.center.y) / 64.0f);


                box.size = new Vector2(_b.Value.width / 2 / 32.0f, _b.Value.height / 2 / 32.0f);
            }
        }
    }
예제 #2
0
 public Bounds?GetKAniBound(string name)
 {
     KAnim.DrawFrame frame = anicontroller.GetFrame();
     foreach (var b in frame.bounds)
     {
         if (b.Key == name)
         {
             Rect?  rect = frame.GetBounds(Vector2.zero, Vector2.one);
             Bounds _b   = new Bounds(new Vector2((rect.Value.center.x) / 64.0f
                                                  , -rect.Value.center.y / 64.0f)
                                      , new Vector2(b.Value.width / 2 / 32.0f, b.Value.height / 2 / 32.0f)
                                      );
             return(_b);
         }
     }
     return(null);
 }
예제 #3
0
 void PlayKAniSound()
 {
     KAnim.DrawFrame frame = anicontroller.GetFrame();
     if (LastKAniSoundPlayFrame != frame.frameid)
     {
         foreach (var s in frame.sounds)
         {
             if (_funcPlaySound != null)
             {
                 _funcPlaySound(s);
             }
             else
             {
                 //Debug.Log("PlaySound:"+s);
             }
         }
     }
     LastKAniSoundPlayFrame = frame.frameid;
 }