static public ChildSprite addSpriteObject(GameObject aObject, Arg aArg, string aDirectory)
    {
        ChildSprite tSprite;

        //プロパティをみて画像表示タイプを判別
        if (aArg.ContainsKey("animation"))
        {
            tSprite = aObject.AddComponent <ChildAnimatingSprite>();
        }
        else if (aArg.ContainsKey("tiles"))
        {
            tSprite = aObject.AddComponent <ChildAlignedSprite>();
        }
        else if (aArg.ContainsKey("pile"))
        {
            tSprite = aObject.AddComponent <ChildPileSprite>();
        }
        else
        {
            tSprite = aObject.AddComponent <ChildOneSprite>();
        }

        tSprite.initImage(aArg, aDirectory);
        return(tSprite);
    }
Exemple #2
0
 public MapEventMoveMap(Arg aData)
 {
     mEndSide       = new MapEventMoveMapEndSide(aData);
     mMapPath       = aData.get <string>("mapPath");
     mMoveOutVector = aData.get <Vector3>("moveOutVector");
     mMoveOutSpeed  = aData.ContainsKey("moveOutSpeed") ? aData.get <float>("moveOutSpeed") : MyMap.mDefaultMoveSpeed;
     mHereEventKey  = aData.ContainsKey("hereEventKey") ? aData.get <string>("hereEventKey") : "";
 }
 private void runData(Arg aData)
 {
     if (aData.ContainsKey("name"))
     {
     }
     if (aData.ContainsKey("text"))
     {
         mText.write(aData.get <string>("text"));
     }
 }
Exemple #4
0
    protected void load(Arg aData)
    {
        mData = aData;

        //マップ名
        mMapName = mData.get <string>("name");
        //field margin
        mFieldMargin = mData.ContainsKey("fieldMargin") ? mData.get <float>("fieldMargin") : 0;
        //camera size
        mCameraSize = mData.ContainsKey("cameraSize") ? mData.get <float>("cameraSize") : -1;
        //フレームワーク外部用変数
        mArg = mData.ContainsKey("arg") ? mData.get <Arg>("arg") : new Arg();
        //階層データ
        mStratums = new List <Stratum>();
        foreach (Arg tData in mData.get <List <Arg> >("stratum"))
        {
            mStratums.Add(new Stratum(tData));
        }
        //chipデータ
        mChip = new Chip(mData.get <Arg>("chip"));
        //shadowデータ
        mShadows = new List <Shadow>();
        foreach (Arg tData in mData.get <List <Arg> >("shadow"))
        {
            mShadows.Add(new Shadow(tData));
        }
        //ornamentデータ
        mOrnaments = new List <Ornament>();
        foreach (Arg tData in mData.get <List <Arg> >("ornament"))
        {
            mOrnaments.Add(new Ornament(tData));
        }
        //characterデータ
        mCharacters = new List <Character>();
        foreach (Arg tData in mData.get <List <Arg> >("character"))
        {
            mCharacters.Add(new Character(tData));
        }
        //triggerデータ
        mTriggers = new List <Trigger>();
        foreach (Arg tData in mData.get <List <Arg> >("trigger"))
        {
            mTriggers.Add(new Trigger(tData));
        }
        //イベントデータ
        mEvents = new Event(mData.get <Arg>("event"));
        //入り口データ
        mEntrances = new Dictionary <string, Entrance>();
        Arg tEntrance = mData.get <Arg>("entrance");

        foreach (KeyValuePair <string, object> tPair in (Dictionary <string, object>)tEntrance.dictionary)
        {
            mEntrances.Add(tPair.Key, new Entrance(tEntrance.get <Arg>(tPair.Key)));
        }
    }
 public MapEventRoot(Arg aData)
 {
     if (aData.ContainsKey("requareAi"))
     {
         mRequareAi = aData.get <List <string> >("requareAi");
     }
     else
     {
         mRequareAi = new List <string>();
     }
     mJackInvoker = (aData.ContainsKey("jackInvoker")) ? aData.get <bool>("jackInvoker") : true;
     mJackInvoked = (aData.ContainsKey("jackInvoked")) ? aData.get <bool>("jackInvoked") : true;
     mEvent       = MapEvent.create(aData.get <Arg>("event"));
 }
