/// <summary>
        /// Gets the nearest focused entity by the specified type.
        /// </summary>
        /// <returns>The nearest focused entity by type.</returns>
        /// <param name="_type">Type.</param>
        /// <param name="_allow_child">If set to <c>true</c> allow child.</param>
        public ICECreatureEntity GetBestCounterpartByType(EntityClassType _type, int _max_counterparts, bool _allow_child = false)
        {
            ICECreatureEntity _best_entity   = null;
            float             _best_distance = Mathf.Infinity;
            int _best_counterparts           = _max_counterparts;

            // transform buffer
            Transform _transform = this.transform;

            for (int i = 0; i < ActiveCounterparts.Count; i++)
            {
                ICECreatureEntity _entity = ActiveCounterparts[i];

                if (_entity != null && _entity.EntityType == _type)
                {
                    Transform _entity_transform    = _entity.transform;
                    int       _entity_counterparts = _entity.ActiveCounterparts.Count;
                    float     _entity_distance     = PositionTools.Distance(_transform.position, _entity_transform.position);

                    if ((_entity_distance <= _best_distance) &&
                        (_allow_child || _entity_transform.IsChildOf(_transform) == false) &&
                        (_best_counterparts == -1 || _entity_counterparts <= _best_counterparts))
                    {
                        _best_counterparts = _entity_counterparts;
                        _best_distance     = _entity_distance;
                        _best_entity       = _entity;
                    }
                }
            }

            return(_best_entity);
        }
Beispiel #2
0
 public EntityClass(EntityClassType type, string name)
 {
     Type              = type;
     Name              = name;
     Description       = string.Empty;
     _editorProperties = new List <EditorProperty>();
     _mapProperties    = new List <MapProperty>();
 }
Beispiel #3
0
        /// <summary>
        /// Compares the specified type with the type of reference object.
        /// </summary>
        /// <returns><c>true</c>, if by type was compared, <c>false</c> otherwise.</returns>
        /// <param name="_type">Type.</param>
        public bool CompareByType(EntityClassType _type)
        {
            if (ReferenceGameObject == null)
            {
                return(false);
            }

            return(EntityType == _type ? true : false);
        }
        public void RemoveHierarchyGroup(EntityClassType _type)
        {
            HierarchyGroupObject _group = GetHierarchyGroup(_type);

            if (_group != null && _group.GroupTransform != null)
            {
                GameObject.DestroyImmediate(_group.GroupTransform.gameObject);
            }
        }
Beispiel #5
0
 public EntityClass(EntityClassType type, string name, string description,
                    IEnumerable <EditorProperty> editorProperties, IEnumerable <MapProperty> mapProperties)
 {
     Type              = type;
     Name              = name;
     Description       = description;
     _editorProperties = editorProperties.ToList();
     _mapProperties    = mapProperties.ToList();
 }
Beispiel #6
0
 public static IDataContractBroker <TEntity> CreateBroker(EntityClassType clss)
 {
     if (clss == EntityClassType.ExtensionClass)
     {
         return(new BrokerOfDataContract1 <TEntity>());
     }
     else
     {
         return(new BrokerOfDataContract2 <TEntity>());
     }
 }
        /// <summary>
        /// Adds the new hierarchy group by using the EntityClassType.
        /// </summary>
        /// <returns>The hierarchy group.</returns>
        /// <param name="_type">Type.</param>
        public HierarchyGroupObject AddHierarchyGroup(EntityClassType _type)
        {
            HierarchyGroupObject _group = null;

            if (GetHierarchyGroup(_type) == null)
            {
                _group = new HierarchyGroupObject(_type);
                HierarchyGroups.Add(_group);
            }
            return(_group);
        }
        public HierarchyGroupObject GetHierarchyGroup(EntityClassType _type, bool _forced)
        {
            HierarchyGroupObject _group = GetHierarchyGroup(_type);

            if (_group == null && _forced)
            {
                _group = new HierarchyGroupObject(_type);
                HierarchyGroups.Add(_group);
            }
            return(_group);
        }
        public HierarchyGroupObject AddHierarchyGroup(EntityClassType _type, bool _enabled)
        {
            HierarchyGroupObject _group = null;

            if (GetHierarchyGroup(_type) == null)
            {
                _group         = new HierarchyGroupObject(_type);
                _group.Enabled = _enabled;
                HierarchyGroups.Add(_group);
            }
            return(_group);
        }
        /// <summary>
        /// Gets the hierarchy group by using the EntityClassType.
        /// </summary>
        /// <returns>The hierarchy group.</returns>
        /// <param name="_type">Type.</param>
        public HierarchyGroupObject GetHierarchyGroup(EntityClassType _type)
        {
            foreach (HierarchyGroupObject _group in HierarchyGroups)
            {
                if (_group.EntityType == _type)
                {
                    return(_group);
                }
            }

            return(null);
        }
        /// <summary>
        /// Gets the hierarchy group transform.
        /// </summary>
        /// <returns>The hierarchy group transform.</returns>
        /// <param name="_type">Type.</param>
        public Transform GetHierarchyGroupTransform(EntityClassType _type)
        {
            if (!Enabled)
            {
                return(null);
            }

            HierarchyGroupObject _group = UpdateHierarchyGroup(GetHierarchyGroup(_type, true));

            if (_group != null && _group.Enabled && _group.GroupTransform != null)
            {
                return(_group.GroupTransform);
            }
            else
            {
                return(GetHierarchyRootGroupTransform());
            }
        }
Beispiel #12
0
 public virtual bool CompareType(EntityClassType _type)
 {
     return(EntityType == _type ? true : false);
 }
 public HierarchyGroupObject(EntityClassType _type) : base()
 {
     EntityType = _type;
 }
 public override bool CompareType(EntityClassType _type)
 {
     return(EntityType != _type || base.CompareType(_type) ? true : false);
 }