コード例 #1
0
 /// <summary>予約名パスをフラグで使うパスに変換</summary>
 public MyFlagItem toFlagPath(MyFlagItem aItem)
 {
     if (aItem is MyFlagSingleItem)
     {
         MyFlagSingleItem tSingle = ((MyFlagSingleItem)aItem).copy();
         tSingle.mPath = toFlagPath(tSingle.mPath);
         return(tSingle);
     }
     else if (aItem is MyFlagAndItems)
     {
         MyFlagAndItems tAnd = ((MyFlagAndItems)aItem).copy();
         for (int i = 0; i < tAnd.mItems.Length; ++i)
         {
             tAnd.mItems[i].mPath = toFlagPath(tAnd.mItems[i].mPath);
         }
         return(tAnd);
     }
     else if (aItem is MyFlagOrItems)
     {
         MyFlagAndItems tOr = ((MyFlagAndItems)aItem).copy();
         for (int i = 0; i < tOr.mItems.Length; ++i)
         {
             tOr.mItems[i].mPath = toFlagPath(tOr.mItems[i].mPath);
         }
         return(tOr);
     }
     throw new System.Exception("MyMap : FlagItemのパス変換失敗「" + aItem.GetType().ToString() + "」");
 }
コード例 #2
0
    /// <summary>フラグを確認して生成するか決定</summary>
    static private bool flagCreate(MapFileData.Behaviour aData)
    {
        //削除フラグ確認
        MyFlagItem tItem = aData.mDeleteFlag;

        if (tItem != null)
        {
            if (mWorld.checkFlag(tItem))
            {
                return(false);
            }
        }
        //生成フラグ確認
        tItem = aData.mCreateFlag;
        if (tItem != null)
        {
            return(mWorld.checkFlag(tItem));
        }
        return(true);
    }
コード例 #3
0
    public bool check(MyFlagItem aItem)
    {
        switch (aItem)
        {
        case MyFlagBoolItem bItem:
            object bO = getFlag(bItem.mPath);
            if (bO is bool && (bool)bO == bItem.mValue)
            {
                return(true);
            }
            else
            {
                return(false);
            }

        case MyFlagStringItem sItem:
            object sO = getFlag(sItem.mPath);
            if (sO is string && (string)sO == sItem.mValue)
            {
                return(true);
            }
            else
            {
                return(false);
            }

        case MyFlagFloatItem fItem:
            object fO = getFlag(fItem.mPath);
            float  f;
            if (fO is int)
            {
                f = (int)fO;
            }
            else if (fO is float)
            {
                f = (float)fO;
            }
            else
            {
                return(false);
            }
            switch (fItem.mCompare)
            {
            case MyFlagFloatItem.Compare.equal:
#pragma warning disable RECS0018 // 等値演算子による浮動小数点値の比較
                return(fItem.mValue == (float)f);

#pragma warning restore RECS0018 // 等値演算子による浮動小数点値の比較
            case MyFlagFloatItem.Compare.lessThan:
                return(fItem.mValue < (float)f);

            case MyFlagFloatItem.Compare.moreThan:
                return(fItem.mValue > (float)f);

            case MyFlagFloatItem.Compare.orLess:
                return(fItem.mValue <= (float)f);

            case MyFlagFloatItem.Compare.orMore:
                return(fItem.mValue >= (float)f);
            }
            throw new System.Exception("MyFlag : FloatItem未定義の比較手法「" + fItem.mCompare.ToString() + "」");

        case MyFlagAndItems andItem:
            foreach (MyFlagItem tItem in andItem.mItems)
            {
                if (!check(tItem))
                {
                    return(false);
                }
            }
            return(true);

        case MyFlagOrItems orItem:
            foreach (MyFlagItem tItem in orItem.mItems)
            {
                if (check(tItem))
                {
                    return(true);
                }
            }
            return(false);
        }
        throw new System.Exception("MyFlag : 未定義のフラグCheck「" + aItem.GetType().ToString() + "」");
    }
コード例 #4
0
    /// <summary>フラグチェック</summary>
    public bool checkFlag(MyFlagItem aItem)
    {
        MyFlagItem tItem = toFlagPath(aItem);

        return(mMap.mFlag.check(tItem));
    }