/// <summary>
        /// Called when a component is removed from the world
        /// </summary>
        /// <param name="compo">Component</param>
        /// <returns>Returns true if successfully removed otherwise false</returns>
        public override bool Unregister(Component compo)
        {
            if (compo == null)
                return false;

            Type componentType = compo.GetType();
            if (componentType == typeof(HealthComponent))
                RemoveHealth(compo as HealthComponent);
            else if (componentType == typeof(ShieldComponent))
                RemoveShield(compo as ShieldComponent);

            return true;
        }
        /// <summary>
        /// Called when a new component is added to the world
        /// </summary>
        /// <param name="compo">Component</param>
        public override void Register(Component compo)
        {
            if(compo == null)
                throw new ArgumentNullException("compo");

            Type componentType = compo.GetType();
            if (componentType == typeof (HealthComponent))
                ActivateHealth(compo as HealthComponent);
            else if (componentType == typeof (ShieldComponent))
                ActivateShield(compo as ShieldComponent);
        }
        public override bool Unregister(Component compo)
        {
            PoisonComponent poison = compo as PoisonComponent;
            if(poison == null)
                throw new ArgumentException();

            return _components.Remove(poison);
        }
        public override void Register(Component compo)
        {
            PoisonComponent poison = compo as PoisonComponent;
            if(poison == null)
                throw new ArgumentException();

            _components.Add(poison);
        }
Beispiel #5
0
 /// <summary>
 /// Unregisters a component
 /// </summary>
 /// <param name="compo">Component to unregister</param>
 /// <returns>Return true if the component is removed successfully otherwise false</returns>
 public abstract bool Unregister(Component compo);
Beispiel #6
0
 /// <summary>
 /// Registers a component
 /// </summary>
 /// <param name="compo">Component to register</param>
 public abstract void Register(Component compo);