//this function gets called upon the event "onHitSwitch" (switchPosition is in grid coordinates) void OnHitSwitch (Vector3 switchPosition, GFGrid theGrid){ //don't do anything if this light doesn't belong to the grid we use if(theGrid != connectedGrid) return; //check if this light is adjacent to the switch; this is an extenion method that always picks //the method that belongs to the specific grid type. The implementation is in another file if(theGrid.IsAdjacent(cachedTransform.position, switchPosition)){ //flip the state of this switch isOn = !isOn; } //change the lights (won't do anything if the state hasn't changed) SwitchLights(); }
//this function gets called upon the event "onHitSwitch" (switchPosition is in grid coordinates) void OnHitSwitch(Vector3 switchPosition, GFGrid theGrid) { //don't do anything if this light doesn't belong to the grid we use if (theGrid != connectedGrid) { return; } //check if this light is adjacent to the switch; this is an extenion method that always picks //the method that belongs to the specific grid type. The implementation is in another file if (theGrid.IsAdjacent(cachedTransform.position, switchPosition)) { //flip the state of this switch isOn = !isOn; } //change the lights (won't do anything if the state hasn't changed) SwitchLights(); }