Exemplo n.º 1
0
    private void beginSceneTransition(LocalEventNotifier.Event e)
    {
        string nextSceneName = (e as BeginSceneTransitionEvent).NextSceneName;

        if (_musicDict.ContainsKey(nextSceneName) && _musicDict[nextSceneName] != this.AudioSource.clip)
        {
            this.VolumeFader.BeginFade(this.FadeOutDuration, 0.0f);
        }
    }
Exemplo n.º 2
0
    private void playerSpawned(LocalEventNotifier.Event e)
    {
        PlayerSpawnedEvent playerSpawnedEvent = e as PlayerSpawnedEvent;
        PlayerController   playerController   = playerSpawnedEvent.PlayerObject.GetComponent <PlayerController>();

        playerController.Slots = new List <ProgressData.SlotWrapper>(ProgressData.WeaponSlotsByPlayer[playerSpawnedEvent.PlayerIndex]);
        _playerControllers[playerSpawnedEvent.PlayerIndex] = playerController;
        playerController.SetInitialHealth(ProgressData.GetHealthForPlayer(playerSpawnedEvent.PlayerIndex));
    }
Exemplo n.º 3
0
    private void playerSpawned(LocalEventNotifier.Event e)
    {
        PlayerSpawnedEvent playerSpawnedEvent = e as PlayerSpawnedEvent;

        if (playerSpawnedEvent.PlayerIndex == this.PlayerIndex)
        {
            _targetPlayerTransform = playerSpawnedEvent.PlayerObject.transform;
        }
    }
Exemplo n.º 4
0
    private void pointsReceived(LocalEventNotifier.Event e)
    {
        SessionPlayer player = DynamicData.GetSessionPlayer(this.PlayerIndex);

        if (player.HasJoined && player.PlayerIndex == ((PlayerPointsReceivedEvent)e).PlayerIndex)
        {
            this.UpdateLength(ProgressData.GetHealthForPlayer(this.PlayerIndex), ProgressData.MAX_HEALTH);
        }
    }
Exemplo n.º 5
0
    private void playerScoreUpdated(LocalEventNotifier.Event e)
    {
        PlayerPointsReceivedEvent pointsEvent = e as PlayerPointsReceivedEvent;

        if (pointsEvent.PlayerIndex == this.PlayerIndex)
        {
            this.ScoreText.text = _prefix + ProgressData.GetPointsForPlayer(this.PlayerIndex);
        }
    }
Exemplo n.º 6
0
 private void playerDied(LocalEventNotifier.Event e)
 {
     if ((e as PlayerDiedEvent).PlayerIndex == this.PlayerIndex)
     {
         _rectTransform.position = new Vector3(-99999, -99999, _rectTransform.position.z);
         _player           = null;
         _playerController = null;
     }
 }
Exemplo n.º 7
0
    private void playerDied(LocalEventNotifier.Event e)
    {
        --_playerCount;

        if (_playerCount <= 0)
        {
            this.GameOver();
        }
    }
Exemplo n.º 8
0
    private void playerSpawned(LocalEventNotifier.Event e)
    {
        Transform playerTransform = (e as PlayerSpawnedEvent).PlayerObject.transform;

        this.Targets.Add(playerTransform);
        for (int i = 0; i < this.BossGroups.Count; ++i)
        {
            this.BossGroups[i].Targets.Add(playerTransform);
        }
    }
Exemplo n.º 9
0
    /**
     * Private
     */
    private void playerSpawned(LocalEventNotifier.Event playerSpawnedEvent)
    {
        PlayerSpawnedEvent spawnEvent = playerSpawnedEvent as PlayerSpawnedEvent;

        if (spawnEvent.PlayerIndex == this.PlayerIndex)
        {
            GlobalEvents.Notifier.RemoveListenersForOwnerAndEventName(this, PlayerPointsReceivedEvent.NAME);
            spawnEvent.PlayerObject.GetComponent <Damagable>().OnHealthChangeCallbacks.Add(healthUpdated);
        }
    }
