Example #1
0
    public void AddNamedStateEvent(LevelUnitStates state, string eventName)
    {
        levelUnitStates.Add(state);
        List <string> stateEvents = GetStateEvents(state);

        AddEvent(ref stateEvents, eventName);
    }
Example #2
0
    public bool CheckForEvent(string eventName, LevelUnitStates state)
    {
        bool result = false;

        result = GetStateEvents(state).Contains(eventName);
        return(result);
    }
Example #3
0
 private void TriggerColorShift(LevelUnitStates newState)
 {
     Timing.KillCoroutines(TintCoroutineName);
     startAlbedoColor  = CurrentAlbedoColor;
     targetAlbedoColor = GetAlbedoColor(newState);
     colorShiftAnim.Animate(TintCoroutineName);
 }
Example #4
0
        public void RegisterEvent()
        {
            for (int j = 0; j < m_GameObjects.Count; j++)
            {
                LevelUnit LU = m_GameObjects[j].GetComponent <LevelUnit>();

                if (LU)
                {
                    LU.DeRegisterFromNamedStateEvents();
                }
            }

            for (int j = 0; j < m_GameObjects.Count; j++)
            {
                LevelUnit LU = m_GameObjects[j].GetComponent <LevelUnit>();

                if (LU == null)
                {
                    continue;
                }

                for (int i = 0; i < Stage.options.Count; i++)
                {
                    string event_name = "PLE_TEST_WAVE_" + i.ToString();

                    LevelUnitStates state = map[i][m_GameObjects[j].GetInstanceID()];
                    LU.AddNamedStateEvent(state, event_name);
                }

                LU.RegisterToNamedStateEvents();
            }
        }
Example #5
0
 public void SnapToFloorState()
 {
     transform.position = flatPosition;
     currentState       = LevelUnitStates.Floor;
     isTransitioning    = false;
     gameObject.tag     = Strings.Tags.FLOOR;
     gameObject.layer   = (int)Layers.Ground;
     HideBlockingObject();
 }
Example #6
0
    public void TryTransitionToState(LevelUnitStates state, bool wasToldToChangeColor)
    {
        switch (state)
        {
        case LevelUnitStates.Cover: TransitionToCoverState(wasToldToChangeColor); break;

        case LevelUnitStates.Floor: TransitionToFloorState(wasToldToChangeColor); break;

        case LevelUnitStates.Pit: TransitionToPitState(wasToldToChangeColor); break;
        }
    }
Example #7
0
    public void AddNewWave(params object[] parameters)
    {
        LevelUnitStates newState         = LevelUnitStates.Floor;
        int             currentWaveIndex = PLESpawnManager.Instance.CurrentWaveIndex;

        if (levelStates.Count > currentWaveIndex)
        {
            newState = levelStates[currentWaveIndex];
        }
        levelStates.Insert(currentWaveIndex, newState);
        SyncTileStatesAndColors();
    }
Example #8
0
 private void FinishTransition(Vector3 finalPosition)
 {
     transform.position = finalPosition;
     currentState       = nextState;
     isTransitioning    = false;
     if (currentState == LevelUnitStates.Floor)
     {
         gameObject.tag   = Strings.Tags.FLOOR;
         gameObject.layer = (int)Layers.Ground;
         HideBlockingObject();
     }
 }
Example #9
0
    private Vector3 GetStatePosition(LevelUnitStates state)
    {
        switch (state)
        {
        case LevelUnitStates.Cover: return(risePosition);

        case LevelUnitStates.Floor: return(flatPosition);

        case LevelUnitStates.Pit: return(pitPosition);
        }
        return(flatPosition);
    }
Example #10
0
    private List <string> GetStateEvents(LevelUnitStates state)
    {
        switch (state)
        {
        case LevelUnitStates.Pit: return(pitStateEvents);

        case LevelUnitStates.Floor: return(floorStateEvents);

        case LevelUnitStates.Cover: return(coverStateEvents);
        }
        return(null);
    }
