예제 #1
0
    MoveJS importAttack(string pathField)
    {
        string json = File.ReadAllText(pathField);
        MoveJS root = JsonConvert.DeserializeObject <MoveJS>(json);

        return(root);
    }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        anim         = GetComponent <Animator>();
        ikContorl    = GetComponent <IKControl>();
        rightTrigger = rightHadukenTrigger.GetComponent <BoxCollider>();
        leftTrigger  = leftHadukenTrigger.GetComponent <BoxCollider>();

        moves = new Move[moveFiles.Length];
        for (int i = 0; i < moves.Length; i++)
        {
            moves[i] = new Move();
        }

        /*for (int i = 0; i < moveFiles.Length; i++ )
         * {
         *  var hitboxes = importAttack(moveFiles[i]).hitboxes;
         *  foreach (HitboxJS  hbox in hitboxes)
         *  {
         *      //GameObject go = new GameObject();
         *      //go.AddComponent<MeshFilter>(
         *      GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
         *      go.transform.SetParent(transform);
         *      Vector3 offset = floatVectorToVector(hbox.offset);
         *      offset.Scale(transform.localScale);
         *      go.transform.localPosition = offset;
         *      go.transform.eulerAngles = floatVectorToVector(hbox.rotation);
         *      Vector3 scale = floatVectorToVector(hbox.scale);
         *      scale.Scale(transform.localScale);
         *      go.transform.localScale = scale;
         *
         *  }
         * }*/
        for (int i = 0; i < moveFiles.Length; i++)
        {
            MoveJS move     = importAttack(moveFiles[i]);
            var    hitboxes = move.hitboxes;
            moves[i].hitboxes = new GhostHBox[hitboxes.Length];
            moves[i].duration = move.duration;
            for (int j = 0; j < hitboxes.Length; j++)
            {
                Transform temp = Instantiate(prefab, new Vector3(0, 0, 0), Quaternion.identity);
                GhostHBox g    = temp.GetComponent <GhostHBox>();
                temp.SetParent(transform);
                temp.localScale       = floatVectorToVector(hitboxes[j].scale);
                temp.localEulerAngles = floatVectorToVector(hitboxes[j].rotation);
                temp.localPosition    = floatVectorToVector(hitboxes[j].offset);
                temp.name             = hitboxes[j].name;
                g.beginFrame          = hitboxes[j].beginFrame;
                g.duration            = hitboxes[j].duration;
                g.damage             = hitboxes[j].damage;
                g.hitStun            = hitboxes[j].hitStun;
                g.launchVector       = floatVectorToVector(hitboxes[j].launchVector);
                g.linearVelocity     = floatVectorToVector(hitboxes[j].linearVelocity);
                g.angularVelocity    = floatVectorToVector(hitboxes[j].angularVelocity);
                g.scaleVelocity      = floatVectorToVector(hitboxes[j].scaleVelocity);
                moves[i].hitboxes[j] = g;
            }
        }
    }