Beispiel #1
0
 public Maintenance(IActive active, IParser parser, IPersister persister, ILogger logger)
 {
     _parser    = parser ?? throw new ArgumentNullException(nameof(parser));
     _active    = active ?? throw new ArgumentNullException(nameof(active));
     _persister = persister ?? throw new ArgumentNullException(nameof(persister));
     _logger    = logger ?? throw new ArgumentNullException(nameof(logger));
 }
 internal void OnDeserialized(StreamingContext context)
 {
     if (null == Active)
     {
         // set the default values.
         Active = JsonConvert.DeserializeObject <ConfigActive>("{}");
     }
 }
Beispiel #3
0
 /// <inheritdoc/>
 public virtual bool InvokeOnTarget(IActive unit, IActive target, Abilities.Ability ability)
 {
     if (ability.VerifyValidTarget(unit, target))
     {
         ability.UseAbility(unit, target);
         unit.UnitState = new UnitRestingState();
         return(true);
     }
     return(false);
 }
Beispiel #4
0
 /// <inheritdoc/>
 public override bool Move(IActive unit, Direction d)
 {
     if (unit is AbstractMoveableUnit)
     {
         (unit as AbstractMoveableUnit).Location += BoardCoordinate.FromDirection(d);
         unit.UnitState = new UnitMovedState();
         return(true);
     }
     return(false);
 }
Beispiel #5
0
 /// <inheritdoc/>
 public override bool Move(IActive unit, BoardCoordinate location)
 {
     if (unit is AbstractMoveableUnit)
     {
         (unit as AbstractMoveableUnit).Location = location;
         unit.UnitState = new UnitMovedState();
         return(true);
     }
     return(false);
 }
        public void CleanActiveObject(GameObject key)
        {
            if (!activeObjects.ContainsKey(key) || activeObjects[key] == null)
            {
                return;
            }
            IActive active = activeObjects[key].GetComponent <IActive>();

            active?.SetActive(false);
            activeObjects[key] = null;
        }
Beispiel #7
0
        public void Notify(CmdMsgType msg, IActive observer)
        {
            Telegram telegram = new Telegram()
            {
                Msg         = msg,
                IsNotifyAll = false,
                Observers   = new List <IActive>()
                {
                    observer
                }
            };

            this.msgQueue.Enqueue(telegram);
        }
        public void SetActiveObject(GameObject key, GameObject newActiveObject)
        {
            if (!activeObjects.ContainsKey(key))
            {
                activeObjects.Add(key, null);
            }
            if (activeObjects[key] == newActiveObject)
            {
                return;
            }
            CleanActiveObject(key);
            activeObjects[key] = newActiveObject;
            IActive active = activeObjects[key].GetComponent <IActive>();

            DebugObject(key);
            active?.SetActive(true);
        }
Beispiel #9
0
 public void RegisterObserver(IActive device)
 {
     this.Observers.Add(device);
 }
Beispiel #10
0
 /// <inheritdoc/>
 public override bool Refresh(IActive unit)
 {
     return(false);
 }
 public ConfigMaintenance(ConfigActive active)
 {
     Active = active;
 }
Beispiel #12
0
 public static void AfterConstruction(IActive active)
 {
     active.IsActive = true;
 }
Beispiel #13
0
 /// <inheritdoc/>
 public virtual bool Refresh(IActive unit)
 {
     unit.UnitState = new SpryUnitState();
     return(true);
 }
 /// <inheritdoc/>
 public override bool InvokeOnTarget(IActive unit, IActive target, Ability ability)
 {
     return(false);
 }
Beispiel #15
0
 /// <inheritdoc/>
 public virtual bool Rest(IActive unit)
 {
     unit.UnitState = new UnitRestingState();
     return(true);
 }
Beispiel #16
0
 /// <inheritdoc/>
 public virtual bool Move(IActive unit, Direction d)
 {
     return(false);
 }
Beispiel #17
0
 /// <inheritdoc/>
 public virtual bool Move(IActive unit, BoardCoordinate coord)
 {
     return(false);
 }
Beispiel #18
0
 public static void DeActivate(IActive instance)
 {
     instance.IsActive = false;
 }
Beispiel #19
0
 public static void Acitvate(IActive instance)
 {
     instance.IsActive = true;
 }