コード例 #1
0
    public void OnLevelComplete()
    {
        StopAllCoroutines();
        int scorePerCoin = 100;

        for (int i = 0; i < coinsCollected; i++)
        {
            score += scorePerCoin;
        }
        coinsCollected = 0;
        onUIUpdated.Raise();
    }
コード例 #2
0
    private void Die()
    {
        bool isTouchingHazards = playerBody.IsTouchingLayers(LayerMask.GetMask("Hazards"));

        if (isTouchingHazards)
        {
            health = 0;
            onPlayerHealthChanged.Raise();
            onPlayerDeath.Raise();
            GameManager.Instance.OnPlayerDeath();
        }
    }
    public void PickupDust(int count)
    {
        float _prevDust = dustCount;

        if (!superMode)
        {
            dustCount = Mathf.Clamp(dustCount + count, 0, maxDust);
        }
        Director.GetManager <ScoreManager>().AddScore(count);
        if (dustCount != _prevDust)
        {
            OnDustCountChanged.Raise();
        }
    }
コード例 #4
0
ファイル: InventoryUI.cs プロジェクト: Altadsa/Undercrypt
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Tab))
     {
         _onInventoryOpen.Raise();
     }
 }
コード例 #5
0
    protected void OnTriggerEnter2D(Collider2D collision)
    {
        var rocket = collision.GetComponent <RocketController>();

        if (rocket)
        {
            _gameOver.Raise();
        }
    }
 public void Damage(float amount)
 {
     currentHealth -= amount;
     OnPlayerHealthChanged.Raise();
     if (currentHealth <= 0)
     {
         OnPlayerDeath.Raise();
     }
 }
コード例 #7
0
    IEnumerator RunTimerEvent()
    {
        Init();

        var now = DateTime.UtcNow;

        while (nextEvent < now)
        {
            eventTarget.Raise();

            if (pauseEvent)
            {
                yield return(new WaitUntil(() => !pauseEvent));
            }

            nextEvent = nextEvent.AddSeconds(timeTrigger);

            if (dateTimeInitializer != null)
            {
                dateTimeInitializer.Value = nextEvent;
            }
        }

        while (true)
        {
            yield return(new WaitForSeconds(SecondsForNextEvent));

            while (pauseEvent)
            {
                yield return(new WaitUntil(() => !pauseEvent));

                yield return(new WaitForSeconds(SecondsForNextEvent));
            }

            eventTarget.Raise();

            nextEvent = nextEvent.AddSeconds(timeTrigger);

            if (dateTimeInitializer != null)
            {
                dateTimeInitializer.Value = nextEvent;
            }
        }
    }
コード例 #8
0
ファイル: DungeonEntrance.cs プロジェクト: Altadsa/Undercrypt
    private void OnTriggerEnter(Collider other)
    {
        var player = other.GetComponent <PlayerController>();

        if (player)
        {
            Debug.Log("Entering Dungeon");
            _onDungeonEntered.Raise();
        }
    }
コード例 #9
0
ファイル: TreasureChest.cs プロジェクト: Altadsa/Undercrypt
    private void OnTriggerEnter(Collider other)
    {
        Debug.Log("Triggered");
        var player = other.GetComponent <PlayerController>();

        if (player)
        {
            _onChestOpened.Raise();
            _chestAnimator.SetTrigger("Open");
        }
    }
コード例 #10
0
ファイル: LevelEnd.cs プロジェクト: Altadsa/The-Platformer
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (triggersLeft < 1)
     {
         return;
     }
     if (collision.gameObject.GetComponent <PlayerMovement>())
     {
         triggersLeft--;
         GameManager.Instance.OnLevelEnd();
         onLevelEnd.Raise();
     }
 }
コード例 #11
0
 protected void Buy()
 {
     if (PurchaseCondition())
     {
         if (currency.SpendCurrency(purchasePrice))
         {
             Debug.Log("Purchase succeeded.");
             OnPurchaseSucceeded.Raise();
             PurchaseSuccessful();
         }
         else
         {
             Debug.Log("Purchase failed, not enough currency.");
             OnPurchaseFailed.Raise();
         }
     }
     else
     {
         Debug.Log(ConditionMessage);
         OnPurchaseFailed.Raise();
     }
 }
