Пример #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();
    }
Пример #2
0
    void Awake()
    {
        lampManager   = GetComponentInParent <LampManager> ();
        this.collider = GetComponent <BoxCollider2D> ();
//		Physics2D.IgnoreCollision (this.collider, GameObject.FindObjectOfType<PlayerYuni>().GetComponent<Collider2D>());
//		Physics2D.IgnoreLayerCollision (LayerMask.NameToLayer("Trampoline"), LayerMask.NameToLayer("Player"));
    }
Пример #3
0
 // Start is called before the first frame update
 void Start()
 {
     _state       = Convert.ToBoolean(Random.Range(0, 2));
     _lampManager = LampManager.manager;
     _score       = GameObject.Find("Player").GetComponent <ScoreScript>();
     _light       = transform.GetChild(0).gameObject;
     _lampManager.Toggle(_state, true);
 }
Пример #4
0
 private void Awake()
 {
     if (manager != null)
     {
         Debug.Log("Error: multiple instances of LampManager.");
         return;
     }
     manager      = this;
     _lampOnCount = 0;
 }
 void NullCheck()
 {
     if (this.trampolineAnimatable == null)
     {
         trampolineAnimatable = gameObject.GetComponentInChildren <TrampolinePlatformAnimatable> ();
     }
     if (this.lampManager != null)
     {
         lampManager = gameObject.GetComponentInParent <LampManager> ();
     }
 }
Пример #6
0
        static void Main(string[] args)
        {
            #region [Reflection]

            //var assemblyType = typeof(Mp3PlayerManager).Assembly.GetTypes();
            //var mp3Type = typeof(Mp3PlayerManager);
            //foreach (var t in assemblyType)
            //{
            //    Console.WriteLine($"(FullName: {t.Name}, IsAssignable Mp3PlayerManager From { t.Name } : { typeof(Mp3PlayerManager).IsAssignableFrom(t) } , Has CassetteState Attribute : {t.GetCustomAttribute(typeof(CassetteStateAttribute))} ");
            //}



            #endregion

            //var cassette = new Cassette() { Id = 1, Name = "Schiller", State = State.Play };
            // cassette.CurrentState.Pause();;


            //var cassette2 = new Cassette() { Id = 1, Name = "Schiller", State = State.Pause };
            //cassette.CurrentState.Play();

            #region Turn Lamp On or OFF

            var currentState = new LampManager();

            var on = new OnState();
            on.PressPlay(currentState);

            var off = new OffState();
            off.PressPlay(currentState);

            Console.WriteLine($"latest state is : {currentState.StateName} ");

            #endregion



            Console.ReadLine();
        }
 public void SetLampManager(LampManager manager)
 {
     this.lampManager = manager;
 }
Пример #8
0
 void OnTurnOff()
 {
     LampManager.GetInstance().OnLampTurnOff(this);
 }
Пример #9
0
 void OnDestroy()
 {
     LampManager.GetInstance().OnLampDestroy(this);
 }
Пример #10
0
 public override void AwakeDefault()
 {
     LampManager.GetInstance().OnLampAwake(this);
 }
Пример #11
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);
    }