예제 #1
0
    private void Awake()
    {
        // Initiazing note to sprite map.
        _buttonSpritesDictionary = new Dictionary <InputNote, Sprite>();
        for (int i = 0; i < buttonSprites.Length; i++)
        {
            _buttonSpritesDictionary.Add(buttonSprites[i].noteType, buttonSprites[i].sprite);
        }

        MessageKit.addObserver(GameEvents.MORALE_CHANGED, () => {
            SetMoraleValue(LevelController.Instance.playersMorale);
        });

        MessageKit.addObserver(GameEvents.QUEUE_CHANGED, () => {
            UpdateQueue();
        });

        //MessageKit.addObserver(GameEvents.AUTO_HIT, () => {
        //    PaintNoteRed();
        //});

        MessageKit.addObserver(GameEvents.RESTORE_COLOR, () => {
            ResetButtonColor();
        });

        MessageKit.addObserver(GameEvents.GAME_OVER, () => {
            OnEndGame();
        });
    }
예제 #2
0
    void Start()
    {
        _originalPos = _camera.localPosition;

        MessageKit.addObserver(GameEvents.P1_DAMAGE, OnDamage);
        MessageKit.addObserver(GameEvents.P2_DAMAGE, OnDamage);
    }
    //TODO don't do this every frame update ;)
    //Do it only when screen size changed
    void Update()
    {
        float height = 2 * Camera.main.orthographicSize;
        float width  = height * Camera.main.aspect;

        MessageKit <Vector2> .post(MessageIds.SCREEN_SIZE, new Vector2(width, height));
    }
예제 #4
0
 void Awake()
 {
     main     = this;
     _focused = true;
     MessageKit.addObserver(Messages.LoadingFinished, EnableCursor);
     MessageKit.addObserver(Messages.Loading, DisableCursor);
 }
예제 #5
0
    void Start()
    {
        // Initialize model data
        Init();

        // Registers an observer for the beat ended event.
        MessageKit.addObserver(GameEvents.BEAT_ENDED, ProcessNotes);

        MessageKit.addObserver(GameEvents.END_OF_BEATS, () => {
            for (int i = 0; i < NUMBER_OF_PLAYERS; i++)
            {
                _ignoreInput[i] = true;
            }
        });

        // Spawn Initial notes
        for (int p = 0; p < NUMBER_OF_PLAYERS; p++)
        {
            for (int i = 0; i < NUMBER_OF_INITIAL_NOTES; i++)
            {
                playerNotes[p].Enqueue(GetRandomNote());
            }
        }

        MessageKit.post(GameEvents.QUEUE_CHANGED);



        // Let the party begin!
        AudioController.Instance.Play(song);
    }
예제 #6
0
    void Awake()
    {
        playerHealthBar = GameObject.Find("HP_Bar").GetComponent <Image>();
        MessageKit <int, int> .addObserver(EventTypes.PLAYER_TAKE_DAMAGE_2P, UpdatePlayerHealthBar);

        MessageKit <int, int> .addObserver(EventTypes.PLAYER_HEAL_DAMAGE_2P, UpdatePlayerHealthBar);
    }
 private void Start()
 {
     pauseMenu = GetComponent <Canvas>();
     MessageKit.addObserver(EventTypes.UI_PAUSE_MENU, TogglePauseMenu);
     EnableGameplayControls();
     DisableUIControls();
 }
 private void Start()
 {
     MessageKit.addObserver(EventTypes.JUMP_INPUT_DOWN, OnJumpInputDown);
     MessageKit.addObserver(EventTypes.JUMP_INPUT_UP, OnJumpInputUp);
     controller         = GetComponent <Controller2D>();
     gravityController  = GetComponent <GravityController>();
     movementController = GetComponent <MovementController>();
 }
    void OnDestroy()
    {
        MessageKit <AsteroidKillInfo> .removeObserver(MessageIds.ASTEROID_KILLED, AsteroidKilled);

        MessageKit <Vector2> .removeObserver(MessageIds.SCREEN_SIZE, UpdateScreenSize);

        MessageKit.removeObserver(MessageIds.INIT_RESTART, Restart);
    }
