コード例 #1
0
ファイル: EntityInfo.cs プロジェクト: fuboss/aiProject
 // 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
ファイル: Backpack.cs プロジェクト: fuboss/aiProject
 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
ファイル: EntityInfo.cs プロジェクト: fuboss/aiProject
        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
ファイル: ActorInfo.cs プロジェクト: fuboss/aiProject
 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;
 }