コード例 #12
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUI.enabled = Application.isPlaying;

            ScriptableEvent e = target as ScriptableEvent;

            if (GUILayout.Button("Raise"))
            {
                e.Raise();
            }
        }
コード例 #13
0
    private void ConfigFetchComplete(ConfigResponse response)
    {
        foreach (var config in remoteConfigs)
        {
            ConfigManager.FetchCompleted -= config.LoadConfig;
        }

        ConfigManager.FetchCompleted -= ConfigFetchComplete;

        OnRemoteConfigLoadComplete.Raise();

        Debug.Log("Remote Config Fetch Complete.");
    }
    // Start is called before the first frame update
    void Update()
    {
        if (Input.GetAxis("Fire1") > 0 && dustCount >= maxDust)
        {
            Debug.Log("Supermode Activated");
            superMode = true;
            OnSupermodeEnabled.Raise();
        }

        if (superMode)
        {
            RemoveDust(Director.GetManager <TimeManager>().deltaTime *maxDust / superModeDuration);
        }
    }
コード例 #15
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.collider.GetComponent <DustBullet>())
     {
         Destroy(gameObject);
         Director.GetManager <ScoreManager>().AddScore(5);
         OnEnemyDeathEvent.Raise();
     }
     if (collision.collider.GetComponent <PlayerHealth>())
     {
         Destroy(gameObject);
         collision.collider.GetComponent <PlayerHealth>().Damage(damage);
     }
 }
コード例 #16
0
ファイル: DialogueManager.cs プロジェクト: Altadsa/Undercrypt
 public void GetNextSentence()
 {
     StopAllCoroutines();
     if (_currentSentenceIndex < _dialogueSentences.Length)
     {
         _text.text = "";
         StartCoroutine(TypeSentence());
     }
     else
     {
         _currentSentenceIndex = 0;
         _onDialogueFinished.Raise();
     }
 }
    public void RemoveDust(float dropped)
    {
        float _prevDust = dustCount;

        dustCount = Mathf.Clamp(dustCount - dropped, 0, maxDust);
        if (dustCount <= 0)
        {
            superMode = false;
            OnSupermodeDisabled.Raise();
        }
        if (dustCount != _prevDust)
        {
            OnDustCountChanged.Raise();
        }
    }
コード例 #18
0
    IEnumerator Start()
    {
        loadingBar.anchorMax = new Vector2(0, loadingBar.anchorMax.y);
        var initTime = Time.time;

        OnRemoteConfigLoadComplete.OnRaise += () => { IsRemoteConfigLoaded = true; };
        OnSceneLoad.Raise();

        var sw = new Stopwatch();

        sw.Start();
        yield return(new WaitUntil(() => CheckIfRemoteConfigLoaded(sw, 5000)));

        IsRemoteConfigLoaded = false;
        sw.Stop();

        var asyncLoad = SceneManager.LoadSceneAsync(sceneName);

        asyncLoad.allowSceneActivation = false;

        // Wait until the asynchronous scene fully loads
        while (!asyncLoad.isDone || Time.time - initTime <= delay)
        {
            var progress = GetAsyncOperationTimeWithDelay(asyncLoad, initTime, delay);
            loadingBar.anchorMax = new Vector2(progress, loadingBar.anchorMax.y);
            loadingBarText.text  = $"LOADING... {(int)(progress * 100)}%";
            yield return(new WaitForEndOfFrame());

            if (asyncLoad.progress >= 0.85f && progress >= 0.85f)
            {
                asyncLoad.allowSceneActivation = true;
            }
        }

        asyncLoad.allowSceneActivation = true;
        yield return(null);
    }
コード例 #19
0
 public void OnDoorClosed()
 {
     _onDoorClosed.Raise();
 }
コード例 #20
0
 public void OnDoorOpened()
 {
     _onDoorOpened.Raise();
 }
コード例 #21
0
ファイル: LevelStart.cs プロジェクト: Altadsa/The-Platformer
 private void Awake()
 {
     player.transform.position = transform.position;
     onLevelStarted.Raise();
 }