예제 #10
0
    ///////////////////////////////////

    void Start()
    {
        //===== Add Key input handlers
        MessageKit <keyTracker> .addObserver((int)InputMsg.key_shift, ShiftKey_keyPress);

        //Building right click mask starts disabled
        GO_rightClickQuad.SetActive(false);
    }
    protected override void Start()
    {
        base.Start();
        MessageKit.addObserver(EventTypes.JUMP_INPUT_DOWN, JumpAnimation);
        MessageKit <string, string> .addObserver(EventTypes.ATTACK_INPUT_DOWN_2P, TriggerAttackAnimation);

        //MessageKit<string, string>.addObserver(EventTypes.DASH_ATTACK_INPUT_DOWN_2P, TriggerDashAttackAnimation);
    }
예제 #12
0
    private void OnDestroy()
    {
        MessageKit.removeObserver(MessageIds.PLAYER_KILLED, HandlePlayerKilled);
        MessageKit.removeObserver(MessageIds.INIT_RESTART, HandleRestart);
        MessageKit <float> .removeObserver(MessageIds.AMMO_LEFT, HandleAmmo);

        MessageKit <TargetCollider> .removeObserver(MessageIds.TARGET_HIT, HandleTargetHit);
    }
예제 #13
0
    void Awake()
    {
        MessageKit <keyTracker> .addObserver((int)InputMsg.key_scroll, Scroll_keyPress);

        camTrans = myCam.GetComponent <Transform>();

        bound_upper_Y = loc_bound_ZoomOut.transform.position.y;
        bound_lower_Y = loc_bound_ZoomIn.transform.position.y;
    }
예제 #14
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.R) && !_playerInstance.activeInHierarchy)
        {
            TrashMan.spawn(playerPrefab);

            MessageKit.post(MessageIds.INIT_RESTART);
        }
    }
예제 #15
0
    void Start()
    {
        MessageKit <AsteroidKillInfo> .addObserver(MessageIds.ASTEROID_KILLED, AsteroidKilled);

        MessageKit <Vector2> .addObserver(MessageIds.SCREEN_SIZE, UpdateScreenSize);

        MessageKit.addObserver(MessageIds.INIT_RESTART, Restart);
        Restart();
    }
예제 #16
0
    void Awake()
    {
        MessageKit <keyTracker> .addObserver(myMsgType, keyPress);

        camTrans = myCam.GetComponent <Transform>();

        v2_bound_LowerUpper = new Vector2(loc_bound_Lower.transform.localPosition.z,
                                          loc_bound_Upper.transform.localPosition.z);
    }
예제 #17
0
    // Start is called before the first frame update
    void Start()
    {
        MessageKit.addObserver(GameEvents.BEAT_ENDED, () =>
        {
            Debug.Break();
        });

        //AudioController.Instance.Play();
    }
예제 #18
0
    // Start is called before the first frame update
    void Start()
    {
        MessageKit.addObserver(MessageIds.PLAYER_KILLED, HandlePlayerKilled);
        MessageKit.addObserver(MessageIds.INIT_RESTART, HandleRestart);
        MessageKit <float> .addObserver(MessageIds.AMMO_LEFT, HandleAmmo);

        MessageKit <TargetCollider> .addObserver(MessageIds.TARGET_HIT, HandleTargetHit);

        HandleRestart();
    }
 private void Start()
 {
     MessageKit.addObserver(EventTypes.JUMP_INPUT_DOWN, OnJumpInputDown);
     controller         = GetComponent <Controller2D>();
     gravityController  = GetComponent <GravityController>();
     movementController = GetComponent <MovementController>();
     jumpController     = GetComponent <JumpController>();
     animController     = GetComponent <AnimatorController>();
     playerAudio        = GetComponent <PlayerAudio>();
 }
예제 #20
0
    IEnumerator Do_Move()
    {
        while (allKTs[ktIndex].is_KeyDown)
        {
            //Simulate keypress while mouse in in this area
            MessageKit <keyTracker> .post(allKTs[ktIndex].keyMsg, allKTs[ktIndex]);

            yield return(new WaitForFixedUpdate());
        }
    }
 private void FixedUpdate()
 {
     if (player != null)
     {
         if (player.transform.position.y < triggerDeathPositionY)
         {
             MessageKit.post(EventTypes.PLAYER_DIED);
         }
     }
 }
