Invoke() public method

Invoke all registered callbacks (runtime and persistent).

public Invoke ( ) : void
return void
コード例 #1
0
    void Start()
    {
        PlayerManager   = PlayerManager.PM;
        UIManager       = UIManager.UIM;
        OverworldCamera = GameObject.Find("Overworld Camera");
        OverworldParent = GameObject.FindWithTag("OverworldParent");

        initCharacters?.Invoke();
        overworldLoaded?.Invoke();
    }
コード例 #2
0
        IEnumerator SecondaryActionChecking(float delayInSeconds)
        {
            yield return(new WaitForSeconds(delayInSeconds));

            if (secondaryCondition)
            {
                StartCoroutine(SecondaryActionValidation(validationDelay));
            }
            else
            {
                onFailure.Invoke();
                started = false;
            }
        }
コード例 #3
0
        IEnumerator SecondaryActionValidationAfterDelay(float delayInSeconds)
        {
            yield return(new WaitForSeconds(delayInSeconds));

            if (secondaryCondition.Value == expectedValue)
            {
                onSuccess.Invoke();
            }
            else
            {
                onFailure.Invoke();
            }

            started = false;
        }
コード例 #4
0
 public virtual void GatherSuccess()
 {
     onGatherFinish?.Invoke();
     GetComponent <Renderer>().enabled = false;
     GatherAble = false;
     if (GatheringInfo.ProductItems.Count > 0)
     {
         List <ItemInfo> lootItems = new List <ItemInfo>();
         foreach (DropItemInfo di in GatheringInfo.ProductItems)
         {
             if (ZetanUtility.Probability(di.DropRate))
             {
                 if (!di.OnlyDropForQuest || (di.OnlyDropForQuest && QuestManager.Instance.HasOngoingQuestWithID(di.BindedQuest.ID)))
                 {
                     lootItems.Add(new ItemInfo(di.Item, Random.Range(1, di.Amount + 1)));
                 }
             }
         }
         if (lootItems.Count > 0)
         {
             LootAgent la = ObjectPool.Get(GatheringInfo.LootPrefab).GetComponent <LootAgent>();
             la.Init(lootItems, transform.position);
         }
     }
     StartCoroutine(UpdateTime());
 }
コード例 #5
0
    public void OnHit(Vector3 hitPoint, Vector3 hitNormal)
    {
        var i = (int)limb;

        var w = (int)WeaponManager.CurrentWeapon;

        w = w < m_weaponMultipliers.Count && w >= 0 ? w : 0;

        float m = 1f, wm = 1f;

        if (LevelConditions.current)
        {
            if (LevelConditions.current.zombieAggression == LevelConditions.Difficulty.docile)
            {
                m  = m_multipliers[i].x;
                wm = m_weaponMultipliers[w].x;
            }
            if (LevelConditions.current.zombieAggression == LevelConditions.Difficulty.agitated)
            {
                m  = m_multipliers[i].y;
                wm = m_weaponMultipliers[w].y;
            }
            if (LevelConditions.current.zombieAggression == LevelConditions.Difficulty.crazed)
            {
                m  = m_multipliers[i].z;
                wm = m_weaponMultipliers[w].z;
            }
        }
        var damageValue = wm * (m_values[i] * m);

        Instantiate(m_impactParticles, hitPoint, Quaternion.LookRotation(hitNormal, Vector3.up));
        onHit?.Invoke((int)damageValue);
    }
コード例 #6
0
        private IEnumerator PluginsMessageRoutine(JsonObject jsonMsg)
        {
            // this is to avoid a deadlock for more info when trying to get data from two separate native plugins and handling them in Unity
            yield return(null);

            string msg = jsonMsg.GetString("msg");

            if (msg.Equals(MSG_TEXT_CHANGE))
            {
                string text = jsonMsg.GetString("text");
                this.onTextChange(text);
            }
            else if (msg.Equals(MSG_TEXT_END_EDIT))
            {
                string text = jsonMsg.GetString("text");
                this.onTextEditEnd(text);
            }
            else if (msg.Equals(MSG_RETURN_PRESSED))
            {
                if (returnPressed != null)
                {
                    returnPressed();
                }
                if (OnReturnPressed != null)
                {
                    OnReturnPressed.Invoke();
                }
            }
        }
