예제 #1
0
 // Forget the actor
 public void Forget(Actor actor)
 {
     var info = new ActorInfo(actor);
     var exists = RealActors.Find(a => a.Equals(info));
     if (exists != null)
         RealActors.Remove(exists);
 }
예제 #2
0
파일: Memory.cs 프로젝트: fuboss/aiProject
        /// <summary>
        /// Create new memry node or update if exists
        /// </summary>
        /// <param name="actor"></param>
        public void Remember(Actor actor)
        {
            var entity = actor.GetEntity();

            if (_memory.ContainsKey(entity))
            {
                _memory[entity].Remember(actor);
            }
            else
            {
                var entityInfo = new EntityInfo(entity);
                entity.SetEntity(entityInfo);
                entityInfo.Remember(actor);
                _memory.Add(entity, entityInfo);
            }

            //TODO: сделать подобное рекурсивно для всех включенных парентов
            if (entity.Parent != null)
            {
                if (_memory.ContainsKey(entity.Parent))
                {
                    _memory[entity.Parent].Remember(actor);
                }
                else
                {
                    var parentInfo = new EntityInfo(entity.Parent);
                    entity.Parent.SetEntity(parentInfo);
                    parentInfo.Remember(actor);

                    _memory.Add(entity.Parent, parentInfo);
                }
            }
        }
예제 #3
0
 public Actor GetItem(Actor item, bool peek = false)
 {
     var founded = _items.Find(i => i == item);
     if (founded != null && !peek)
     {
         _items.Remove(founded);
     }
     return founded;
 }
예제 #4
0
파일: Storage.cs 프로젝트: fuboss/aiProject
 public Actor GetItem(Actor item)
 {
     var founded = Items.Find(i => i == item);
     if (founded != null)
     {
         Items.Remove(founded);
     }
     return founded;
 }
예제 #5
0
파일: Memory.cs 프로젝트: fuboss/aiProject
 /// <summary>
 /// remove memory node, if exists
 /// </summary>
 /// <param name="actor"></param>
 public void Forget(Actor actor)
 {
     var entity = actor.GetEntity();
     if (_memory.ContainsKey(entity))
     {
         _memory[entity].Forget(actor);
     }
     else
     {
         Debug.Log("trying to forget about actor, when Entity doesn't exist");
     }
 }
예제 #6
0
        public void Remember(Actor actor)
        {
            if (actor == null){
                return;
            }
            var actorInfo = new ActorInfo(actor);

            //if exists pure copy - replace it
            var exists = RealActors.Find(a => a.Equals(actorInfo));
            if (exists != null)
                return;

            AddToList(actorInfo);
            if (Updated != null) Updated(actor);
        }
예제 #7
0
파일: Entity.cs 프로젝트: fuboss/aiProject
 private void EntityInfoUpdated(Actor actor)
 {
     Debug.Log("<color=grey> Memory updated for "+ actor.Name+"</color>");
 }
예제 #8
0
 public ActorInfo(Actor actor):this(actor.Name, actor.Position, actor.GetType())
 { }
예제 #9
0
파일: Storage.cs 프로젝트: fuboss/aiProject
 public void AddItem(Actor newItem)
 {
     Items.Add(newItem);
     newItem.transform.SetParent(Cells);
     newItem.transform.position = Cells.position;
 }