public void RegisterEntityWithBehaviourOfType(GameEntity entity, EntityBehaviourType behaviourType)
        {
            EntityBehaviour behaviour = behaviourRepository.Get(behaviourType);

            if (behaviour != null)
            {
                behaviour.RegisterEntityWithBehaviour(entity);
            }
        }
 public bool RepositoryContains(EntityBehaviourType type)
 {
     if (behaviourRepository.RepositoryContains(type))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 3
0
 public EntityBehaviourDefinition GetBehaviourDefinitionOfType(EntityBehaviourType behaviourType)
 {
     for (int i = 0; i < requiredBehaviours.Count; i++)
     {
         if (requiredBehaviours[i].behaviourType == behaviourType)
         {
             return(requiredBehaviours[i]);
         }
     }
     return(null);
 }
Esempio n. 4
0
 public void RemoveBehaviourOfType(EntityBehaviourType behaviourType)
 {
     if (Count() > 0)
     {
         IEnumerable all = GetAll();
         foreach (EntityBehaviour item in all)
         {
             if (item.behaviourType == behaviourType)
             {
                 RemoveAt(item.repositoryIndex);
             }
         }
     }
 }
Esempio n. 5
0
 public EntityBehaviour Get(EntityBehaviourType behaviourType)
 {
     if (Count() > 0)
     {
         IEnumerable all = GetAll();
         foreach (EntityBehaviour item in all)
         {
             if (item.behaviourType == behaviourType)
             {
                 return(item);
             }
         }
     }
     UnityEngine.Debug.Log("Unable to find requested behaviour type on entity");
     return(null);
 }
Esempio n. 6
0
        public bool RepositoryContains(EntityBehaviourType behaviourType)
        {
            if (Count() > 0)
            {
                IEnumerable all = GetAll();
                foreach (EntityBehaviour item in all)
                {
                    if (item.behaviourType == behaviourType)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        public override EntityBehaviour AddBehaviourOfType(GameEntity entity, EntityBehaviourType type)
        {
            EntityBehaviour behaviour = new EntityBehaviour_Default();

/*             switch (type) {
 *              case EntityBehaviourType.Growable:
 *                  behaviour = new EntityBehaviour_Growable();
 *                  break;
 *              case EntityBehaviourType.Harvestable:
 *                  behaviour = new EntityBehaviour_Harvestable();
 *                  break;
 *              case EntityBehaviourType.Raining:
 *                  behaviour = new EntityBehaviour_Raining();
 *                  break;
 *          } */

            return(behaviour);
        }
Esempio n. 8
0
        public EntityBehaviourDefinition AddBehaviourToEntityDefinition(EntityDefinition definition, EntityBehaviourType behaviourType)
        {
            for (int i = 0; i < definition.requiredBehaviours.Count; i++)
            {
                if (definition.requiredBehaviours[i].behaviourType == behaviourType)
                {
                    return(definition.requiredBehaviours[i]);
                }
            }
            EntityBehaviourDefinition newDefinition = new EntityBehaviourDefinition_Default();

            switch (behaviourType)
            {
            case EntityBehaviourType.Growable:
                newDefinition = new EntityBehaviourDefinition_Growable(100, 150);
                break;
            }

            definition.requiredBehaviours.Add(newDefinition);
            return(newDefinition);
        }
Esempio n. 9
0
 public abstract EntityBehaviour AddBehaviourOfType(GameEntity entity, EntityBehaviourType behaviourType);
 public void RemoveBehaviourOfType(EntityBehaviourType behaviourType)
 {
     behaviourRepository.RemoveBehaviourOfType(behaviourType);
 }