コード例 #7
0
ファイル: Crop.cs プロジェクト: pengeel/Project-ZT
 public void OnHarvestSuccess()
 {
     onHarvestFinish?.Invoke();
     HarvestAble = false;
     if (currentStage.ProductItems.Count > 0)
     {
         List <ItemInfo> lootItems = new List <ItemInfo>();
         foreach (DropItemInfo di in currentStage.ProductItems)
         {
             if (ZetanUtility.Probability(di.DropRate))
             {
                 if (!di.OnlyDropForQuest || (di.OnlyDropForQuest && QuestManager.Instance.HasOngoingQuestWithID(di.BindedQuest.ID)))
                 {
                     lootItems.Add(new ItemInfo(di.Item, Random.Range(1, di.Amount + 1)));
                 }
             }
         }
         if (lootItems.Count > 0)
         {
             LootAgent la = ObjectPool.Get(currentStage.LootPrefab).GetComponent <LootAgent>();
             la.Init(lootItems, transform.position);
         }
     }
     HarvestDone();
 }
コード例 #8
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            myEvent.Invoke();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            // エディタ上でイベントを登録した場合、ここで登録した引数は無視される。
            myIntEvent.Invoke(123);
        }

        // スクリプトだけでイベントを加え、さらに、実行後自らを削除してみる例
        // https://answers.unity.com/questions/1492047/unityactionunityevent-remove-listener-from-within.html
        if (Input.GetKeyDown(KeyCode.T))
        {
            //SetEventFromCode(() => Debug.Log("Invoked Medthod whidh is added from code"));
            UnityAction myAction = null;
            myAction = new UnityAction(() =>
            {
                Debug.Log("Invoked Medthod whidh is added from code");
                myEvent.RemoveListener(myAction);
            });
            SetEventFromCode(myAction);
        }
    }
コード例 #9
0
    /// Show a list of options, and wait for the player to make a
    /// selection.
    private IEnumerator DoRunOptions(Yarn.OptionSet optionsCollection, ILineLocalisationProvider localisationProvider, System.Action <int> selectOption)
    {
        ds.ClearOptions();
        end = false;

        waitingForOptionSelection = true;

        currentOptionSelectionHandler = selectOption;

        foreach (var optionString in optionsCollection.Options)
        {
            string text = localisationProvider.GetLocalisedTextForLine(optionString.Line);
            ds.AddChoice(text, () => SelectOption(optionString.ID));
        }

        onOptionsStart?.Invoke();

        // Wait until the chooser has been used and then removed
        while (waitingForOptionSelection)
        {
            yield return(null);
        }

        onOptionsEnd?.Invoke();
    }
コード例 #10
0
 public void Use()
 {
     if (action != null)
     {
         action.Invoke();
     }
 }
コード例 #11
0
 private void Update()
 {
     if (Input.GetKeyDown(jumpCode))
     {
         onPress?.Invoke();
     }
 }
コード例 #12
0
 public void OnMilestoneAchieved(GameManager.Milestone milestone)
 {
     if (milestone == m_milestoneToAchieve)
     {
         m_onMilestoneAchievedEvent?.Invoke();
     }
 }
コード例 #13
0
    protected virtual void HandlePluginMessage(JsonObject jsonMsg)
    {
        // By the time this is called the component might be destroyed
        if (this == null)
        {
            return;
        }

        string msg = jsonMsg.GetString("msg");

        if (msg.Equals(MSG_TEXT_BEGIN_EDIT))
        {
            if (this.OnBeginEditing != null)
            {
                this.OnBeginEditing.Invoke();
            }
        }
        else if (msg.Equals(MSG_TEXT_CHANGE) || msg.Equals(MSG_TEXT_END_EDIT))
        {
            this.InputField.text = jsonMsg.GetString("text");
        }
        else if (msg.Equals(MSG_RETURN_PRESSED))
        {
            if (returnPressed != null)
            {
                returnPressed();
            }
            if (OnReturnPressed != null)
            {
                OnReturnPressed.Invoke();
            }
        }
    }
コード例 #14
0
 private void OnFire(object sender, bool isFire)
 {
     if (isFire)
     {
         fireEvt?.Invoke();
     }
 }