Example #11
0
    private Color GetEmissiveColor(LevelUnitStates state)
    {
        switch (state)
        {
        case LevelUnitStates.Cover: return(riseColor);

        case LevelUnitStates.Floor: return(riseColor);

        case LevelUnitStates.Pit: return(riseColor);
        }
        return(riseColor);
    }
Example #12
0
    private Color GetAlbedoColor(LevelUnitStates state)
    {
        switch (state)
        {
        case LevelUnitStates.Cover: return(riseColor);

        case LevelUnitStates.Floor: return(flatColor);

        case LevelUnitStates.Pit: return(fallColor);
        }
        return(flatColor);
    }
Example #13
0
    private void TryTransitionToState(LevelUnitStates newState, Texture2D paintMaskTexture, Texture2D renderMask, bool wasToldToChangeColor)
    {
        if ((isTransitioning && currentState == newState) || currentState != newState)
        {
            splattable.PaintMask  = paintMaskTexture;
            splattable.RenderMask = renderMask;
            nextState             = newState;
            targetPosition        = GetStatePosition(nextState);
            isBeginningTransition = true;
            isTransitioning       = true;
            if (UnityEngine.Random.value < TILE_TRANSITION_SOUND_PROB)
            {
                SFXManager.Instance.Play(SFXType.TileLift, transform.position);
            }
        }
        bool shouldChangeColor = wasToldToChangeColor && isTransitioning;

        if (shouldChangeColor)
        {
            TriggerColorShift(newState);
        }
    }
Example #14
0
 protected override void Awake()
 {
     base.Awake();
     splattable = GetComponent <Splattable>();
     Assert.IsNotNull(splattable);
     defaultRenderMask = splattable.RenderMask;
     if (MeshRenderer)
     {
         meshSizeX = meshRenderer.bounds.size.x;
         meshSizeY = meshRenderer.bounds.size.y;
         meshSizeZ = meshRenderer.bounds.size.z;
         Color emptyColor = new Color(0f, 0f, 0f, 0f);
         if (riseColor.IsAboutEqual(emptyColor))
         {
             riseColor = Color.cyan.ChangeAlpha(.3f);
             flatColor = Color.black.ChangeAlpha(.8f);
             fallColor = Color.red.ChangeAlpha(.3f);
         }
     }
     colorShiftAnim.OnUpdate = OnColorChange;
     currentState            = defaultState;
     InitializeStatePositions();
     SetAlbedoColor(CurrentStateColor);
 }
Example #15
0
    private void UpdateTiles(List <GridTile> tiles, LevelUnitStates state, bool wasToldToChangeColor)
    {
        if (tiles.Count == 0)
        {
            return;
        }

        SFXManager.Instance.Play(SFXType.UI_Click);
        int currentWaveIndex = PLESpawnManager.Instance.CurrentWaveIndex;

        for (int i = 0; i < tiles.Count; i++)
        {
            GridTile     tile      = tiles[i];
            PLEBlockUnit blockUnit = tile.blockUnit;
            LevelUnit    levelUnit = tile.levelUnit;
            if (!blockUnit.HasActiveSpawn)
            {
                List <LevelUnitStates> levelUnitStates = blockUnit.GetLevelStates();
                levelUnitStates[currentWaveIndex] = state;
                blockUnit.SyncTileStatesAndColors();
                levelUnit.TryTransitionToState(state, wasToldToChangeColor);
            }
        }
    }
Example #16
0
    private void UpdateSelectedAndOpenTilesState(LevelUnitStates state)
    {
        List <GridTile> selectedGridTiles = levelEditor.gridController.GetSelectedGridTiles();

        UpdateTiles(selectedGridTiles, state, false);
    }
Example #17
0
 public void SaveObjectState(GameObject i_GameObject, LevelUnitStates i_State)
 {
     map[Stage.value][i_GameObject.GetInstanceID()] = i_State;
 }