예제 #22
0
    public void Die()
    {
        TrashMan.despawn(gameObject);

        var particles = TrashMan.spawn(explosionPrefab, transform.position).GetComponent <ParticleSystem>();

        particles.Clear();
        particles.Play();

        MessageKit.post(MessageIds.PLAYER_KILLED);
    }
예제 #23
0
    private void Start()
    {
        MessageKit.addObserver(GameEvents.P2_DAMAGE, PlayPlayer1Success);
        MessageKit.addObserver(GameEvents.P1_DAMAGE, PlayPlayer2Success);


        MessageKit.addObserver(GameEvents.P1_MISS, PlayPlayer1Failure);
        MessageKit.addObserver(GameEvents.P2_MISS, PlayPlayer2Failure);

        MessageKit.addObserver(GameEvents.CONFUSION, PlayVaia);
    }
예제 #24
0
    public void ReleasePress()
    {
        _is_KeyDown    = false;
        _is_FirstFrame = false;
        _value_keyAxis = 0f;

        //Send 1 final message when key is released
        MessageKit <keyTracker> .post(_keyMsg, this);

        _dura_KeyPress = 0f;
    }
예제 #25
0
    //Use awake so this will register once when it is turned on
    public void Awake()
    {
        //get ref to image on this button
        _image = this.gameObject.GetComponent <Image>();

        //store starting color
        _defaultColor = _image.color;

        //===== Add Key input handlers for Hotkey
        MessageKit <keyTracker> .addObserver((int)myHotkey, hotkeyPress);

        DoAwake();
    }
예제 #26
0
    public void Heal(int healAmount)
    {
        if (currentHealth + healAmount > maxHealth)
        {
            currentHealth = maxHealth;
        }
        else
        {
            currentHealth += healAmount;
        }

        MessageKit <int, int> .post(EventTypes.PLAYER_HEAL_DAMAGE_2P, currentHealth, maxHealth);
    }
    private void Awake()
    {
        enemies      = GameObject.FindGameObjectsWithTag("Enemy");
        player       = GameObject.Find("Player");
        healthPickup = GameObject.Find("HealthPickup");
        checkpoint   = GameObject.Find("Checkpoint").GetComponent <Checkpoint>();
        MessageKit.addObserver(EventTypes.PLAYER_DIED, LoadTitleScene);
        MessageKit.addObserver(EventTypes.BOSS_DIED, LoadWinScene);

        if (checkpoint.hasReachedCheckpoint == true)
        {
            SetUpSceneForCheckpoint();
        }
    }
예제 #28
0
    // Update is called once per frame
    void Update()
    {
        _ammo = Mathf.Clamp01(_ammo + ammoRegen * Time.deltaTime);

        if (Input.GetKey(KeyCode.Space) && Time.time > _lastShotTime + cooldown && _ammo > ammoCost)
        {
            _ammo        -= ammoCost;
            _lastShotTime = Time.time;
            InitSpeedAndTorque speedAndTorque = TrashMan.spawn(projectile, transform.position, transform.rotation).GetComponent <InitSpeedAndTorque>();
            speedAndTorque.Go();
        }

        MessageKit <float> .post(MessageIds.AMMO_LEFT, _ammo);
    }
    // Use this for initialization
    void Start()
    {
        // listeners
        MessageKit <ChunkInfo> .addObserver(MsgType.PlayerChangedChunk, LoadAllNeighbors);

        // setup
        originChunk.info      = new ChunkInfo(0, 0);
        currentChunk          = originChunk;
        currentChunk.info.obj = currentChunk;
        originChunk.GetComponentInChildren <ElevationDeform>().Deform();
        originChunk.GetComponentInChildren <PropPlacer>().Place();
        allChunkInfo.Add(currentChunk.info);
        StartCoroutine(LoadAround(currentChunk.info));
    }
예제 #30
0
    public void Die()
    {
        TrashMan.despawn(gameObject);

        AsteroidKillInfo killInfo = new AsteroidKillInfo();

        killInfo.asteroid = gameObject;
        killInfo.scale    = asteroidChildController.CurrentScale;
        MessageKit <AsteroidKillInfo> .post(MessageIds.ASTEROID_KILLED, killInfo);

        var particles = TrashMan.spawn(asteroidExplosionPrefab, transform.position).GetComponent <ParticleSystem>();

        particles.Clear();
        particles.Play();
    }