コード例 #22
0
 public void AddScore(int toAdd)
 {
     score += toAdd;
     ScoreChangedEvent.Raise();
 }
コード例 #23
0
 public void PickUpDust(DustMote pocket)
 {
     OnDustPickedUpEvent.Raise();
     dustController.PickupDust(pocket.dustValue);
     pocket.PickUp(this);
 }
コード例 #24
0
 private void Awake()
 {
     playerBody = GetComponent <CapsuleCollider2D>();
     health     = maxHealth;
     onPlayerHealthChanged.Raise();
 }
コード例 #25
0
    // Start is called before the first frame update

    IEnumerator Start()
    {
        yield return(new WaitForEndOfFrame());

        Queue <Wave> waveQueue = new Queue <Wave>();

        for (int i = startFromWave; i < waves.Count; i++)
        {
            waveQueue.Enqueue(waves[i]);
        }
        List <EnemySpawner> activeSpawners = new List <EnemySpawner>();

        List <EnemyDuster> activeEnemies = new List <EnemyDuster>();

        if (waveQueue.Count > 0)
        {
            nextWave = waveQueue.Peek();
            OnNextWaveReady.Raise();
        }

        float startTimer = timeBeforeStart;

        while (startTimer > 0)
        {
            startTimer -= Director.GetManager <TimeManager>().deltaTime;
            yield return(new WaitForEndOfFrame());
        }
        while (waveQueue.Count > 0)
        {
            //take first wave
            Wave currentWave = waveQueue.Dequeue();

            //run through all the wave parts
            foreach (var part in currentWave.parts)
            {
                Queue <Vector2> positionQueue = new Queue <Vector2>();
                if (part.ordered)
                {
                    positionQueue = new Queue <Vector2>(part.area.GetOrderedPoints(part.enemyCount));
                }
                else
                {
                    for (int i = 0; i < part.enemyCount; i++)
                    {
                        positionQueue.Enqueue(part.area.GetRandomPoint(part.edge));
                    }
                }
                //spawn all enemies as intended
                for (int i = 0; i < part.enemyCount; i++)
                {
                    Vector2 position = boundaries.ClampToBoundary(positionQueue.Dequeue());
                    if (part.followPlayer)
                    {
                        position += (Vector2)player.transform.position;
                    }
                    //add all enemies to a list of enemies
                    var spawner = Instantiate(spawnerPrefab, position, Quaternion.identity);
                    spawner.StartCount(2);
                    activeSpawners.Add(spawner);
                    spawner.OnEnemySpawn += (enemy) =>
                    {
                        activeSpawners.Remove(spawner);
                        activeEnemies.Add(enemy);
                        enemy.OnKill = () =>
                        {
                            activeEnemies.Remove(enemy);
                        };
                    };
                    if (!part.instant)
                    {
                        float enemyTimer = timeBetweenEnemies;
                        while (enemyTimer > 0)
                        {
                            enemyTimer -= Director.GetManager <TimeManager>().deltaTime;
                            yield return(new WaitForEndOfFrame());
                        }
                    }
                }
                float partTimer = timeBetweenEnemies;
                while (partTimer > 0)
                {
                    partTimer -= Director.GetManager <TimeManager>().deltaTime;
                    yield return(new WaitForEndOfFrame());
                }
            }
            while (activeEnemies.Count > 0 || activeSpawners.Count > 0)
            {
                yield return(new WaitForEndOfFrame());
            }
            if (waveQueue.Count > 0)
            {
                nextWave = waveQueue.Peek();
                OnNextWaveReady.Raise();
            }
            float waveTimer = timeBetweenWaves;
            while (waveTimer > 0)
            {
                waveTimer -= Director.GetManager <TimeManager>().deltaTime;
                yield return(new WaitForEndOfFrame());
            }
        }
        OnLastWaveClear.Raise();
    }
コード例 #26
0
 void ShootBullet(Vector2 direction)
 {
     OnShootEvent.Raise();
     Instantiate(bulletPrefab, transform.position, Quaternion.identity).transform.up = direction;
 }