Exemplo n.º 10
0
 private void execute(LocalEventNotifier.Event e)
 {
     if (this.Delay > 0)
     {
         _delayTimer.start();
     }
     else
     {
         onDelayComplete();
     }
 }
Exemplo n.º 11
0
    private void pointsReceived(LocalEventNotifier.Event e)
    {
        SessionPlayer player = DynamicData.GetSessionPlayer(this.PlayerIndex);

        if (player.HasJoined && player.PlayerIndex == ((PlayerPointsReceivedEvent)e).PlayerIndex)
        {
            for (int i = 0; i < this.Slots.Length; ++i)
            {
                this.Slots[i].UpdateWithSessionPlayer(player);
            }
        }
    }
Exemplo n.º 12
0
 private void resume(LocalEventNotifier.Event e)
 {
     PauseController.PauseGroup group = (e as ResumeEvent).PauseGroup;
     if (_currentPausedLayers != 0 && isAffected(group) && (_currentPausedLayers & (uint)group) != 0)
     {
         _currentPausedLayers = _currentPausedLayers.Approach(0, (uint)group);
         if (_currentPausedLayers == 0)
         {
             resumePausables();
         }
     }
 }
Exemplo n.º 13
0
 private void okToBegin(LocalEventNotifier.Event e)
 {
     if (_readyToSpawn)
     {
         _readyToSpawn = false;
         begin();
     }
     else
     {
         _okToBegin = true;
     }
 }
Exemplo n.º 14
0
    private void menuSelection(LocalEventNotifier.Event e)
    {
        MenuElementSelectedEvent menuSelectionEvent = e as MenuElementSelectedEvent;

        if (menuSelectionEvent.Element == _menuElement)
        {
            if (this.SlotType != WeaponData.Slot.Empty)
            {
                if (ProgressData.GetPointsForPlayer(this.PlayerIndex) >= _cost)
                {
                    ProgressData.SmartSlot[] smartSlots = ProgressData.GetSmartSlots(this.PlayerIndex);
                    bool ok = true;
                    for (int i = 0; i < smartSlots.Length; ++i)
                    {
                        if (smartSlots[i].SlotType == this.SlotType)
                        {
                            ok = smartSlots[i].Level < WeaponData.GetMaxSlotsByType()[this.SlotType] || smartSlots[i].Ammo < WeaponData.GetSlotDurationsByType()[this.SlotType];
                            break;
                        }
                    }
                    if (ok)
                    {
                        this.SelectionImage.color = _normalColor;
                        ProgressData.ApplyPointsDeltaForPlayer(this.PlayerIndex, -_cost);
                        ProgressData.PickupSlot(this.PlayerIndex, this.SlotType);
                        GlobalEvents.Notifier.SendEvent(new PlayerPointsReceivedEvent(this.PlayerIndex, -_cost));
                        updateDisplay();
                    }
                    else
                    {
                        this.SelectionImage.color = this.NotEnoughColor;
                    }
                }
                else
                {
                    this.SelectionImage.color = this.NotEnoughColor;
                }
            }
            else if (ProgressData.GetHealthForPlayer(this.PlayerIndex) < ProgressData.MAX_HEALTH && ProgressData.GetPointsForPlayer(this.PlayerIndex) >= _cost)
            {
                this.SelectionImage.color = _normalColor;
                ProgressData.SetHealthForPlayer(this.PlayerIndex, ProgressData.GetHealthForPlayer(this.PlayerIndex) + 1);
                ProgressData.ApplyPointsDeltaForPlayer(this.PlayerIndex, -_cost);
                GlobalEvents.Notifier.SendEvent(new PlayerPointsReceivedEvent(this.PlayerIndex, -_cost));
                updateDisplay();
            }
            else
            {
                this.SelectionImage.color = this.NotEnoughColor;
            }
        }
    }
