Пример #1
0
        internal object GetValue(SqlDataReader reader, UnitTags unitTypeTag, int i)
        {
            switch (unitTypeTag)
            {
            case UnitTags.String:
                return(reader.GetString(i));

            case UnitTags.Integer:
                return(reader.GetInt32(i));

            case UnitTags.Float:
                return(reader.GetDouble(i));

            case UnitTags.Decimal:
                return(reader.GetDecimal(i));

            case UnitTags.Boolean:
                return(reader.GetBoolean(i));

            case UnitTags.DateTime:
                return(reader.GetDateTime(i));

            case UnitTags.Unique:
                return(reader.GetGuid(i));

            case UnitTags.Binary:
                return(reader.GetValue(i));

            default:
                throw new ArgumentException("Unknown Unit ObjectType: " + unitTypeTag);
            }
        }
Пример #2
0
 private void RemoveUnitFromUnitsByTags(Unit unit, UnitTags tags)
 {
     if (_unitsByTags.TryGetValue(tags, out List <Unit> units))
     {
         _unitsByTags[unit.UnitTags].Remove(unit);
     }
 }
Пример #3
0
        public virtual object GetValue(DbDataReader reader, UnitTags unitTypeTag, int i)
        {
            switch (unitTypeTag)
            {
            case UnitTags.String:
                return(this.GetString(reader, i));

            case UnitTags.Integer:
                return(this.GetInteger(reader, i));

            case UnitTags.Decimal:
                return(this.GetDecimal(reader, i));

            case UnitTags.Float:
                return(this.GetDouble(reader, i));

            case UnitTags.Boolean:
                return(this.GetBoolean(reader, i));

            case UnitTags.DateTime:
                return(this.GetDateTime(reader, i));

            case UnitTags.Unique:
                return(this.GetUnique(reader, i));

            case UnitTags.Binary:
                return(this.GetBinary(reader, i));

            default:
                throw new ArgumentException("Unknown Unit IObjectType: " + unitTypeTag);
            }
        }
Пример #4
0
        /// <summary>
        /// <see cref="XmlConvert"/> the unit to an XML value..
        /// </summary>
        /// <param name="unitTypeTag">The unit type tag.</param>
        /// <param name="unit">The unit .</param>
        /// <returns>The XML Value</returns>
        public static string WriteString(UnitTags unitTypeTag, object unit)
        {
            switch (unitTypeTag)
            {
            case UnitTags.String:
                return((string)unit);

            case UnitTags.Integer:
                return(XmlConvert.ToString((int)unit));

            case UnitTags.Decimal:
                return(XmlConvert.ToString((decimal)unit));

            case UnitTags.Float:
                return(XmlConvert.ToString((double)unit));

            case UnitTags.Boolean:
                return(XmlConvert.ToString((bool)unit));

            case UnitTags.DateTime:
                return(XmlConvert.ToString((DateTime)unit, XmlDateTimeSerializationMode.Utc));

            case UnitTags.Unique:
                return(XmlConvert.ToString((Guid)unit));

            case UnitTags.Binary:
                return(Convert.ToBase64String((byte[])unit));

            default:
                throw new ArgumentException("Unknown Unit ObjectType: " + unitTypeTag);
            }
        }
Пример #5
0
        /// <summary>
        /// <see cref="XmlConvert"/> from the xml unit value.
        /// </summary>
        /// <param name="value">The XML value.</param>
        /// <param name="unitTypeTag">The unit type tag.</param>
        /// <returns>The converted value</returns>
        public static object ReadString(string value, UnitTags unitTypeTag)
        {
            switch (unitTypeTag)
            {
            case UnitTags.String:
                return(value);

            case UnitTags.Integer:
                return(XmlConvert.ToInt32(value));

            case UnitTags.Decimal:
                return(XmlConvert.ToDecimal(value));

            case UnitTags.Float:
                return(XmlConvert.ToDouble(value));

            case UnitTags.Boolean:
                return(XmlConvert.ToBoolean(value));

            case UnitTags.DateTime:
                return(XmlConvert.ToDateTime(value, XmlDateTimeSerializationMode.Utc));

            case UnitTags.Unique:
                return(Guid.Parse(value));

            case UnitTags.Binary:
                return(Convert.FromBase64String(value));

            default:
                throw new ArgumentException("Unknown Unit ObjectType: " + unitTypeTag);
            }
        }
Пример #6
0
 private void AddUnitToUnitsByTags(Unit unit, UnitTags tags)
 {
     if (!_unitsByTags.ContainsKey(tags))
     {
         _unitsByTags.Add(tags, new List <Unit>());
     }
     _unitsByTags[tags].Add(unit);
 }
