Ejemplo n.º 1
0
    public void PlayCorrespondingEffect(EventToPlay newEvent)
    {
        currentEvent     = newEvent;
        delayBeforeEvent = currentEvent.delayBeforeEventActivation;
        startNbOfWaves   = currentEvent.nbOfWaves;


        switch (currentEvent.eventName)
        {
        case "Blizzard":
            StartCoroutine(WaitBeforeStartingBlizzardEvent(delayBeforeEvent));
            StartCoroutine(PlayBlizzardSound(true));
            break;

        case "Magma":
            StartCoroutine(WaitBeforeStartingMagmaEvent(delayBeforeEvent));
            StartCoroutine(PlayMagmaSound());

            break;

        default:
            Msg.instance.Print(Msg.ErrorType.Info, 25, "L'event \"" + currentEvent.eventName + "\" n'a pas de fonction associée.", true, false);
            break;
        }
    }
    private void Awake()
    {
        timer = minDelayBetweenTwoEvents;

        if (instance != null)
        {
            Msg.instance.Print(Msg.ErrorType.Error, 25, "More than one RandomEventSystem in scene !", true, false);
            return;
        }

        instance = this;

        eventToPlay = new EventToPlay("Aucun événement", 10f, 2, Color.black, 10f);
    }
    // Update is called once per frame
    void Update()
    {
        #region Calcul du délai entre le nouvel intervalle et le précédent
        if (!isCurrentlyPlayingAnEvent)
        {
            if (timer <= 0f)
            {
                eventToPlay = SelectRandomEvent();
                isCurrentlyPlayingAnEvent = true;
                EventScript.instance.PlayCorrespondingEffect(eventToPlay);
                Msg.instance.Print(Msg.ErrorType.Warning, 21, "L'évenement " + eventToPlay.eventName + " sera actif dans " + Mathf.RoundToInt(eventToPlay.delayBeforeEventActivation).ToString() + " secondes.", true, true);
                timer = minDelayBetweenTwoEvents;
            }

            timer -= Time.deltaTime;
        }
        #endregion

        Update_Countdown_UI();
    }