Exemplo n.º 15
0
    /**
     * Private
     */
    private void playerSpawned(LocalEventNotifier.Event playerSpawnedEvent)
    {
        PlayerSpawnedEvent spawnEvent = playerSpawnedEvent as PlayerSpawnedEvent;

        if (spawnEvent.PlayerIndex == this.PlayerIndex)
        {
            GlobalEvents.Notifier.RemoveListenersForOwnerAndEventName(this, PlayerPointsReceivedEvent.NAME);
            foreach (UISlot slot in this.Slots)
            {
                slot.SetPlayer(spawnEvent.PlayerObject);
            }
        }
    }
Exemplo n.º 16
0
    private void levelComplete(LocalEventNotifier.Event e)
    {
        for (int i = 0; i < _playerControllers.Length; ++i)
        {
            PlayerController           playerController = _playerControllers[i];
            ProgressData.SlotWrapper[] slots            = playerController != null?playerController.Slots.ToArray() : new ProgressData.SlotWrapper[0];

            ProgressData.UpdatePlayerSlots(i, slots);
            if (DynamicData.GetSessionPlayer(i).HasJoined)
            {
                ProgressData.SetHealthForPlayer(i, playerController != null ? playerController.GetComponent <Damagable>().Health : 0);
            }
        }
    }
Exemplo n.º 17
0
    public void OnHit(LocalEventNotifier.Event localEvent)
    {
        GameObject hit = ((HitEvent)localEvent).Hit;

        if (((1 << hit.layer) & this.DamagableLayers) != 0 && !_alreadyHitThisUpdate.Contains(hit))
        {
            Damagable damagable = hit.GetComponent <Damagable>();
            if (damagable != null && !damagable.Invincible)
            {
                damagable.ReceiveDamage(this);
                this.ApplyDamage(damagable);
            }
        }
    }
Exemplo n.º 18
0
    private void playerSpawned(LocalEventNotifier.Event e)
    {
        PlayerSpawnedEvent playerSpawnedEvent = e as PlayerSpawnedEvent;

        if (playerSpawnedEvent.PlayerIndex == this.PlayerIndex)
        {
            SessionPlayer p = DynamicData.GetSessionPlayer(this.PlayerIndex);
            if (p.HasJoined && !ReInput.players.GetPlayer(p.RewiredId).controllers.hasMouse)
            {
                _player           = p;
                _playerController = playerSpawnedEvent.PlayerObject.GetComponent <PlayerController>();
                _playerController.SetUsingController();
            }
        }
    }
Exemplo n.º 19
0
    public void OnHit(LocalEventNotifier.Event localEvent)
    {
        if (this.Invincible)
            return;

        GameObject hit = ((HitEvent)localEvent).Hit;
        if (((1 << hit.layer) & this.DamagerLayers) != 0 && !_alreadyHitThisUpdate.Contains(hit))
        {
            Damager damager = hit.GetComponent<Damager>();
            if (damager != null)
            {
                damager.ApplyDamage(this);
                this.ReceiveDamage(damager);
            }
        }
    }
Exemplo n.º 20
0
    public void OnInvincibilityToggle(LocalEventNotifier.Event localEvent)
    {
        _activated = ((InvincibilityToggleEvent)localEvent).ToggledOn;

        if (_activated)
        {
            _normalColor = this.spriteRenderer.color;
            flashOn();
        }
        else
        {
            _blinking = false;
            this.spriteRenderer.color = _normalColor;
            _blinkTimer = 0.0f;
        }
    }
Exemplo n.º 21
0
    void choiceMade(LocalEventNotifier.Event e)
    {
        MenuElementSelectedEvent selectionEvent = e as MenuElementSelectedEvent;

        if (selectionEvent.Action.ToLower() == "choice_a")
        {
            PersistentData.RegisterAcceptedMaster();
            PersistentData.RecordHighScore();
            PersistentData.SaveToDisk();
        }
        else if (selectionEvent.Action.ToLower() == "choice_b")
        {
            GlobalEvents.Notifier.SendEvent(new PlayMusicEvent());
            PersistentData.RegisterRefusedMaster();
            PersistentData.SaveToDisk();
        }
    }
