Exemplo n.º 1
0
    public void Die()
    {
        isAlive = false;
        head.GetComponent <Animator>().enabled = false;
        head.isKinematic = false;
        head.useGravity  = true;
        head.GetComponent <SphereCollider>().enabled = true;
        head.gameObject.transform.parent             = null;

        Vector3 position = head.transform.position;

        position[1]             = 13;
        head.transform.position = position;

        head.velocity = new Vector3(0, 26.0f, 3.0f);

        if (deathParticles)
        {
            deathParticles.transform.parent = null;
            position    = deathParticles.transform.position;
            position[1] = 13;
            deathParticles.transform.position = position;
            deathParticles.Activate();
        }

        OnDestroy.Invoke();
        OnDestroy.RemoveAllListeners();
        head.GetComponent <SelfDestruct>().Initiate();
        Destroy(gameObject);
    }
 private void OnDestroy()
 {
     OnPauseToggle.RemoveAllListeners();
     OnLoseGame.RemoveAllListeners();
     OnHealthChange.RemoveAllListeners();
     OnScoreChange.RemoveAllListeners();
 }
Exemplo n.º 3
0
    private IEnumerator ShowIterator(bool showFlag)
    {
        var showSpeed = showFlag ? 3.0f : -3.0f;

        while (true)
        {
            canvas.alpha += Time.deltaTime * showSpeed;
            if (showFlag)
            {
                canvas.blocksRaycasts = true;
                if (canvas.alpha >= 1.0f)
                {
                    canvas.alpha = 1.0f;
                    break;
                }
            }
            else
            {
                if (canvas.alpha <= 0.0f)
                {
                    canvas.alpha          = 0.0f;
                    canvas.blocksRaycasts = false;
                    IsShow = false;
                    OnClose();
                    OnClosed.Invoke();
                    OnClosed.RemoveAllListeners();
                    break;
                }
            }
            yield return(null);
        }
        coroutine = null;
    }
Exemplo n.º 4
0
 private void OnDisable()
 {
     UnregisterAllHitboxes();
     dieEvent.RemoveAllListeners();
     damageEvent.RemoveAllListeners();
     healthUpdateEvent.RemoveAllListeners();
 }
Exemplo n.º 5
0
    public void InitItem()
    {
        splineMove = GetComponent <splineMove>();
        if (null == splineMove)
        {
            splineMove = gameObject.AddComponent <splineMove>();
        }
        boxcollider = GetComponent <BoxCollider2D>();
        foodImg     = GetComponent <Image>();
        splineMove.pathContainer = GameCtrl._Ins.mapCurve;
        splineMove.speed         = GameCtrl._Ins.GetCurrLevelData().Movespeed;
        splineMove.pathMode      = DG.Tweening.PathMode.TopDown2D;
        splineMove.loopType      = splineMove.LoopType.loop;
        //Debug.Log($"{transform.name} = {transform.position},vector[0]:{splineMove.pathContainer.GetPathPoints()[0]}");
        //transform.position = splineMove.pathContainer.GetPathPoints()[0];
        //Debug.Log($"{transform.name} = {transform.position},vector[0]:{splineMove.pathContainer.GetPathPoints()[0]}");
        splineMove.StartMove();     // 事件必须在 startMove() 调用了在添加
        //Debug.Log($"曲线事件长度 = {splineMove.events.Count}");
        UnityEvent myEvent = splineMove.events[splineMove.events.Count - 1];

        myEvent.RemoveAllListeners();
        myEvent.AddListener(() => {
            //Debug.Log($"到达曲线终点,pointIndex = {splineMove.events.Count - 1}");
            ResetItem();
            GameCtrl._Ins.EC.OnFoodArriveEndPoint?.Invoke(this);
        });
    }
Exemplo n.º 6
0
 protected virtual void OnDestroy()
 {
     OnShowEvent.RemoveAllListeners();
     OnHideEvent.RemoveAllListeners();
     OnShowFinishedEvent.RemoveAllListeners();
     OnHideFinishedEvent.RemoveAllListeners();
 }
