예제 #1
0
 void interactionRaisEvent(Collision col, VoidEvent eventToTrigger)
 {
     wasRaisedThisFrame = false;
     if (checkInteractionBy == Filter.Tag)
     {
         if (col.gameObject.CompareTag(tagToLookFor))
         {
             eventToTrigger.Raise();
             if (isOneTimeEvent)
             {
                 gameObject.SetActive(false);
                 Destroy(gameObject);
             }
             wasRaisedThisFrame = true;
         }
     }
     //safety so we don't encounter a nullpointer if
     if (checkInteractionBy == Filter.Object)
     {
         if (collidableObject == null)
         {
             return;
         }
         if (col.gameObject == collidableObject)
         {
             eventToTrigger.Raise();
             if (isOneTimeEvent)
             {
                 gameObject.SetActive(false);
                 Destroy(gameObject);
             }
             wasRaisedThisFrame = true;
         }
     }
 }
예제 #2
0
            public void Setup(VoidEvent evt, UnityAction action)
            {
                @event   = evt;
                reaction = new UnityReaction();
                reaction.AddListener(action);

                OnEnable();
            }
예제 #3
0
    // Use this function to unregister a callback function with this script
    public void UnRegisterCallback(VoidEvent cbFunction)
    {
        // If events are enabled, unregister the callback function from the event list
        if (_enableEvents)
            _voidEventCallbackList.Remove(cbFunction);
        else
			Debug.LogWarning("AnimateTiledTextureOnTrail: You are attempting to un-register a callback but the events of this object are not enabled!");
    }
예제 #4
0
 public void OnEventFired(VoidEvent evt)
 {
     if (responseDelay <= 1e-2f)
     {
         response?.Invoke();
     }
     else
     {
         Conditional.Wait(responseDelay).Do(() => { response?.Invoke(); });
     }
 }
예제 #5
0
 public void UnRegisterCallback(VoidEvent cbFunction)
 {
     if (_enableEvents)
     {
         _voidEventCallbackList.Remove(cbFunction);
     }
     else
     {
         Debug.LogWarning("AnimateTiledTexture: You are attempting to un-register a callback but the events of this object are not enabled!");
     }
 }
 // Use this function to unregister a callback function with this script
 public void UnRegisterCallback(VoidEvent cbFunction)
 {
     // If events are enabled, unregister the callback function from the event list
     if (_enableEvents)
     {
         _voidEventCallbackList.Remove(cbFunction);
     }
     else
     {
         Debug.LogWarning("AnimateTiledTextureOnTrail: You are attempting to un-register a callback but the events of this object are not enabled!");
     }
 }
예제 #7
0
    private List <VoidEvent> _voidEventCallbackList; // A list of functions we need to call if events are enabled

    // Use this function to register your callback function with this script
    public void RegisterCallback(VoidEvent cbFunction)
    {
        // If events are enabled, add the callback function to the event list
        if (_enableEvents)
        {
            _voidEventCallbackList.Add(cbFunction);
        }
        else
        {
            Debug.LogWarning("AnimateTiledTexture: You are attempting to register a callback but the events of this object are not enabled!");
        }
    }
예제 #8
0
        public static T SendEvent <T>(this object context, T evt, int channel = EventManager.DefaultChannel)
            where T : Event, new()
        {
            if (evt == null)
            {
                using (var voidEvt = VoidEvent.Get())
                    EventManager.SendEvent(voidEvt, context, channel);
                return(null);
            }

            return(EventManager.SendEvent(evt, context, channel));
        }
예제 #9
0
    // Read variables from JSON data.
    private void Tune()
    {
        JSONNode json = JSON.Parse(voidEventsJSON.ToString());

        // Read JSON data for tier-specific data.
        JSONNode nodeTierData = json["tier-specific data"];

        for (int i = 0; i < nodeTierData.Count; ++i)
        {
            JSONNode nodeTier = nodeTierData[i];
            int      tier     = nodeTier["tier"].AsInt;
            int      radiationVestigeCount = nodeTier["radiation vestige count"].AsInt;
            tierToVestigeCount.Add(tier, radiationVestigeCount);
            int radiationVestigeLevel = nodeTier["radiation vestige level"].AsInt;
            tierToVestigeLevel.Add(tier, radiationVestigeLevel);
            int radiationBEDRB = nodeTier["radiation base energy decay rate bonus"].AsInt;
            tierToDecayBonus.Add(tier, radiationBEDRB);
            int asteroidCount = nodeTier["asteroid count"].AsInt;
            tierToAsteroidCount.Add(tier, asteroidCount);
        }

        // Read the actual void event JSON data.
        JSONNode nodeEvents = json["events"];

        for (int i = 0; i < nodeEvents.Count; ++i)
        {
            JSONNode  nodeEvent = nodeEvents[i];
            int       begin     = nodeEvent["begin"].AsInt;
            int       end       = nodeEvent["end"].AsInt;
            JSONArray types     = nodeEvent["types"].AsArray;

            List <VoidEvent> myEvents = new List <VoidEvent>();
            for (int j = 0; j < types.Count; ++j)
            {
                string typeString = types[j];
                char   tierLetter = typeString[0];
                char   typeLetter = typeString[1];

                VoidEvent.EventType theType = letterBindings[typeLetter];
                int tier = (int)char.GetNumericValue(tierLetter);

                VoidEvent newEvent = new VoidEvent(theType, tier);
                newEvent.Started  += VoidEvent_Started;
                newEvent.Finished += VoidEvent_Finished;
                myEvents.Add(newEvent);
            }

            VoidEventGroup newEventGroup = new VoidEventGroup(myEvents, begin, end);
            newEventGroup.Started += VoidEventGroup_Started;
            voidEventGroups.Add(newEventGroup);
        }
    }