Exemplo n.º 22
0
    private void handleAction(Menu.Action action, int dir = 1)
    {
        switch (action.Type)
        {
        default:
        case Menu.ActionType.None:
            break;

        case Menu.ActionType.OpenMenu:
            _pastMenuStack.Add(_currentMenu.Name);
            configureForState(action.Param);
            break;

        case Menu.ActionType.SceneTransition:
            this.Hide();
            _actionTimer   = new Timer(this.SceneTransitionDelay, false, true, onDelayedAction);
            _timerParam    = action.Param;
            _changingScene = true;

            LocalEventNotifier.Event e = new LocalEventNotifier.Event();
            e.Name = this.EndSceneEvent;
            GlobalEvents.Notifier.SendEvent(e);
            break;

        case Menu.ActionType.CloseMenuWithEvent:
            this.Hide();
            _actionTimer = new Timer(this.EventSendDelay, false, true, onDelayedAction);
            _timerParam  = action.Param;
            break;

        case Menu.ActionType.ChangeValue:
            OptionsValues.ChangeValue(action.Param, dir);
            refreshState();
            break;

        case Menu.ActionType.Reload:
            for (int i = 0; i < _pastMenuStack.Count; ++i)
            {
                menuByStateName(_pastMenuStack[i]).Reload();
            }
            _currentMenu.Reload();
            refreshState();
            break;
        }
    }
Exemplo n.º 23
0
    private void choiceMade(LocalEventNotifier.Event eventObject)
    {
        MenuElementSelectedEvent selectionEvent = eventObject as MenuElementSelectedEvent;

        if (selectionEvent.Action.ToLower() == "choice_a")
        {
            this.PageHandler.AddPage(this.Choices[_choiceIndex].ResultTextA);
            _destination = this.Choices[_choiceIndex].DestinationA;
            ++_choiceIndex;
            this.ChoiceMenu.SetActive(false);
            this.PageHandler.IncrementPage();
        }
        else if (selectionEvent.Action.ToLower() == "choice_b")
        {
            this.PageHandler.AddPage(this.Choices[_choiceIndex].ResultTextB);
            _destination = this.Choices[_choiceIndex].DestinationB;
            ++_choiceIndex;
            this.ChoiceMenu.SetActive(false);
            this.PageHandler.IncrementPage();
        }
    }
