コード例 #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!");
     }
 }
コード例 #6
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!");
     }
 }
コード例 #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
ファイル: EventListener.cs プロジェクト: xmzzc/PickWalker
 public void AddListener(string key,VoidEvent callback)
 {
 }
コード例 #15
0
    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!");
 }
コード例 #17
0
 static internal void PutInDic(this VoidEvent @void)
 {
     PutInDic(@void, string.Format("{0}{1}", defaultKey, nameof(VoidEvent)));
 }
コード例 #18
0
 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);
 }
コード例 #19
0
 public static void AddOnce(this VoidEvent thisEvent, UnityAction reciever)
 {
     thisEvent.RemoveListener(reciever);
     thisEvent.AddListener(reciever);
 }
コード例 #20
0
 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
ファイル: Button.cs プロジェクト: PerxodiT/SFML_MazeWalker
 public void SetAnimationEndAction(VoidEvent action)
 {
     button.onEndAnimation = action;
 }
コード例 #23
0
ファイル: Button.cs プロジェクト: PerxodiT/SFML_MazeWalker
 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
ファイル: AppNodeTest.cs プロジェクト: MeltyPlayer/FinCSharp
 private void PrintToLog_(VoidEvent evt) => LOG.Write("Bar");