void Update() { switch (_systemState) { case eSystemState.noop: break; case eSystemState.reboot: _score = 0; _systemState = eSystemState.active; break; case eSystemState.active: { _elaspedTime += Time.deltaTime; if (_elaspedTime > _emmiterTime) { //insert ball into bucket AddBallToBucket(); _elaspedTime = 0.0f; } if (Input.GetMouseButtonDown(0)) { //Debug.Log ("Clicked"); Vector2 pos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); RaycastHit2D hitInfo = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(pos), Vector2.zero); // RaycastHit2D can be either true or null, but has an implicit conversion to bool, so we can use it like this if (hitInfo) { //Debug.Log( hitInfo.transform.gameObject.name ); GameObject _gObj = hitInfo.transform.gameObject; MathBall _mathBallScript = _gObj.GetComponent <MathBall> (); if (_mathBallScript.setBallSelected() == false) { ClearSelectedBalls(); //CentralCalculator _centralCalculator = GameCommon.getCentralCalculatorClass(); CentralCalculator.Instance.ResetCalcTokenList(); //is ball already selected? //clear with zonk //GameCommon.getAudioDepotClass().PlaySfx(AudioDepot.eSfxID.matchReset); AudioDepot.Instance.PlaySfx(AudioDepot.eSfxID.matchReset); } else { //value & function MathBall.eFunction function = _mathBallScript._function; int value = _mathBallScript.ball_value; //CentralCalculator _centralCalculator = GameCommon.getCentralCalculatorClass(); CentralCalculator.Instance.AddCalcToken(value, function); if (CentralCalculator.Instance.AnalyseCalcTokenList() == true) { //success //get score _score += CentralCalculator.Instance.calcScore; //clear selected balls Debug.Log("SUCCESSFULL CALCULATION!!"); RemoveSelectedBalls(); CentralCalculator.Instance.ResetCalcTokenList(); if (GetNumBallsInBucket() == 0) { //GameCommon.getGameplayManagerClass().PuzzleCompete(_score); GameplayManager.Instance.PuzzleCompete(_score); //GameCommon.getAudioDepotClass().PlaySfx(AudioDepot.eSfxID.puzzleDone); AudioDepot.Instance.PlaySfx(AudioDepot.eSfxID.puzzleDone); //GameCommon.getParticleDepotClass().PlayBonus(); ParticleDepot.Instance.PlayBonus(); } else { //GameCommon.getAudioDepotClass().PlaySfx(AudioDepot.eSfxID.matchMade); AudioDepot.Instance.PlaySfx(AudioDepot.eSfxID.matchMade); } } else if (CentralCalculator.Instance.ErrorReport() > 0) { //clear with zonk Debug.Log("ERROR ... ERROR ... ERROR!!"); ClearSelectedBalls(); CentralCalculator.Instance.ResetCalcTokenList(); } } } } } break; case eSystemState.done: break; } }
public bool GetCondition(eSystemState state) { return(this._state == state); }
public void SetState(eSystemState state) { _systemState = state; }