Exemplo n.º 7
0
    private IEnumerator FadeOutLoop()
    {
        while (isFading)
        {
            if (fadePercentage < 1)
            {
                fadePercentage += Time.deltaTime / fadeTime;
            }

            fadeImage.color    = Color.Lerp(fadeColorEnd, fadeColorStart, fadePercentage);
            loadingWheel.color = Color.Lerp(loadingWheelColorEnd, loadingWheelColorStart, fadePercentage);
            yield return(null);

            if (fadePercentage >= 1)
            {
                if (OnFadeOut != null)
                {
                    OnFadeOut.Invoke();
                    OnFadeOut.RemoveAllListeners();
                }

                isFading = false;
            }
        }
    }
Exemplo n.º 8
0
 /**
  * SetEventAction
  * @brief このメニューで実行するアクションを外部から設定する
  * @param[in] setAction このメニューで実行するAction
  */
 public void SetEventAction(UnityAction setAction)
 {
     //初期化
     m_launchEvent.RemoveAllListeners();
     //Actionの追加
     m_launchEvent.AddListener(setAction);
 }
Exemplo n.º 9
0
 public override void Stop()
 {
     base.Stop();
     OnLiftedObjectsOutput.RemoveAllListeners();
     OnMultiBoxRectsOutput.RemoveAllListeners();
     OnMultiBoxLandmarksOutput.RemoveAllListeners();
 }
Exemplo n.º 10
0
 // Use this for initialization
 void Awake()
 {
     onClean.Invoke();
     onClean.RemoveAllListeners();
     onCleanPermanently.Invoke();
     Match.Init();
 }
Exemplo n.º 11
0
        public void Emit(string eventName, object[] args = null)
        {
            if (!Events.ContainsKey(eventName))
            {
                throw new Exception("No event with name: " + eventName);
            }

            if (args == null)
            {
                args = defaultArguments;
            }

            isEmitting = true;

            UnityEvent <object[]> permanentEvent = Events[eventName];
            UnityEvent <object[]> oneTimeEvent   = OnceEvents[eventName];

            permanentEvent.Invoke(args);
            oneTimeEvent.Invoke(args);

            oneTimeEvent.RemoveAllListeners();

            isEmitting = false;

            while (QueuedActionsOnEmitter.Count > 0)
            {
                QueuedActionsOnEmitter.Dequeue().Invoke();
            }
        }
Exemplo n.º 12
0
 void OnDestroy()
 {
     if (BackKeyCallBack != null)
     {
         BackKeyCallBack.RemoveAllListeners();
     }
 }
Exemplo n.º 13
0
 //!
 //! Execute on finish. Will call finish callback function
 //!
 private void OnFinish()
 {
     currentAmount = 1f;
     OnFinishEvent.Invoke();
     // Make sure its clean for nexts
     OnFinishEvent.RemoveAllListeners();
 }
Exemplo n.º 14
0
    private IEnumerator AlphaTransition(float _fadeTime)
    {
        while (!s_isValid)
        {
            yield return(new WaitForEndOfFrame());
        }

        float alfa = _fadeTime < 0 ? 1.0f : 0.0f;

        IsFinish = false;

        Color color = s_fadePanel.color;

        while (0.0f <= alfa && alfa <= 1.0f)
        {
            alfa += Time.deltaTime / _fadeTime;
            s_fadePanel.color = new Color(color.r, color.g, color.b, alfa);
            yield return(new WaitForEndOfFrame());
        }

        IsFinish = true;

        if (m_isCallBackValid)
        {
            m_callBack.Invoke();
            m_callBack.RemoveAllListeners();
            m_isCallBackValid = false;
        }
    }
Exemplo n.º 15
0
 public void SetOnClick(UnityAction unityAction)
 {
     // remove all previous listeners
     onClick.RemoveAllListeners();
     // set new listener
     onClick.AddListener(unityAction);
 }
Exemplo n.º 16
0
 public virtual void OnDestroy()
 {
     if (onClick != null)
     {
         onClick.RemoveAllListeners();
     }
 }
