public void Update_ProfileForField (FIELDS field, int value) { string tempField; switch (field) { case FIELDS.WEAPON_PRIMAL: PlayerPrefs.SetInt ("primalWeapon", value); primalWeapon = value; break; case FIELDS.WEAPON_SECONDARY: PlayerPrefs.SetInt ("secondWeapon", value); secondWeapon = value; break; case FIELDS.HIGHEST_SCORE: if (highScore < value) { highScore = value; PlayerPrefs.SetInt ("HighScore", value); } break; case FIELDS.HIGHEST_STREAK: if (highStreak < value) { highStreak = value; PlayerPrefs.SetInt ("HighStreak", value); } break; case FIELDS.BODY_COUNT: bodyCount += value; PlayerPrefs.SetInt ("bodyCount", bodyCount); break; default : Debug.Log ("Value not supported: " + field); return; } }
public Field(FIELDS val, Point up, Point down, Point left, Point right) { value = val; this.up = up; this.down = down; this.left = left; this.right = right; }
/// <summary> /// Get special field from message with field enum /// </summary> /// <param name="field">field enum</param> /// <returns></returns> /// <exception cref="ISOException">throws ISOException if field does not exists</exception> public byte[] GetField(FIELDS field) { if (!dataElements.ContainsKey(field.GetNo())) { throw new ISOException("Field No " + field.GetNo() + " does not exists"); } return(dataElements[field.GetNo()]); }
public void Update_ForFieldS (FIELDS[] fields, int[] values) { if (fields.Length != values.Length) { Debug.LogError ("DIFFERENT ARRAY SIZE C**T"); } for (int i = 0; i < fields.Length; i++) { Update_ProfileForField (fields [i], values [i]); } }
/// <summary> /// Get string representation of field enum /// </summary> /// <param name="field">Field enum</param> /// <param name="asciiFix">Fix ascii characters</param> /// <returns>Field value in string</returns> public string GetStringField(FIELDS field, bool asciiFix) { string temp = StringUtil.FromByteArray(GetField(field.GetNo())); if (asciiFix && !field.getType().Equals("n")) { return(StringUtil.HexToAscii(temp)); } return(temp); }
//amíg lehet az adott irányba menni, megnézi, hogy az adott irányban a mezők megegyeznek-e fieldValue-val private bool checkDirection(int row, int col, DIRECTION direction, FIELDS fieldValue) { if (fieldValue == table.table[row, col].value) { switch (direction) { case DIRECTION.up: if (table.table[row, col].up != null) { return(checkDirection(table.table[row, col].up.row, table.table[row, col].up.col, DIRECTION.up, fieldValue)); } else { return(true); //ha felfele nem tudunk tovább menni, akkor az azt jelenti, hogy az addig bejárt mezők } //value értéke megegyezik a fieldValue-val és visszatérhetünk igazzal rekurzívan case DIRECTION.down: if (table.table[row, col].down != null) { return(checkDirection(table.table[row, col].down.row, table.table[row, col].down.col, DIRECTION.down, fieldValue)); } else { return(true); } case DIRECTION.left: if (table.table[row, col].left != null) //ha tudunk még balra menni, akkor nézzük meg, hogy annak a mezőnek a value-ja egyenlő-e a fieldValue-val { return(checkDirection(table.table[row, col].left.row, table.table[row, col].left.col, DIRECTION.left, fieldValue)); } else { return(true); } case DIRECTION.right: if (table.table[row, col].right != null) { return(checkDirection(table.table[row, col].right.row, table.table[row, col].right.col, DIRECTION.right, fieldValue)); } else { return(true); } } return(true); //ha switch ágban egyik sem futott volna le (hiba!) } else { return(false); //ha az adott irányban találunk olyan mezőt, amelynek value-ja nem egyenlő fieldValue-val, } //akkor visszatérünk hamissal, és a rekuzió miatt az előző rekurzív hívások is hamissal térnek vissza }
private void AddOrUpdateElement(FIELDS field, byte[] fValue) { if (dataElements.ContainsKey(field.GetNo())) { dataElements[field.GetNo()] = fValue; } else { dataElements.Add(field.GetNo(), fValue); } }
/// <summary> /// Add new field to data element stack /// </summary> /// <param name="field">field enum</param> /// <param name="body">body of message</param> /// <param name="offset">field offset</param> /// <param name="len">field data len</param> /// <exception cref="ISOException"></exception> private void AddElement(FIELDS field, byte[] body, int offset, int len) { if (body.Length >= offset + len) { AddElement(field, Arrays.CopyOfRange(body, offset, offset + len)); } else { throw new ISOException("ArrayIndexOutOfBoundsException for field " + field + " len: " + body.Length + "/" + (offset + len)); } }
private bool isAttackable(FIELDS player) { for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if (table.table[i, j].value != FIELDS.NaF && table.table[i, j].value == player && !check3Group(i, j)) { return(true); } } } return(false); }
/// <summary> /// /// </summary> /// <param name="field"></param> /// <returns></returns> public byte[] parse(FIELDS field) { fieldLength = field.GetLength(); fieldType = field.getType(); fieldFormat = field.GetFormat(); if (field.IsFixed()) { return(fixedFieldParser()); } else { return(varFieldParser()); } }
private int countPlayerFigureCount(FIELDS player) { int counter = 0; for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if (table.table[i, j].value == player) { counter++; } } } return(counter); }
/// <summary> /// Convert fields to string /// </summary> /// <returns></returns> public string FieldsToString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("\r\n"); foreach (KeyValuePair <int, byte[]> item in dataElements) { stringBuilder .Append(FIELDS.ValueOf(item.Key)) .Append(" : ") .Append(StringUtil.FromByteArray(item.Value)) .Append("\r\n"); } stringBuilder.Append("\r\n"); return(stringBuilder.ToString()); }
public DataElement <T> SetField(FIELDS field, string value) { if (value != null) { switch (field.getType()) { case "n": SetField(field, StringUtil.HexStringToByteArray(value)); break; default: SetField(field, Encoding.Default.GetBytes(value)); break; } } return(this); }
/// <summary> /// Parse body /// </summary> private void parseBody() { BitArray pb = StringUtil.BitArrayFromHexString(StringUtil.FromByteArray(primaryBitmap)); MessageParser parser = new MessageParser(body); for (int i = 1; i < pb.Count; i++) { int o = i + 1; if (!pb.Get(i)) { continue; } FIELDS field = FIELDS.ValueOf(o); byte[] fieldData = parser.parse(field); AddElement(field, fieldData); } }
public DataElement <T> SetField(FIELDS field, byte[] value) { byte[] fValue = value; if (value == null) { throw new ISOException(field + " is Null"); } //Length check and padding if (field.IsFixed()) { if (field.GetLength() % 2 != 0) { if (field.getType().Equals("n")) { // byte[] _fixed = new byte[(int) Math.Ceiling(field.GetLength()/2f)*2]; // // for (int i = 0; i<fValue.Length; i++) { // _fixed[i] = (byte) ((fValue[i] & 0x0F) << 4); // if (i + 1 < value.Length) // _fixed[i] += Convert.ToByte((fValue[i + 1] & 0xF0) >> 4); // } // // _fixed[fValue.Length - 1] = (byte) (_fixed[fValue.Length - 1] + 0x0F); // fValue = _fixed; } } else if (field.GetLength() - (fValue.Length * 2) > 0 && field.getType().Equals("n")) { ByteArray valueBuffer = new ByteArray(); valueBuffer.append(fValue); valueBuffer.prepend( Encoding.ASCII.GetBytes(new char[(field.GetLength() - (fValue.Length * 2)) / 2]) ); fValue = valueBuffer.array(); valueBuffer.clear(); } if (fValue.Length > field.GetLength()) { fValue = Arrays.CopyOfRange(fValue, fValue.Length - field.GetLength(), fValue.Length); } } else { int dLen = fValue.Length; switch (field.getType()) { case "z": if (dLen > field.GetLength()) { fValue = Arrays.CopyOfRange(fValue, fValue.Length - field.GetLength(), fValue.Length); } dLen = fValue.Length * 2; break; } ByteArray valueBuffer = new ByteArray(); valueBuffer.append(fValue); switch (field.GetFormat()) { case "LL": if (2 - dLen.ToString().Length <= 0) { valueBuffer.prepend(StringUtil.HexStringToByteArray(dLen + "")); } else { var eLen = (new String('0', (2 - dLen.ToString().Length) + dLen)); valueBuffer.prepend( StringUtil.HexStringToByteArray( eLen.Substring(eLen.Length - 2, 2) )); } break; case "LLL": { var eLen = '0' + new String('0', (4 - dLen.ToString().Length)) + dLen; valueBuffer.prepend( StringUtil.HexStringToByteArray( eLen.Substring(eLen.Length - 4, 4) )); } break; } fValue = valueBuffer.array(); valueBuffer.clear(); valueBuffer = null; } AddOrUpdateElement(field, fValue); return(this); }
/// <summary> /// Check if fields exists by field enum /// </summary> /// <param name="field">Field enum</param> /// <returns>Returns true if field already exists</returns> public bool FieldExits(FIELDS field) { return(FieldExits(field.GetNo())); }
/// <summary> /// Add new field to data element stack /// </summary> /// <param name="field">field enum</param> /// <param name="data">field data</param> private void AddElement(FIELDS field, byte[] data) { dataElements.Add(field.GetNo(), data); }
public int GetValue_ForField (FIELDS field) { switch (field) { case FIELDS.BODY_COUNT: return bodyCount; case FIELDS.HIGHEST_SCORE: return highScore; case FIELDS.HIGHEST_STREAK: return highStreak; case FIELDS.WEAPON_PRIMAL: return primalWeapon; case FIELDS.WEAPON_SECONDARY: return secondWeapon; default : Debug.LogError ("Unrecognised key"); return -1; } }
public void Excute() { if (String.IsNullOrEmpty(this.TableName)) { throw new SAPException("表名为空!!"); } if (this._dataInput == null && DATA == null) { throw new SAPException("数量为0!!"); } if (this._fieldsIn == null && FIELDS == null) { throw new SAPException("字段列表不能为空!!"); } try { IRfcTable DATA2 = this._function.GetTable("DATA"); IRfcTable FIELDS2 = this._function.GetTable("FIELDS"); DATA2.Clear(); FIELDS2.Clear(); IRfcStructure line2; if (this.Operation == OperationType.direct) { for (int i = 0; i < DATA.RowCount; i++) { DATA.CurrentIndex = i; line2 = DATA2.Metadata.LineType.CreateStructure(); line2.SetValue("FELD", DATA.GetValue("FELD")); DATA2.Append(line2); } for (int i = 0; i < FIELDS.RowCount; i++) { FIELDS.CurrentIndex = i; line2 = FIELDS2.Metadata.LineType.CreateStructure(); line2.SetValue("FIELDNAME", FIELDS.GetValue("FIELDNAME")); line2.SetValue("OFFSET", FIELDS.GetValue("OFFSET")); line2.SetValue("LENGTH", FIELDS.GetValue("LENGTH")); line2.SetValue("TYPE", FIELDS.GetValue("TYPE")); line2.SetValue("FIELDTEXT", FIELDS.GetValue("FIELDTEXT")); FIELDS2.Append(line2); } } else if (this.Operation == OperationType.write) { foreach (var item in this._dataInput) { line2 = DATA2.Metadata.LineType.CreateStructure(); line2.SetValue(0, item); DATA2.Append(line2); } foreach (var item in this._fieldsIn) { line2 = FIELDS2.Metadata.LineType.CreateStructure(); line2.SetValue("FIELDNAME", item.FieldName); line2.SetValue("OFFSET", item.Offset); line2.SetValue("LENGTH", item.Length); line2.SetValue("TYPE", item.Type); line2.SetValue("FIELDTEXT", item.FieldText); FIELDS2.Append(line2); } } this._function.SetValue("QUERY_TABLE", this.TableName); this._function.SetValue("DATA", DATA2); this._function.SetValue("FIELDS", FIELDS2); this._function.SetValue("DELIMITER", this.Delimiter); this._function.SetValue("INSERTX", this.isInsert == true ? "X" : ""); this._function.SetValue("UPDATEX", this.isUpdate == true ? "X" : ""); this._function.SetValue("MODIFYX", this.isModify == true ? "X" : ""); this._function.SetValue("DELETEX", this.isDelete == true ? "X" : ""); NotifyListener(String.Format("SAP表:{0},总行数{1}写入开始!", this.TableName, DATA2.RowCount.ToString())); this._function.Invoke(_destination); NotifyListener(String.Format("SAP表:{0},写入结束!", this.TableName)); } catch (RfcAbapException abapEx) { throw new SAPException(abapEx.Key + abapEx.Message); } catch (RfcBaseException rfcbase) { throw new SAPException(rfcbase.Message); } catch (Exception ex) { throw new SAPException(ex.Message); } }
/// <summary> /// Get string representation of field no /// </summary> /// <param name="fieldNo">Field no</param> /// <param name="asciiFix">Fix ascii characters</param> /// <returns>Field value in string</returns> public string GetStringField(int fieldNo, bool asciiFix) { return(GetStringField(FIELDS.ValueOf(fieldNo), asciiFix)); }
/// <summary> /// Get string representation of field enum /// </summary> /// <param name="field">Field enum</param> /// <returns>Field value in string</returns> public string GetStringField(FIELDS field) { return(GetStringField(field, false)); }
public DataElement <T> SetField(int no, byte[] value) { SetField(FIELDS.ValueOf(no), value); return(this); }
public Field(FIELDS val) { value = val; }
/// <summary> /// Get string representation of field no /// </summary> /// <param name="fieldNo">Field number</param> /// <returns>Field value in string</returns> public string GetStringField(int fieldNo) { return(GetStringField(FIELDS.ValueOf(fieldNo))); }