예제 #10
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        GUI.enabled = Application.isPlaying;

        VoidEvent e = target as VoidEvent;

        if (GUILayout.Button("Raise"))
        {
            e.Raise(new Void());
        }
    }
예제 #11
0
    void Start()
    {
        attackEvent = new VoidEvent();
        _animationHandler.CreateAnimationUnit("Punch", AnimatorControllerParameterType.Trigger, atomEvent: attackEvent);

        Transform player = AtomTags.FindByTag(playerTag.Value).transform;

        Observable.EveryUpdate().Buffer(TimeSpan.FromSeconds(eachXSeconds))
        .Where(_ => attackAtThisDistance.Value >= Vector2.Distance(player.position, transform.position))
        .Subscribe(_ =>
        {
            _attackAction.Do(gameObject, player.position - transform.position);
            attackEvent.Raise();
        });
    }
예제 #12
0
 public override bool UseItem(Player player)
 {
     if (!MyWorld.voidInvasionUp && !Main.dayTime)
     {
         Main.NewText("You feel a wave of cold rush over you...", 182, 15, 15, false);
         VoidEvent.StartInvasion();
         return(true);
     }
     if (Main.dayTime)
     {
         Main.NewText("Your head throbs", 182, 15, 15, false);
         MyWorld.willStartVoidInvasion = true;
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #13
0
    void interactionRaisEvent(Collider other, VoidEvent eventToTrigger) //trigger
    {
        wasRaisedThisFrame = false;

        if (checkInteractionBy == Filter.Tag)
        {
            if (other.gameObject.CompareTag(tagToLookFor))
            {
                eventToTrigger.Raise();
                if (isOneTimeEvent)
                {
                    if (gameObject.activeSelf)
                    {
                        gameObject.SetActive(false);
                    }
                    wasUsedThisPlaythrough = true;
                }
                wasRaisedThisFrame = true;
            }
        }
        //safety so we don't encounter a nullpointer if
        if (checkInteractionBy == Filter.Object)
        {
            if (collidableObject == null)
            {
                return;
            }
            if (other.gameObject == collidableObject)
            {
                eventToTrigger.Raise();
                if (isOneTimeEvent)
                {
                    if (gameObject.activeSelf)
                    {
                        gameObject.SetActive(false);
                    }
                    wasUsedThisPlaythrough = true;
                }
                wasRaisedThisFrame = true;
            }
        }
    }
예제 #14
0
 public void AddListener(string key,VoidEvent callback)
 {
 }
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        VoidEvent voidEvent = animator.GetComponent <VoidEvent>();

        voidEvent.OnFired();
    }
예제 #16
0
 // Use this function to register your callback function with this script
 public void RegisterCallback(VoidEvent cbFunction)
 {
     // If events are enabled, add the callback function to the event list
     if (_enableEvents)
         _voidEventCallbackList.Add(cbFunction);
     else
         Debug.LogWarning("AnimateTiledTexture: You are attempting to register a callback but the events of this object are not enabled!");
 }
 static internal void PutInDic(this VoidEvent @void)
 {
     PutInDic(@void, string.Format("{0}{1}", defaultKey, nameof(VoidEvent)));
 }
 static internal void PutInDic(this VoidEvent @void, out string key)
 {
     key = string.Format("{0}{1}{2}", defaultKey, nameof(VoidEvent), KeyForXY(UnityEngine.Random.Range(1, 20), UnityEngine.Random.Range(1, 99)));
     PutInDic(@void, key);
 }
 public static void AddOnce(this VoidEvent thisEvent, UnityAction reciever)
 {
     thisEvent.RemoveListener(reciever);
     thisEvent.AddListener(reciever);
 }
 static internal void PutInDic(this VoidEvent @void, string key)
 {
     PutInDic((OLiOEvent)@void, key);
 }
예제 #21
0
 /// <summary>
 /// UEvent数据写入无返回值字典
 /// </summary>
 /// <param name="void">UEvent</param>
 public void PutUEventInVoidDic(VoidEvent @void)
 {
     @void.PutInDic();
 }
예제 #22
0
 public void SetAnimationEndAction(VoidEvent action)
 {
     button.onEndAnimation = action;
 }
예제 #23
0
 public void SetAction(VoidEvent action)
 {
     onClick = action;
 }
예제 #24
0
 /// <summary>
 /// UEvent数据写入无返回值字典
 /// </summary>
 /// <param name="void">UEvent</param>
 /// <param name="key">返回键</param>
 public void PutUEventInVoidDic(VoidEvent @void, out string key)
 {
     @void.PutInDic(out key);
 }
예제 #25
0
 private void PrintToLog_(VoidEvent evt) => LOG.Write("Bar");