/* * Drawing of the different hints */ public void DrawOperand(CubeWrapper wrapper) { Log.Debug ("-- Hint Controller Draw Operand"); //Paint Background mCube.FillScreen (bgColor); PaintDomino (wrapper); }
public OperatorController(Cube cube) { Log.Debug (classname + " Init"); mCube = cube; mWrapper = (CubeWrapper)cube.userData; mCube.NeighborAddEvent += OnNeighborAdd; mCube.NeighborRemoveEvent += OnNeighborRemove; }
public ResultController(Cube cube) { Log.Debug (classname + " Init"); mCube = cube; mWrapper = (CubeWrapper)cube.userData; //Event listeners mCube.NeighborAddEvent += OnNeighborAdd; mCube.NeighborRemoveEvent += OnNeighborRemove; }
public void PaintDomino(CubeWrapper wrapper, int operandVal) { DominoPainter painter = new DominoPainter (mCube, operandVal, wrapper.mColor); painter = null; }
public void PaintDomino(CubeWrapper wrapper) { DominoPainter painter = new DominoPainter (mCube, wrapper.mValue, wrapper.mColor); painter = null; }
public void DrawResult(CubeWrapper wrapper) { Cube[] connected = CubeHelper.FindConnected (mCube); //Get all the connected cubes Log.Debug (" num cubes connected: {0}", connected.Length); int result = 0; //Loop through each cube foreach (Cube neighbor in connected) { CubeWrapper neighborWrapper = (CubeWrapper)neighbor.userData; //Skip any other cube other than an Operand cube if (neighborWrapper.mCubeStateMachine.Current == Constants.OperandState) { //Mark the hint cube to be updated result += neighborWrapper.mValue; mWrapper.mNeedDraw = true; } } //Paint Background mCube.FillScreen (bgColor); PaintDomino (wrapper, result); }
// ### New Cube ### // When a new cube connects while the game is running, we need to create a // wrapper for it so that it is included in gameplay. // // If a new cube is added while the game is paused, this event will be // handled after the player unpauses, but before the unpause event is // handled. private void OnNewCube(Cube c) { Log.Debug ("New Cube {0}", c.UniqueId); CubeWrapper wrapper = (CubeWrapper)c.userData; if (wrapper == null) { wrapper = new CubeWrapper (this, c, lastIndex); lastIndex += 1; mWrappers.Add (wrapper); Log.Debug ("{0}", mWrappers); } mNeedCheck = true; }
// called during intitialization, before the game has started to run public override void Setup() { Log.Debug ("Setup()"); //Initially, check all the cubes mNeedCheck = true; System.Version myVersion = System.Reflection.Assembly.GetExecutingAssembly ().GetName ().Version; Log.Debug (myVersion.ToString ()); //Init Cube roles cubeStates = new CubeRole[6]; cubeStates [0] = new CubeRole (Constants.HintState, Constants.tTitleToHintState, -1, -1, System.Drawing.Color.Black); cubeStates [1] = new CubeRole (Constants.OperandState, Constants.tTitleToOperandState, Constants.kOperandMin, Constants.kOperandMax, System.Drawing.Color.Orange); cubeStates [2] = new CubeRole (Constants.OperatorState, Constants.tTitleToOperatorState, Constants.kOperatorMin, Constants.kOperatorMax, System.Drawing.Color.Black); cubeStates [3] = new CubeRole (Constants.OperandState, Constants.tTitleToOperandState, Constants.kOperandMin, Constants.kOperandMax, System.Drawing.Color.Red); cubeStates [4] = new CubeRole (Constants.ResultState, Constants.tTitleToResultState, 5, 5, System.Drawing.Color.Blue); cubeStates [5] = new CubeRole (Constants.OperandState, Constants.tTitleToOperandState, Constants.kOperandMin, Constants.kOperandMax, System.Drawing.Color.Green); // Loop through all the cubes and set them up. lastIndex = 1; foreach (Cube cube in CubeSet) { CubeWrapper wrapper = new CubeWrapper (this, cube, lastIndex); lastIndex += 1; mWrappers.Add (wrapper); } //Event Listeners this.PauseEvent += OnPause; this.UnpauseEvent += OnUnpause; CubeSet.NewCubeEvent += OnNewCube; CubeSet.LostCubeEvent += OnLostCube; CubeSet.NeighborAddEvent += OnNeighborAdd; CubeSet.NeighborRemoveEvent += OnNeighborRemove; }