Exemplo n.º 17
0
    public void Release()
    {
        Stop();

        if (_mediaPlayer != null)
        {
            // Release MediaPlayer
            _mediaPlayer.Release();
            _mediaPlayer = null;

            if (_mediaPlayerLoop != null)
            {
                _mediaPlayerLoop.Release();
            }

            if (_videoHostingParser != null)
            {
                _videoHostingParser.Release();
            }

            RemoveListeners();

            _openingEvent.RemoveAllListeners();
            _bufferingEvent.RemoveAllListeners();
            _preparedEvent.RemoveAllListeners();
            _playingEvent.RemoveAllListeners();
            _pausedEvent.RemoveAllListeners();
            _stoppedEvent.RemoveAllListeners();
            _endReachedEvent.RemoveAllListeners();
            _encounteredErrorEvent.RemoveAllListeners();
            _timeChangedEvent.RemoveAllListeners();
            _positionChangedEvent.RemoveAllListeners();
            _snapshotTakenEvent.RemoveAllListeners();
        }
    }
Exemplo n.º 18
0
 public void DoFadeAndSetLoadingState()
 {
     currentGameState = GameState.Loading;
     OnLevelRestart.RemoveAllListeners();
     gameManagerAnimator.SetBool("LoadLevel", true);
     sound?.FadeSound(true);
 }
Exemplo n.º 19
0
    private void FixedUpdate()
    {
        if (delayTime > 0f)
        {
            delayTime -= Time.fixedDeltaTime;
            if (textBinds != null)
            {
                foreach (var i in textBinds)
                {
                    if (!useFloatingValues)
                    {
                        i.text = Mathf.RoundToInt(delayTime).ToString();
                    }
                    else
                    {
                        i.text = delayTime.ToString().Substring(0, delayTime.ToString().Length - 2);
                    }
                }
            }
            antiDelayTime += Time.unscaledDeltaTime;
            if (targetValue - antiDelayTime < 0.1f && antiDelayTime < targetValue)
            {
                targetValue++;
                onSecondPassed.Invoke();
            }
            onTick.Invoke();
        }

        if (delayTime < 0.1f && delayTime > 0f)
        {
            delayTime = 0f;
            onTimerReachedEnd.Invoke();
            onSecondPassed.RemoveAllListeners();
        }
    }
Exemplo n.º 20
0
 private void UpdateCrewDeployed()
 {
     crewDeployed.RemoveAllListeners();
     crewDeployed.AddListener(Target.ReadCardFromAsset);
     crewDeployed.AddListener(GameLogicEvents.DeployCrew);
     crewDeployed.AddListener(CrewAssigner.instance.UpdateCrewItems);
 }
Exemplo n.º 21
0
    public void Die()
    {
        //kills alien and makes it fall apart
        isAlive = false;
        head.GetComponent <Animator>().enabled = false;
        head.isKinematic = false;
        head.useGravity  = true;
        head.GetComponent <SphereCollider>().enabled = true;
        head.gameObject.transform.parent             = null;
        head.velocity = new Vector3(0, 26.0f, 3.0f);

        //removes listeners and destroys object
        OnDestroy.Invoke();
        OnDestroy.RemoveAllListeners();
        SoundManager.Instance.PlayOneShot(SoundManager.Instance.alienDeath);
        head.GetComponent <SelfDestruct>().Initiate();

        if (deathParticles)
        {
            //makes blood splatter when alien dies
            deathParticles.transform.parent = null;
            deathParticles.Activate();
        }
        Destroy(gameObject);
    }
Exemplo n.º 22
0
        public static void SubscribeEvents()
        {
            eventUpdateCurrentEncounter.RemoveAllListeners();
            eventUpdateCurrentEncounter.AddListener(GameLogicEvents.UpdateCurrentEncounter);
            eventUpdateLossCounter.RemoveAllListeners();
            eventUpdateLossCounter.AddListener(Visual.instance.UpdateLossCounter);
            eventUpdateCrewCounter.RemoveAllListeners();
            eventUpdateCrewCounter.AddListener(Visual.instance.UpdateCrewCounter);
            eventNewEffect.RemoveAllListeners();

            eventNewEffect.AddListener(raiseNewEffect);
            eventRemoveSingleEffects.RemoveAllListeners();

            eventRemoveSingleEffects.AddListener(removeSingleEffects);

            eventAddSingleUsedTreausreTouchListener.RemoveAllListeners();
            eventAddSingleUsedTreausreTouchListener.AddListener(AddSingleUsedTreasureTouchListener);


            eventCardVisual.RemoveAllListeners();
            eventCardVisual.AddListener(ShowCardVisualEvent);

            eventRestoreCrew.RemoveAllListeners();
            eventRestoreCrew.AddListener(RestoreCrewByCard);
        }
