void SubscribeToEvents()
    {
        EventManager.Subscribe <GameFSMStates>(GameFSM.EVT_ON_CHANGE_GAME_STATE, (CurrentState) =>
        {
            ToggleInGameUI(CurrentState == GameFSMStates.MAINMENU);
        });

        EventManager.Subscribe <GameFSMStates>(GameFSM.EVT_ON_CHANGE_GAME_STATE, (CurrentState) =>
        {
            ToggleInGameUI(CurrentState == GameFSMStates.GAMEOVER);
        });

        EventManager.Subscribe <GameFSMStates>(GameFSM.EVT_ON_CHANGE_GAME_STATE, (CurrentState) =>
        {
            ToggleInGameUI(CurrentState != GameFSMStates.MAINMENU || CurrentState != GameFSMStates.GAMEOVER);
        });

        //0 for player ID
        EventManager.Subscribe <ObjectStats>(EventConst.GetUpdatePlayerStats(0), (currentStats) => ShowStats(currentStats));
        EventManager.Subscribe <float>(EventConst.GetUpdatePlayerHealth(0), (health) => healthBar.UpdateFill(health));
        EventManager.Subscribe <float>(EventConst.GetUpdatePlayerFuel(0), (fuel) => fuelBar.UpdateFill(fuel));
        EventManager.Subscribe <Vector2>(EventConst.GetUpdateUIPosAim(0), (mPos) => UpdateCursorPosition(mPos));
        EventManager.Subscribe <bool>(EventConst.GetUpdateAimTargetInSight(0), (isInSight) => UpdateTargetInSight(isInSight));
    }
Beispiel #2
0
    //void DestroyStickingObject(StickingObject stickingObject)
    //{
    //    if(this.stickingObject == stickingObject)
    //    {
    //        Debug.Log("I DIE OH NON");
    //        EventManager.Invoke<Player>(EVT_ON_PLAYER_DEATH,this);
    //        gameObject.SetActive(false);
    //    }
    //}

    public void OnDamage(float healthRatio)
    {
        Debug.Log(healthRatio);
        EventManager.Invoke <float>(EventConst.GetUpdatePlayerHealth(ID), healthRatio);
    }