Exemple #6
0
    static public MapObject create(string aFileName, string aName, string id = "")
    {
        if (!mObjectDatas.ContainsKey(aFileName))
        {
            mObjectDatas[aFileName] = new Arg(MyJson.deserializeResourse(MapObjectCreater.kDirPath + "/" + aFileName));
        }
        Arg       tObjectData = mObjectDatas[aFileName].get <Arg>(aName);
        MapObject tMapObject  = MyBehaviour.create <MapObject>();

        tMapObject.name = (id == "") ? aName : aFileName;
        //sprite
        if (tObjectData.ContainsKey("sprite"))
        {
            //画像があるフォルダのパス
            string tPath = HandleString.cutOff(aFileName, "/");
            tPath = (tPath == "") ? MapObjectCreater.kDirPath : MapObjectCreater.kDirPath + "/" + tPath;
            Arg tData = tObjectData.get <Arg>("sprite");
            //pivotYが設定されていないなら0に設定
            if (!tData.ContainsKey("pivotY"))
            {
                tData.set("pivotY", 0f);
            }
            //スプライトセット
            ChildSprite.addSpriteObject(tMapObject.gameObject, tData, tPath);
        }
        //zIndex
        if (tObjectData.ContainsKey("zIndex"))
        {
            tMapObject.zIndex = tObjectData.get <float>("zIndex");
        }
        //マップ属性
        if (tObjectData.ContainsKey("attribute"))
        {
            tMapObject.gameObject.AddComponent <MapAttributeBehaviour>().setAttribute(tObjectData.get <string>("attribute"));
        }
        //collider設定
        if (tObjectData.ContainsKey("collider"))
        {
            Arg tColliderData = tObjectData.get <Arg>("collider");
            ColliderInstaller.addCollider(tMapObject.gameObject, tObjectData.get <Arg>("collider"));
        }
        //category
        if (tObjectData.ContainsKey("category"))
        {
        }
        return(tMapObject);
    }
    public override void initImage(Arg aArg, string aDirectory)
    {
        createChild();
        float tWidth  = (aArg.ContainsKey("width")) ? aArg.get <float>("width") : 1;
        float tHeight = (aArg.ContainsKey("height")) ? aArg.get <float>("height") : 1;
        //画像のpivot
        Vector2 tPivot = new Vector2(aArg.ContainsKey("pivotX") ? aArg.get <float>("pivotX") : 0.5f,
                                     aArg.ContainsKey("pivotY") ? (aArg.get <float>("pivotY")) : 0.5f);
        //画像読み込み
        Sprite tSprite = ChipLoader.load(aDirectory + "/" + aArg.get <string>("file"), aArg.get <int>("x"), aArg.get <int>("y"),
                                         tWidth, tHeight, tPivot);
        //画像表示用の子ノード生成
        GameObject tSpriteNode = MyBehaviour.create <MyBehaviour>().gameObject;

        tSpriteNode.transform.SetParent(mChild.transform, false);
        mRenderer        = tSpriteNode.AddComponent <SpriteRenderer>();
        mRenderer.sprite = tSprite;
    }