Exemplo n.º 24
0
 public void OnCollide(LocalEventNotifier.Event localEvent)
 {
     foreach (GameObject hit in ((CollisionEvent)localEvent).Hits)
     {
         if (((1 << hit.layer) & this.PickupLayer) != 0)
         {
             WeaponPickup pickup = hit.GetComponent <WeaponPickup>();
             if (pickup != null)
             {
                 if (pickup.PickupContents.Type == WeaponPickup.PickupType.WeaponSlot)
                 {
                     WeaponData.Slot          slotType   = (WeaponData.Slot)pickup.PickupContents.Parameter;
                     ProgressData.SmartSlot[] smartSlots = ProgressData.SmartSlotsFromWrappers(this.Slots.ToArray());
                     bool ok = true;
                     for (int i = 0; i < smartSlots.Length; ++i)
                     {
                         if (smartSlots[i].SlotType == slotType)
                         {
                             ok = smartSlots[i].Level < WeaponData.GetMaxSlotsByType()[slotType] || smartSlots[i].Ammo < WeaponData.GetSlotDurationsByType()[slotType];
                             break;
                         }
                     }
                     if (ok)
                     {
                         pickupWeaponSlot(slotType);
                         Destroy(hit);
                     }
                 }
                 else
                 {
                     if (_damagable.Health < ProgressData.MAX_HEALTH)
                     {
                         _damagable.Heal(pickup.PickupContents.Parameter);
                         Destroy(hit);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 25
0
    public void OnCollide(LocalEventNotifier.Event localEvent)
    {
        CollisionEvent collision = localEvent as CollisionEvent;

        bool bounced = false;

        foreach (GameObject hit in collision.Hits)
        {
            LayerMask hitLayerMask = (1 << hit.layer);
            if (_bouncesRemaining > 0 && (hitLayerMask & this.BounceLayerMask) != 0)
            {
                if (!bounced)
                {
                    bounce(hit, collision.VelocityAtHit, collision.VelocityApplied);
                }
            }
            else if ((hitLayerMask & this.HaltMovementMask) != 0)
            {
                scheduleDestruction(this.transform.position);
            }
        }
    }
Exemplo n.º 26
0
    public void OnCollide(LocalEventNotifier.Event localEvent)
    {
        CollisionEvent collision = localEvent as CollisionEvent;

        foreach (GameObject hit in collision.Hits)
        {
            if (this.CollisionWeaponType != null && this.CollisionWeaponType.SpecialEffect == WeaponType.SPECIAL_EXPLOSION && ((1 << hit.layer) & this.GetComponent <Damager>().DamagableLayers) != 0)
            {
                // Explode on impact
                Damagable damagable = this.GetComponent <Damagable>();
                while (damagable.Health > 0)
                {
                    damagable.ReceiveDamage(this.GetComponent <Damager>());
                }
            }
            else if (((1 << hit.layer) & this.BounceLayerMask) != 0)
            {
                _actor.Bounce(hit, collision.VelocityAtHit, collision.VelocityApplied, this.BounceLayerMask, 0.0f);
                break;
            }
        }
    }
Exemplo n.º 27
0
    public void OnLaserCast(LocalEventNotifier.Event localEvent)
    {
        LaserCastEvent castEvent = (LaserCastEvent)localEvent;

        CollisionManager.RaycastResult raycast = castEvent.RaycastResult;

        IntegerVector distance = raycast.FarthestPointReached - castEvent.Origin;

        if (distance.X == 0 && distance.Y == 0)
        {
            return;
        }

        GameObject lineObject = ObjectPools.GetPooledObject(this.LineObjectKey);

        _lineObjects.Add(lineObject);
        //lineObject.transform.parent = this.transform;
        lineObject.transform.position = new Vector3(castEvent.Origin.X, castEvent.Origin.Y, this.transform.position.z);

        lineObject.GetComponent <LineRenderer>().SetPosition(1, new Vector3(raycast.FarthestPointReached.X - castEvent.Origin.X, raycast.FarthestPointReached.Y - castEvent.Origin.Y, 0));
        lineObject.GetComponent <AllegianceColorizer>().UpdateVisual(castEvent.AllegianceInfo);
    }
Exemplo n.º 28
0
    private void onDelayedAction()
    {
        _actionTimer = null;

        if (_changingScene)
        {
            if (_timerParam.IsEmpty())
            {
                Application.Quit();
            }
            else
            {
                SceneManager.LoadScene(_timerParam, LoadSceneMode.Single);
            }
        }
        else
        {
            LocalEventNotifier.Event e = new LocalEventNotifier.Event();
            e.Name = _timerParam;
            GlobalEvents.Notifier.SendEvent(e);
            _timerParam = null;
        }
    }
Exemplo n.º 29
0
    private void pause(LocalEventNotifier.Event e)
    {
        PauseController.PauseGroup group = (e as PauseEvent).PauseGroup;
        if (isAffected(group) && (_currentPausedLayers & (uint)group) != (uint)group)
        {
            bool prevPaused = _currentPausedLayers != 0;
            _currentPausedLayers += (uint)group;

            if (!prevPaused)
            {
                for (int i = 0; i < _pausables.Count;)
                {
                    if (_pausables[i].Pause())
                    {
                        ++i;
                    }
                    else
                    {
                        _pausables.RemoveAt(i);
                    }
                }
            }
        }
    }
Exemplo n.º 30
0
 private void gameplayBegin(LocalEventNotifier.Event e)
 {
     _timedCallbacks.AddCallback(this, begin, this.InitialDelay);
 }