Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="encypStr">需要加密的字符串</param>
 /// <param name="charset">编码</param>
 /// <param name="type">位长度</param>
 /// <returns>返回加密后的字符串</returns>
 public static String Sha1(string encypStr, string charset = "gb2312", BitType type = BitType.x16)
 {
     try
     {
         string retStr;
         if (type == BitType.x16)
         {
             System.Security.Cryptography.SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
             retStr = BitConverter.ToString(sha.ComputeHash(System.Text.Encoding.GetEncoding(charset).GetBytes(encypStr)), 4, 8);
             retStr = retStr.Replace("-", "");
         }
         else
         {
             System.Security.Cryptography.SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
             retStr = BitConverter.ToString(sha.ComputeHash(System.Text.Encoding.GetEncoding(charset).GetBytes(encypStr)));
             retStr = retStr.Replace("-", "");
         }
         return(retStr);
     }
     catch (Exception e)
     {
         Console.Error.WriteLine(e.StackTrace);
         return(null);
     }
 }
Ejemplo n.º 2
0
        private void m_comboBoxTypeBit_SelectedIndexChanged(object sender, EventArgs e)
        {
            int type = m_comboBoxTypeBit.SelectedIndex;

            switch (type)
            {
            case 0:
                ShowLog("Bit Change to O bit");
                m_bittype = global::BitType.O;
                break;

            case 1:
                ShowLog("Bit Change to I bit");
                m_bittype = global::BitType.I;
                break;

            case 2:
                ShowLog("Bit Change to R bit");
                m_bittype = global::BitType.R;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 3
0

        
Ejemplo n.º 4
0
        public bool IsHaveMatchingVariants(Cell[][] grid, Point firstPoint, Point secondPoint)
        {
            BitType type1 = grid[secondPoint.X][secondPoint.Y].AssignedBit.BitType;
            BitType type2 = grid[firstPoint.X][firstPoint.Y].AssignedBit.BitType;

            return(GetSameColorCrossCollapse(grid, firstPoint, type1, secondPoint) || GetSameColorCrossCollapse(grid, secondPoint, type2, firstPoint));
        }
Ejemplo n.º 5
0
 public Int()
 {
     _value   = new StringBuilder();
     _state   = State.START;
     _bitType = BitType.DECIMAL;
     _intType = IntToken.IntType.INT;
 }
Ejemplo n.º 6
0
        public Bit CreateBit(ModifiType modifi = ModifiType.None)
        {
            int     index = _random.Next(0, Enum.GetNames(typeof(BitType)).Length);
            BitType type  = (BitType)index;

            return(CreateBit(type, modifi));
        }
Ejemplo n.º 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="type">格式化属性类型</param>
 public BitFormatElementAttribute(BitType type)
     : base()
 {
     this.IsNullable = false;
     this.Order      = 0;
     this.Type       = type;
     this.Length     = 0;
 }
Ejemplo n.º 8
0
 public Bit_Specific(byte bitNo, BitLength bitLenAtrr, BitType bitTypeAtrr, int maxLen, EAddtionalOption option)
 {
     this.bitNumber       = bitNo;
     this.bitLength       = bitLenAtrr;
     this.bitType         = bitTypeAtrr;
     this.maxLength       = maxLen;
     this.addtionalOption = option;
 }
Ejemplo n.º 9
0
 private Transform FindPrefabFromBitType(BitType bitType)
 {
     foreach (BitTypetoPrefab pair in relations)
     {
         if (pair.bitType == bitType)
         {
             return(pair.prefab);
         }
     }
     return(null);
 }
Ejemplo n.º 10
0
        private bool GetSameColorCrossCollapse(Cell[][] grid, Point pos, BitType type, Point noCheckDirection)
        {
            int leftCount   = GetIdenticalTypeCount(grid, pos, new Point(-1, 0), type, noCheckDirection);
            int rightCount  = GetIdenticalTypeCount(grid, pos, new Point(1, 0), type, noCheckDirection);
            int topCount    = GetIdenticalTypeCount(grid, pos, new Point(0, -1), type, noCheckDirection);
            int bottomCount = GetIdenticalTypeCount(grid, pos, new Point(0, 1), type, noCheckDirection);

            int horizontalCount = leftCount + rightCount;
            int verticalCount   = topCount + bottomCount;

            return(horizontalCount >= 2 || verticalCount >= 2);
        }
        private string GetBitString(BitType bit)
        {
            switch (bit)
            {
            case OpenWindowLib.BitType.Bit32: { return("32-Bit"); }

            case OpenWindowLib.BitType.Bit64: { return("64-Bit"); }

            case OpenWindowLib.BitType.Bit32And64: { return("32-Bit and 64-Bit"); }

            default: return("N/A");
            }
        }
Ejemplo n.º 12
0
        private int GetIdenticalTypeCount(Cell[][] grid, Point pos, Point dir, BitType type, Point noCheckDirection)
        {
            int   count    = 0;
            Point nextPose = pos + dir;

            if (nextPose != noCheckDirection && IsPosInGrid(nextPose) && grid[nextPose.X][nextPose.Y].AssignedBit.BitType == type)
            {
                count++;
                nextPose += dir;
                if (IsPosInGrid(nextPose) && grid[nextPose.X][nextPose.Y].AssignedBit.BitType == type)
                {
                    count++;
                }
            }
            return(count);
        }
Ejemplo n.º 13
0
    // Function to choose the prefab type to make
    private void FindColour(int x, int y, Color32 pixel)
    {
        bool found = false;

        foreach (BitTypetoPrefab pair in relations)
        {
            if (knowledge.BitTypeByColour.ContainsKey(pair.bitType) && pixel.Equals(knowledge.BitTypeByColour[pair.bitType]))
            {
                MakeBit(x, y, pair.prefab, pair.bitType);
                found = true;
                break;
            }
        }
        if (!found)
        {
            BitType bitType = BitType.Void;
            if (pixel.a != 0)
            {
                if (FindColourInList(beaconFacingColours, pixel))
                {
                    bitType = BitType.BeaconTR;
                }
                else if (FindColourInList(beaconStartingColours, pixel))
                {
                    bitType = BitType.BeaconTL;
                }
                else if (FindColourInList(beaconUpgradeColours, pixel))
                {
                    bitType = BitType.BeaconBR;
                }
                else if (FindColourInList(pickupUpgradeColours, pixel))
                {
                    bitType = BitType.Upgrade;
                }
                if (bitType != BitType.Void)
                {
                    MakeBit(x, y, FindPrefabFromBitType(bitType), bitType);
                    mostRecentBit.GiveMulticolourInfo(pixel);
                    found = true;
                }
            }
            if (!found)
            {
                MakeBit(x, y, voidPrefab, BitType.Void);
            }
        }
    }
Ejemplo n.º 14
0
    // Function for instantiating a bit
    private void MakeBit(int x, int y, Transform prefab, BitType bitType)
    {
        // Get grid coordinates within the world by dividing pixel x & y by width of grids (10)
        int worldX = x / 10;
        int worldY = y / 10;
        // Get bit position within grid by finding the remainder after dividing by grid width (10)
        int gridX = x % 10;
        int gridY = y % 10;
        // Get unity transform coordinates by multiplying pixel coordinates by the size of a bit (0.2)
        float coordX = x * 0.2f;
        float coordY = y * 0.2f;

        // Instantiate the bit in the appropriate grid, with that grid as its parent
        mostRecentBit = instantiatedWorldScript.GetGrid(worldX, worldY).AddBit(Instantiate(prefab, new Vector3(coordX, coordY, 0), Quaternion.identity, instantiatedWorldScript.gridsObjs[worldX, worldY]).GetComponent <Bit>(), gridX, gridY);
        // Tell the bit where it is in the grid and the world
        mostRecentBit.SetLocationData(worldX, worldY, gridX, gridY);
        mostRecentBit.BitTypeSet = bitType;
    }
Ejemplo n.º 15
0
        public Bit CreateBit(BitType type, ModifiType modifi = ModifiType.None)
        {
            string name = (type).ToString();

            BitData      data                 = new BitData();
            RendererData rendererData         = _settingsManager.GetBitRendererData();
            RendererData modifierRendererData = _settingsManager.GetBitModifierRendererData();

            rendererData.texture    = _resource.GetCommonTexture(name);
            rendererData.auxTexture = _resource.GetCommonTexture(name + "Select");
            data.mainRendererData   = rendererData;
            if (modifi > 0)
            {
                modifierRendererData.texture = _resource.GetCommonTexture(modifi.ToString());
            }
            data.modifiRendererData = modifierRendererData;

            Bit bit = new Bit(data);

            bit.BitType    = type;
            bit.ModifiType = modifi;
            bit.Scale      = 1;
            return(bit);
        }
Ejemplo n.º 16
0
 public static string Encrypt(string sMessage, BitType bitType)
 {
     byte[] bytes = Encoding.UTF8.GetBytes(sMessage);
     return(Encrypt(bytes, bitType));
 }
Ejemplo n.º 17
0
 // Get the sprite for a BitType
 public Sprite GetBitSprite(BitType bt)
 {
     return(bitSprites[bt]);
 }
Ejemplo n.º 18
0
 // Add sprite to dictionary
 public void AddBitSprite(BitType bt, Sprite sprite)
 {
     bitSprites.Add(bt, sprite);
 }
Ejemplo n.º 19
0
 public static string Encrypt(byte[] bytes, BitType bitType)
 {
     return(Encrypt(ConvertToWordArray(bytes), (int)bitType));
 }
Ejemplo n.º 20
0
 /// <summary>
 /// 음악의 비트를 변경합니다.
 /// </summary>
 public void ChangeBit(BitType bitType) =>
 Get <AudioManager>().bgm.setParameterByName("Stage", bitType == BitType.BIT_8 ? 1 : 0);