Пример #7
0
    public List <Unit> GetUnitListByTags(UnitTags tags)
    {
        List <Unit> units = new List <Unit>();

        foreach (KeyValuePair <UnitTags, List <Unit> > pair in _unitsByTags)
        {
            if ((tags & pair.Key) != 0)
            {
                units.AddRange(pair.Value);
            }
        }
        return(units);
    }
Пример #8
0
    public void GeneralScan(List <Unit> foundUnits, UnitTags unitTags)
    {
        int foundCollidersCount = Physics2D.OverlapCircleNonAlloc(_unit.MoveController.Body.position, _visionRange, _foundColliders, _targetLayers);

        foundUnits.Clear();
        for (int i = 0; i < foundCollidersCount; i++)
        {
            Collider2D collider = _foundColliders[i];
            Unit       unit     = collider.GetComponent <Unit>();
            if (unit != null && unit != _unit)
            {
                if (UnitUtils.ContainsTag(unit.UnitTags, unitTags) &&
                    Scan(unit, _unit.MoveController.Body.transform, _visionRange, _visionLayers, _visionAngle))
                {
                    foundUnits.Add(unit);
                }
            }
        }
    }
Пример #9
0
 internal object GetValue(SqlDataReader reader, UnitTags unitTypeTag, int i)
 {
     switch (unitTypeTag)
     {
         case UnitTags.AllorsString:
             return reader.GetString(i);
         case UnitTags.AllorsInteger:
             return reader.GetInt32(i);
         case UnitTags.AllorsFloat:
             return reader.GetDouble(i);
         case UnitTags.AllorsDecimal:
             return reader.GetDecimal(i);
         case UnitTags.AllorsBoolean:
             return reader.GetBoolean(i);
         case UnitTags.AllorsDateTime:
             return reader.GetDateTime(i);
         case UnitTags.AllorsUnique:
             return reader.GetGuid(i);
         case UnitTags.AllorsBinary:
             return reader.GetValue(i);
         default:
             throw new ArgumentException("Unknown Unit ObjectType: " + unitTypeTag);
     }
 }
Пример #10
0
 private void OnUnitTagsUpdated(Unit unit, UnitTags newTags)
 {
     RemoveUnitFromUnitsByTags(unit, unit.UnitTags);
     AddUnitToUnitsByTags(unit, newTags);
 }
Пример #11
0
 /// <summary>
 /// <see cref="XmlConvert"/> the unit to an XML value..
 /// </summary>
 /// <param name="unitTypeTag">The unit type tag.</param>
 /// <param name="unit">The unit .</param>
 /// <returns>The XML Value</returns>
 public static string WriteString(UnitTags unitTypeTag, object unit)
 {
     switch (unitTypeTag)
     {
         case UnitTags.AllorsString:
             return (string)unit;
         case UnitTags.AllorsInteger:
             return XmlConvert.ToString((int)unit);
         case UnitTags.AllorsDecimal:
             return XmlConvert.ToString((decimal)unit);
         case UnitTags.AllorsFloat:
             return XmlConvert.ToString((double)unit);
         case UnitTags.AllorsBoolean:
             return XmlConvert.ToString((bool)unit);
         case UnitTags.AllorsDateTime:
             return XmlConvert.ToString((DateTime)unit, XmlDateTimeSerializationMode.Utc);
         case UnitTags.AllorsUnique:
             return XmlConvert.ToString((Guid)unit);
         case UnitTags.AllorsBinary:
             return Convert.ToBase64String((byte[])unit);
         default:
             throw new ArgumentException("Unknown Unit ObjectType: " + unitTypeTag);
     }
 }
Пример #12
0
 /// <summary>
 /// <see cref="XmlConvert"/> from the xml unit value.
 /// </summary>
 /// <param name="value">The XML value.</param>
 /// <param name="unitTypeTag">The unit type tag.</param>
 /// <returns>The converted value</returns>
 public static object ReadString(string value, UnitTags unitTypeTag)
 {
     switch (unitTypeTag)
     {
         case UnitTags.AllorsString:
             return value;
         case UnitTags.AllorsInteger:
             return XmlConvert.ToInt32(value);
         case UnitTags.AllorsDecimal:
             return XmlConvert.ToDecimal(value);
         case UnitTags.AllorsFloat:
             return XmlConvert.ToDouble(value);
         case UnitTags.AllorsBoolean:
             return XmlConvert.ToBoolean(value);
         case UnitTags.AllorsDateTime:
             return XmlConvert.ToDateTime(value, XmlDateTimeSerializationMode.Utc);
         case UnitTags.AllorsUnique:
             return Guid.Parse(value);
         case UnitTags.AllorsBinary:
             return Convert.FromBase64String(value);
         default:
             throw new ArgumentException("Unknown Unit ObjectType: " + unitTypeTag);
     }
 }
Пример #13
0
 public static bool ContainsTag(UnitTags tagSet, UnitTags targetTags)
 {
     return((tagSet & targetTags) != 0);
 }