コード例 #15
0
        IEnumerator IntentionChecking()
        {
            yield return(new WaitForSeconds(intentionCheckingDelay));

            // If, after some time, initial gesture is still being held then intention is validated
            if (primaryCondition.Value)
            {
                onIntentionValidated.Invoke();

                // Secondary action validation
                switch (mode)
                {
                case SeqMode.CheckAfterDelay:
                    StartCoroutine(SecondaryActionValidationAfterDelay(validationCheckingDelay));
                    break;

                case SeqMode.WaitUntilTimeout:
                    StartCoroutine(SecondaryActionValidationUntilTimeout(validationTimeout, validationCheckingFreq));
                    break;
                }
            }
            else
            {
                // There was no intention
                onIntentionFailed.Invoke();

                started = false;
            }
        }
コード例 #16
0
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         onM1Clicked?.Invoke();
     }
 }
コード例 #17
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         OnPlayerFinish?.Invoke();
     }
 }
コード例 #18
0
ファイル: EventTrigger2D.cs プロジェクト: almyu/ld33
    private void FilterAndInvoke(Collider2D collider, UnityEvent colliderEvent)
    {
        int mask = 1 << collider.gameObject.layer;
        if ((mask & filter.value) == 0) return;

        colliderEvent.Invoke();
    }
コード例 #19
0
    private IEnumerator LerpToTargetSpot()
    {
        var startPosition = transform.position;
        var startRotation = transform.rotation;
        var startTime     = Time.unscaledTime;
        var endTime       = startTime + lerppingTime;

        while (true)
        {
            yield return(null);

            var t = Mathf.InverseLerp(startTime, endTime, Time.unscaledTime);

            transform.SetPositionAndRotation(Vector3.Lerp(startPosition, targetSpot.position, t), Quaternion.Lerp(startRotation, targetSpot.rotation, t));

            if (Time.unscaledTime >= endTime)
            {
                lerpping       = false;
                rb.isKinematic = true;
                inPosition     = true;
                onPosition?.Invoke();
                break;
            }
        }
    }
コード例 #20
0
 public void Trigger(Transform instigator)
 {
     if (!once || (once && !triggered))
     {
         triggered = true;
         evt.Invoke();
     }
 }
コード例 #21
0
 public void HealthDown(float damage)
 {
     health -= damage;
     if (health <= 0)
     {
         onHealthUnderZero?.Invoke();
     }
 }
コード例 #22
0
    //Removes all listeners of an event, adds one listener, and then invokes the event depending on parameters
    public static void RemoveAllAndAddListener(UnityEvent e, UnityAction listenerToAdd, bool invoke)
    {
        e.RemoveAllListeners(); //Remove all listeners
        e.AddListener(listenerToAdd); //Add the listen

        if(invoke) //If the event should be invoked
            e.Invoke(); //Invoke all listeners
    }
コード例 #23
0
    public void SaveAndQuit(bool save)
    {
        saveChanges = save;

        saveOrDiscardMenu.SetActive(false);

        OnSaveAndQuit?.Invoke();
    }
コード例 #24
0
 IEnumerator checkForKeyUp(KeyCode key, UnityEvent keyUpEvent)
 {
     while (alive) {
         if (Input.GetKeyUp(key) == true) {
             keyUpEvent.Invoke();
         }
         yield return null;
     }
 }
コード例 #25
0
ファイル: ScrapDialogueUI.cs プロジェクト: jimistine/Scrapper
        public override void DialogueComplete()
        {
            onDialogueEnd?.Invoke();


            // Hide the dialogue interface.
            // if (dialogueContainer != null)
            //     dialogueContainer.SetActive(false);
        }
コード例 #26
0
    void Update()
    {
        lifeTime += Time.deltaTime;

        if (lifeTime > maxLifeTime)
        {
            onTimeUp?.Invoke();
        }
    }
コード例 #27
0
 private void FixedUpdate()
 {
     if (timer > maxTime)
     {
         OnTimeUpEvent?.Invoke();
         timer = 0;
     }
     timer += Time.deltaTime;
 }