Exemple #8
0
    public override void initImage(Arg aArg, string aDirectory)
    {
        createChild();
        mAnimator = MyBehaviour.create <GifAnimator>();
        mAnimator.gameObject.transform.SetParent(mChild.transform, false);
        Arg tAnimationData = aArg.get <Arg>("animation");

        //更新インターバル
        mAnimator.setInterval(tAnimationData.get <float>("interval"));
        //画像のpivot
        Vector2 tPivot = new Vector2(aArg.ContainsKey("pivotX") ? aArg.get <float>("pivotX") : 0.5f,
                                     aArg.ContainsKey("pivotY") ? (aArg.get <float>("pivotY")) : 0.5f);
        //画像
        List <Sprite> tSprites = new List <Sprite>();

        if (tAnimationData.ContainsKey("tile"))//コマを座標指定
        {
            int tWidth  = (aArg.ContainsKey("width")) ? aArg.get <int>("width") : 1;
            int tHeight = (aArg.ContainsKey("height")) ? aArg.get <int>("height") : 1;
            foreach (List <int> tXY in tAnimationData.get <List <List <int> > >("tile"))
            {
                tSprites.Add(ChipLoader.load(aDirectory + "/" + aArg.get <string>("file"), tXY[0], tXY[1], tWidth, tHeight));
            }
        }
        else if (tAnimationData.get <string>("direction") == "horizontal")//コマが横方向
        {
            for (int i = 0; i < tAnimationData.get <int>("frame"); i++)
            {
                tSprites.Add(ChipLoader.load(aDirectory + "/" + aArg.get <string>("file"), aArg.get <int>("x") + i * aArg.get <int>("width"), aArg.get <int>("y"),
                                             aArg.get <int>("width"), aArg.get <int>("height"), tPivot));
            }
        }
        else  //コマが縦方向
        {
            for (int i = 0; i < tAnimationData.get <int>("frame"); i++)
            {
                tSprites.Add(ChipLoader.load(aDirectory + "/" + aArg.get <string>("file"), aArg.get <int>("x"), aArg.get <int>("y") + i * aArg.get <int>("height"),
                                             aArg.get <int>("width"), aArg.get <int>("height"), tPivot));
            }
        }
        mAnimator.setSprites(tSprites);
        mAnimator.play();
    }
 /// <summary>MapEventを作成</summary>
 static public MapEvent createRoot(Arg aData)
 {
     if (aData.ContainsKey("type") && aData.get <string>("type") != "root")
     {
         //root以外作成
         return(create(aData));
     }
     //root作成
     return(new MapEventRoot(aData));
 }
    static public MapEventTrigger create(Arg aData)
    {
        MapEventTrigger tTrigger = MyBehaviour.create <MapEventTrigger>();

        //collider
        ColliderInstaller.addCollider(tTrigger.gameObject, aData.get <Arg>("collider"));
        Collider2D[] tColliders = tTrigger.gameObject.GetComponents <Collider2D>();
        foreach (Collider2D tCollider in tColliders)
        {
            tCollider.isTrigger = true;
        }
        //mapBehaviourAttribute
        tTrigger.gameObject.AddComponent <MapAttributeBehaviour>().setAttribute(MapBehaviourAttribute.Attribute.empty);
        //イベント設定
        tTrigger.set((aData.ContainsKey("enter")) ? new MapEvent(aData.get <Arg>("enter")) : null,
                     (aData.ContainsKey("exit")) ? new MapEvent(aData.get <Arg>("exit")) : null,
                     (aData.ContainsKey("stay")) ? new MapEvent(aData.get <Arg>("stay")) : null,
                     aData.get <Arg>("trigger"), aData.get <bool>("destroy"));
        return(tTrigger);
    }
 public MapEventForwardDelegate(Arg aData)
 {
     mData = aData;
     if (!aData.ContainsKey("nextEvents"))
     {
         return;
     }
     //このイベントの次に実行するイベントを初期化
     foreach (KeyValuePair <string, object> tPair in aData.get <Arg>("nextEvents").dictionary)
     {
         mEventDic.Add(tPair.Key, MapEvent.create((Arg)tPair.Value));
     }
 }
 ///調べられた時のイベントセット
 public void setSearchedEvent(Arg aArg)
 {
     if (aArg.ContainsKey("event"))
     {
         mEvent = new MapEvent(aArg.get <Arg>("event"));
     }
     if (aArg.ContainsKey("up"))
     {
         mFromUpEvent = new MapEvent(aArg.get <Arg>("up"));
     }
     if (aArg.ContainsKey("down"))
     {
         mFromDownEvent = new MapEvent(aArg.get <Arg>("down"));
     }
     if (aArg.ContainsKey("left"))
     {
         mFromLeftEvent = new MapEvent(aArg.get <Arg>("left"));
     }
     if (aArg.ContainsKey("right"))
     {
         mFromRightEvent = new MapEvent(aArg.get <Arg>("right"));
     }
 }
    public static Collider2D addCollider(GameObject aObject, Arg aArg)
    {
        switch (aArg.get <string>("colliderType"))
        {
        case "box":    //四角形
            BoxCollider2D tBox = aObject.AddComponent <BoxCollider2D>();
            tBox.size = new Vector2(aArg.get <float>("colliderSizeX"), aArg.get <float>("colliderSizeY"));
            float tBoxOffsetX = (aArg.ContainsKey("colliderOffsetX")) ? aArg.get <float>("colliderOffsetX") : 0;
            float tBoxOffsetY = (aArg.ContainsKey("colliderOffsetY")) ? aArg.get <float>("colliderOffsetY") : 0;
            tBox.offset = new Vector2(tBoxOffsetX, tBoxOffsetY);
            return(tBox);

        case "block":    //四角形(offsetYを自動で +colliderHeight/2)
            BoxCollider2D tBlock = aObject.AddComponent <BoxCollider2D>();
            tBlock.size = new Vector2(aArg.get <float>("colliderSizeX"), aArg.get <float>("colliderSizeY"));
            float tBlockOffsetX = (aArg.ContainsKey("colliderOffsetX")) ? aArg.get <float>("colliderOffsetX") : 0;
            float tBlockOffsetY = (aArg.ContainsKey("colliderOffsetY")) ? aArg.get <float>("colliderOffsetY") : 0;
            tBlockOffsetY += +aArg.get <float>("colliderSizeY") / 2;
            tBlock.offset  = new Vector2(tBlockOffsetX, tBlockOffsetY);
            return(tBlock);

        case "polygon":    //colliderの頂点指定
            PolygonCollider2D    tPolygon   = aObject.AddComponent <PolygonCollider2D>();
            List <List <float> > tPointData = aArg.get <List <List <float> > >("points");
            Vector2[]            tPoints    = new Vector2[tPointData.Count];
            for (int i = 0; i < tPointData.Count; i++)
            {
                tPoints[i] = new Vector2(tPointData[i][0], tPointData[i][1]);
            }
            tPolygon.points = tPoints;
            return(tPolygon);

        default:
            throw new Exception("ColliderInstaller : 不正なColliderTypeだよ「" + aArg.get <string>("colliderType") + "」");
        }
    }
    //会話文表示
    public void showMessage(Arg aArg, Action aCallback)
    {
        string tType = (aArg.ContainsKey("type")) ? aArg.get <string>("type") : "single";

        switch (tType)
        {
        case "single":
            showSingle(aArg, aCallback);
            break;

        case "list":
            HandleAsync.processInOrder <Arg>(aArg.get <List <Arg> >("list"), (aElement, aRes) => {
                showMessage(aElement, aRes);
            }, () => { aCallback(); });
            break;
        }
    }
 private void showSingle(Arg aArg, Action aCallback)
 {
     //名前
     if (aArg.ContainsKey("name"))
     {
         mNameWindow.SetActive(true);
         mNameText.text = aArg.get <string>("name");
     }
     else
     {
         mNameWindow.SetActive(false);
     }
     //会話文
     mText1.text = aArg.get <string>("text");
     mNext       = () => {
         mNext = null;
         aCallback();
     };
 }
 public MapEventMoveBy(Arg aData)
 {
     mTarget = aData.get <string>("target");
     mSpeed  = aData.ContainsKey("speed") ? aData.get <float>("speed") : MyMap.mDefaultMoveSpeed;
     mVector = aData.get <Vector3>("vector");
 }
 public void end()
 {
     mCamera.enabled = (mData.ContainsKey("endClose") && mData.get <bool>("endClose") == false);
     mCallback("");
 }
Exemple #18
0
 public MapEventMoveMapEndSide(Arg aData)
 {
     mEntrance            = aData.get <string>("entrance");
     mDestinationEventKey = aData.ContainsKey("destinationEventKey") ? aData.get <string>("destinationEventKey") : "";
 }