Exemplo n.º 1
0
    public void TrySetIsWall(bool _isWall)
    {
        if (IsWall == _isWall)
        {
            return;
        }

        IsWall = _isWall;

        if (_isWall)
        {
            NeighborFinder.TryCacheNeighbor(GridPos, Direction.All);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.TL]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.T]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.TR]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.R]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.BR]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.B]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.BL]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.L]);
        }
        else
        {
            LampManager.GetInstance().SetNodeLightingDirty(this);
        }

        RoomManager.GetInstance().ScheduleUpdateForRoomOfNode(GridPos);
        ScheduleUpdateGraphicsForSurroundingTiles();
    }
Exemplo n.º 2
0
 void OnTurnOff()
 {
     LampManager.GetInstance().OnLampTurnOff(this);
 }
Exemplo n.º 3
0
 void OnDestroy()
 {
     LampManager.GetInstance().OnLampDestroy(this);
 }
Exemplo n.º 4
0
 public override void AwakeDefault()
 {
     LampManager.GetInstance().OnLampAwake(this);
 }
Exemplo n.º 5
0
    void CacheChemicalData(Int2 _nodeGridPos)
    {
        int _nodeIndex = _nodeGridPos.y * chemAmountsAndTemperatureTex.width + _nodeGridPos.x;

        // TODO: need to sort Contents
        ChemicalContainer _chemicalContainer = GameGrid.GetInstance().TryGetNode(_nodeGridPos).ChemicalContainer;

        Chemical.Blob _chem_0 = _chemicalContainer.Contents[0];
        Chemical.Blob _chem_1 = _chemicalContainer.Contents[1];
        Chemical.Blob _chem_2 = _chemicalContainer.Contents[2];

        // Vertex data
        // int _vertexIndexBL = ((_nodeGridPos.y) * GameGrid.TILE_COUNT.x + (_nodeGridPos.x)) * VERTICES_PER_TILE + VERTEX_INDEX_TOP_RIGHT;
        // int _vertexIndexBR = ((_nodeGridPos.y) * GameGrid.TILE_COUNT.x + (_nodeGridPos.x + 1)) * VERTICES_PER_TILE + VERTEX_INDEX_TOP_LEFT;
        // int _vertexIndexTL = ((_nodeGridPos.y + 1) * GameGrid.TILE_COUNT.x + (_nodeGridPos.x)) * VERTICES_PER_TILE + VERTEX_INDEX_BOTTOM_RIGHT;
        // int _vertexIndexTR = ((_nodeGridPos.y + 1) * GameGrid.TILE_COUNT.x + (_nodeGridPos.x + 1)) * VERTICES_PER_TILE + VERTEX_INDEX_BOTTOM_LEFT;

        float _amount_0    = _chem_0.Amount / (float)_chemicalContainer.MaxAmount;
        float _amount_1    = _chem_1.Amount / (float)_chemicalContainer.MaxAmount;
        float _amount_2    = _chem_2.Amount / (float)_chemicalContainer.MaxAmount;
        float _temperature = _chemicalContainer.Temperature / (float)Chemical.MAX_TEMPERATURE;

        // chemAmountsAndTemperature[_vertexIndexBL] = new Vector4(_amount_0, _amount_1, _amount_2, _temperature);
        // chemAmountsAndTemperature[_vertexIndexBR] = new Vector4(_amount_0, _amount_1, _amount_2, _temperature);
        // chemAmountsAndTemperature[_vertexIndexTL] = new Vector4(_amount_0, _amount_1, _amount_2, _temperature);
        // chemAmountsAndTemperature[_vertexIndexTR] = new Vector4(_amount_0, _amount_1, _amount_2, _temperature);

        float debugValue_0 = GameGrid.GetInstance().TryGetNode(_nodeGridPos).DebugChemicalContainer.Contents[0].Amount / (float)GameGrid.GetInstance().TryGetNode(_nodeGridPos).DebugChemicalContainer.MaxAmount;
        float debugValue_1 = GameGrid.GetInstance().TryGetNode(_nodeGridPos).DebugChemicalContainer.Contents[1].Amount / (float)GameGrid.GetInstance().TryGetNode(_nodeGridPos).DebugChemicalContainer.MaxAmount;
        float debugValue_2 = GameGrid.GetInstance().TryGetNode(_nodeGridPos).DebugChemicalContainer.Contents[2].Amount / (float)GameGrid.GetInstance().TryGetNode(_nodeGridPos).DebugChemicalContainer.MaxAmount;

        debugColors[_nodeIndex] = new Color(debugValue_0, debugValue_1, debugValue_2, 1);
        chemAmountsAndTemperature[_nodeIndex] = new Color(_amount_0, _amount_1, _amount_2, _temperature);

        // chemColorIndices[_vertexIndexBL] = new Vector3(_colorIndex_0, _colorIndex_1, _colorIndex_2);
        // chemColorIndices[_vertexIndexBR] = new Vector3(_colorIndex_0, _colorIndex_1, _colorIndex_2);
        // chemColorIndices[_vertexIndexTL] = new Vector3(_colorIndex_0, _colorIndex_1, _colorIndex_2);
        // chemColorIndices[_vertexIndexTR] = new Vector3(_colorIndex_0, _colorIndex_1, _colorIndex_2);
        float _colorIndex_0 = _chem_0.Chemical.GetColorIndex() / (float)ColorManager.COLOR_COUNT;
        float _colorIndex_1 = _chem_1.Chemical.GetColorIndex() / (float)ColorManager.COLOR_COUNT;
        float _colorIndex_2 = _chem_2.Chemical.GetColorIndex() / (float)ColorManager.COLOR_COUNT;

        chemColorIndices[_nodeIndex] = new Color(_colorIndex_0, _colorIndex_1, _colorIndex_2, 0.0f);
        //

        // Texture data
        int   _stateCount = System.Enum.GetValues(typeof(Chemical.State)).Length;
        float _state_0    = _chem_0.GetStateAsFloat() / (float)(_stateCount - 1.0f);
        float _state_1    = _chem_1.GetStateAsFloat() / (float)(_stateCount - 1.0f);
        float _state_2    = _chem_2.GetStateAsFloat() / (float)(_stateCount - 1.0f);

        // Debug.Log(_chem_0.GetStateAsFloat() + ", " + _state_0);

        // chemStates[_vertexIndexBL] = new Vector3(_state_0, _state_1, _state_2);
        // chemStates[_vertexIndexBR] = new Vector3(_state_0, _state_1, _state_2);
        // chemStates[_vertexIndexTL] = new Vector3(_state_0, _state_1, _state_2);
        // chemStates[_vertexIndexTR] = new Vector3(_state_0, _state_1, _state_2);
        chemStates[_nodeIndex] = new Color(_state_0, _state_1, _state_2);
        //
        // if(_nodeGridPos.x == 30 && _nodeGridPos.y == 20) {
        //  SuperDebug.MarkPoint(GameGrid.GetInstance().GetWorldPosFromNodeGridPos(_nodeGridPos), Color.cyan);
        //
        //  float _stateR = GameGrid.GetInstance().TryGetNode(_nodeGridPos + Int2.Right).ChemicalContainer.Contents[0].GetStateAsFloat();
        //
        //  Debug.Log("state = " +(_state_0 * 3.0f) + ", stateR = " + _stateR);
        // }

        if (_chemicalContainer.IsIncandescent() || _chemicalContainer.HasLostIncandescence())
        {
            LampManager.GetInstance().SetNodeIncandescenceDirty(_nodeGridPos);
        }

        // Color _incandescence_0 = _chem_0.GetIncandescence() * _amount_0;
        // Color _incandescence_1 = _chem_1.GetIncandescence() * _amount_1;
        // Color _incandescence_2 = _chem_2.GetIncandescence() * _amount_2;
        //
        // float _maxIncandescenceR = Mathf.Max(_incandescence_0.r, Mathf.Max(_incandescence_1.r, _incandescence_2.r));
        // float _maxIncandescenceG = Mathf.Max(_incandescence_0.g, Mathf.Max(_incandescence_1.g, _incandescence_2.g));
        // float _maxIncandescenceB = Mathf.Max(_incandescence_0.b, Mathf.Max(_incandescence_1.b, _incandescence_2.b));
        // float _maxIncandescenceA = Mathf.Max(_incandescence_0.a, Mathf.Max(_incandescence_1.a, _incandescence_2.a));
        //
        // Node _node = GameGrid.GetInstance().TryGetNode(_nodeGridPos);
        // Color32 _lighting = _node.GetLighting();
        //
        // _lighting.r = (byte)Mathf.Max(_lighting.r, _maxIncandescenceR * 255.0f);
        // _lighting.g = (byte)Mathf.Max(_lighting.g, _maxIncandescenceG * 255.0f);
        // _lighting.b = (byte)Mathf.Max(_lighting.b, _maxIncandescenceB * 255.0f);
        // _lighting.a = (byte)Mathf.Max(_lighting.a, _maxIncandescenceA * 255.0f);
        //
        // _node.SetLighting(_lighting);
    }