Ejemplo n.º 1
0
    public void Initialize(HazardData hazardData, Tile tile, Helper helper)
    {
        Data    = hazardData;
        Tile    = tile;
        _helper = helper;

        Assert.IsNotNull(Data.ViewPrototype, "View is missing.");
        var view = GameObject.Instantiate <HazardView>(Data.ViewPrototype);

        view.Initialize(this);

        _hazardHandler          = hazardData.EffectTrigger == HazardEffectTrigger.OnEnter ? new HazardOnEnterHandler(this) : new HazardHandler(this);
        _hazardHandler.Removed += OnHazardHandlerRemoved;

        _triggeredCount = new StateHandledValue <int>();

        _stateHandlers = new List <IStateHandler>();
        _stateHandlers.Add(_hazardHandler);
        _stateHandlers.Add(_triggeredCount);
    }
Ejemplo n.º 2
0
 private void OnHazardHandlerRemoved(HazardHandler hazardHandler)
 {
     hazardHandler.Removed -= OnHazardHandlerRemoved;
     Removed?.Invoke(this);
 }