コード例 #28
0
    /// EDITED FOR SAILING WITH THE GODS
    /// Designed for our dialog system to fill in a dialog object
    private IEnumerator DoRunLine(Yarn.Line line, ILineLocalisationProvider localisationProvider, System.Action onComplete)
    {
        onLineStart?.Invoke();

        userRequestedNextLine = false;

        string text = localisationProvider.GetLocalisedTextForLine(line);

        if (text == null)
        {
            Debug.LogWarning($"Line {line.ID} doesn't have any localised text.");
            text = line.ID;
        }

        //Split one block of text into multiple sections
        string[] split = text.Split('^');

        //If we need to end after the split, we have to save that for later
        //Otherwise, we'll end between the split, which isn't right
        bool eventualEnd = end;

        end = false;

        for (int i = 0; i < split.Length; i++)
        {
            if (split[i][0] == '&')
            {
                ds.AddImage(split[i].Remove(0, 1));
            }
            else
            {
                ds.AddToDialogText(currentSpeakerName, split[i], textAlign);
            }

            //If this is the final part of the split text, remember if this is the end or not
            if (i == split.Length - 1)
            {
                end = eventualEnd;
            }

            // We're now waiting for the player to move on to the next line
            userRequestedNextLine = false;

            // Indicate to the rest of the game that the line has finished being delivered
            onLineFinishDisplaying?.Invoke();

            while (userRequestedNextLine == false)
            {
                yield return(null);
            }
        }

        onLineEnd?.Invoke();

        onComplete();
    }
コード例 #29
0
    /// Show a line of dialogue, gradually
    private IEnumerator DoRunLine(Yarn.Line line, ILineLocalisationProvider localisationProvider, System.Action onComplete)
    {
        onLineStart?.Invoke();

        userRequestedNextLine = false;

        // The final text we'll be showing for this line.
        string text = localisationProvider.GetLocalisedTextForLine(line);

        if (text == null)
        {
            Debug.LogWarning($"Line {line.ID} doesn't have any localised text.");
            text = line.ID;
        }


        string[] split = text.Split('^');

        bool eventualEnd = end;

        end = false;

        for (int i = 0; i < split.Length; i++)
        {
            if (split[i][0] == '&')
            {
                ds.AddImage(split[i].Remove(0, 1));
            }
            else
            {
                ds.AddToDialogText(currentSpeakerName, split[i], textAlign);
            }


            if (i == split.Length - 1)
            {
                end = eventualEnd;
            }

            // We're now waiting for the player to move on to the next line
            userRequestedNextLine = false;

            // Indicate to the rest of the game that the line has finished being delivered
            onLineFinishDisplaying?.Invoke();

            while (userRequestedNextLine == false)
            {
                yield return(null);
            }
        }

        // Hide the text and prompt
        onLineEnd?.Invoke();

        onComplete();
    }
コード例 #30
0
 protected virtual void InteractableObjectUsed(object sender, InteractableObjectEventArgs e)
 {
     doorEvent.Invoke();
     headsetCollision.GetComponent <VRTK_HeadsetCollisionFade>().blinkTransitionSpeed = 3.0f;
     headsetCollision.GetComponent <VRTK_HeadsetCollisionFade>().fadeColor            = Color.white;
     isOpen = true;
     lightSource.SetActive(true);
     cameraFader.SetActive(true);
     doorKnobInteraction.enabled = false;
 }
コード例 #31
0
 public void LeaveScrap()
 {
     // recentScrap.transform.Find("onScrapPanel(Clone)").gameObject.GetComponentInChildren<TextMeshProUGUI>().text =
     //     recentScrap.GetComponent<ScrapObject>().scrapName + "<size=60%><color=#798478> | <color=#FF752A>" + recentScrap.GetComponent<ScrapObject>().size.ToString("#,#") + " m<sup>3</sup></size>";
     // Director.Dir.StartFadeCanvasGroup(recentScrap.transform.Find("onScrapPanel(Clone)").gameObject, "in", 0.1f);
     leftScrap?.Invoke();
     Director.Dir.StartFadeCanvasGroup(readoutPanel, "out", 0.05f);
     AudioManager.AM.PlayMiscUIClip("dismiss");
     DialogueManager.DM.RunNode("scrap-leave");
 }
コード例 #32
0
    private void OnTriggerExit(Collider other)
    {
        Grabbable grabbable = other.GetComponent <Grabbable>();

        if (grabbable != null && currentObjectOn == grabbable)
        {
            OnExit.Invoke();
            currentObjectOn = null;
        }
    }
コード例 #33
0
ファイル: SpriteButton.cs プロジェクト: Fonserbc/LD42
 void OnMouseDown()
 {
     if (isToggle)
     {
         toggleState = !toggleState;
         RefreshToggle();
         onMouseDown.Invoke();
     }
     else
     {
         if (enabled)
         {
             time        = lingerTime;
             rend.sprite = disabledSprite;
             rend.color  = Color.Lerp(original, Color.black, lerpColorFactor);
             onMouseDown.Invoke();
         }
     }
 }