Exemplo n.º 23
0
    // This code works similarly to the marine’s death, but we disable the Animator for the alien.
    // In addition, this code launches the head off the body.
    public void Die()
    {
        isAlive = false;
        head.GetComponent <Animator>().enabled = false;
        head.isKinematic = false;
        head.useGravity  = true;
        head.GetComponent <SphereCollider>().enabled = true;
        head.gameObject.transform.parent             = null;
        head.velocity = new Vector3(0, 26.0f, 3.0f);

        //This block notifies the listeners, removes them and then it deletes the GameObject.
        OnDestroy.Invoke();
        OnDestroy.RemoveAllListeners();
        SoundManager.Instance.PlayOneShot(SoundManager.Instance.alienDeath);

        //
        head.GetComponent <SelfDestruct>().Initiate();

        //This makes the blood splatter when an alien dies.
        if (deathParticles)
        {
            deathParticles.transform.parent = null;
            deathParticles.Activate();
        }

        Destroy(gameObject);
    }
Exemplo n.º 24
0
    protected override void OnDestroy()
    {
        base.OnDestroy();

        onButtonDown.RemoveAllListeners();
        onButtonUp.RemoveAllListeners();
    }
Exemplo n.º 25
0
 void OnDisable()     // PERFORMANCE do we need LevelManger events RemoveAllListeners() OnDisble
 {
     Debug.Log("Level Man Disabled");
     OnIntroEventEnd.RemoveAllListeners();
     StartScriptedEvent.RemoveAllListeners();
     EnableSpawnSystem.RemoveAllListeners();
 }
Exemplo n.º 26
0
 public void ResetData()
 {
     total   = 0;
     current = 0;
     OnDamage.RemoveAllListeners();
     OnRepair.RemoveAllListeners();
 }
        public void SetData(ItemStack stack, ButtonArgument arg = null)
        {
            this.stack = stack;
            onPointerEvent.RemoveAllListeners();
            CommonAttributes atr = stack.item.GetAttribute <CommonAttributes>();

            if (atr)
            {
                this.InventorySprite.sprite = atr.GetSprite();
                this.Amounttext.text        = this.stack.amount.ToString();
                if (this.Amounttext.text == "1")
                {
                    this.Amounttext.enabled = false;
                }
                else
                {
                    this.Amounttext.enabled = true;
                }
            }


            if (arg != null)
            {
                foreach (UnityAction argument in arg.onClickCallback)
                {
                    onPointerEvent.AddListener(argument);
                }
            }
        }
Exemplo n.º 28
0
 private void ResetListeners()
 {
     m_OnMouseOver.RemoveAllListeners();
     m_OnMouseExit.RemoveAllListeners();
     m_OnLock.RemoveAllListeners();
     m_OnStart.RemoveAllListeners();
 }
Exemplo n.º 29
0
 // Hides the ui menu on screen playing an animation if has one
 public void Hide(bool selfDestroy = false)
 {
     if (selfDestroy)
     {
         OnMenuHidden.AddListener(Delete);
     }
     if (anim != null)
     {
         anim.SetBool("IsOpen", false);
         StartCoroutine(WaitFor("Closed"));
     }
     else if (OnMenuHidden != null)
     {
         OnMenuHidden.Invoke();
         OnMenuHidden.RemoveAllListeners();
     }
 }
Exemplo n.º 30
0
 public void RemoveAllListeners()
 {
     startHeistCountdown.RemoveAllListeners();
     startHeist.RemoveAllListeners();
     endMoneyTruckPhase.RemoveAllListeners();
     endHeist.RemoveAllListeners();
     addToScore.RemoveAllListeners();
 }