public void TryPlaceNewCylinder(int treeCylindersAmount, float lastCylinderScale) { StoreCurrentPlaceData(treeCylindersAmount, lastCylinderScale); CylinderController newCylinder = CreateNewCylinder(); StoreCylinder(newCylinder); }
private void SetCylinderCoords(CylinderController newCylinder) { float cylinderY = GetCylinderYCoord(); Vector3 newCylinderPos = new Vector3(0f, cylinderY, 0f); newCylinder.Tran.position = newCylinderPos; }
private void DoAutoLoseActions() { CylinderController currentCylinder = _currentCylinder; UnstoreCylinder(); FireOnAutoLoseConditionFullified(currentCylinder); }
private void DestroyAndRemoveCylinder(int i) { CylinderController curCylinder = Cylinders[i]; curCylinder.Destroy(); Cylinders.RemoveAt(i); }
private void CheckRayHit() { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, Mathf.Infinity, cylinderLayer)) { if (cylinder != null) { cylinder.IsSelected = false; } cylinder = hit.transform.GetComponent <CylinderController>(); cylinder.IsSelected = true; } else if (Physics.Raycast(ray, out hit, Mathf.Infinity, nodeLayer)) { if (cylinder.IsSelected) { startNode = cylinder.NodeCollided; targetNode = hit.collider.GetComponent <Node>(); pathfinder.FindPath(startNode, targetNode); cylinder.Move(); } } }
private void FireOnAutoLoseConditionFullified(CylinderController currentCylinder) { if (OnAutoLoseConditionFullified != null) { OnAutoLoseConditionFullified(currentCylinder); } }
private CylinderController CreateNewCylinder() { CylinderController newCylinder = Factory.Get(); SetCylinderCoords(newCylinder); return(newCylinder); }
void Start() { this.ball = GameObject.FindWithTag("Ball"); this.player = GetComponent<PlayerController>(); this.cylinderController = GameObject.Find("Cylinders").GetComponent<CylinderController>(); this.soundController = GetComponent<SoundController>(); GameObject charSprite = transform.GetChild(0).FindChild("Character Sprite").gameObject; anim = charSprite.GetComponent<Animator>(); }
private CylinderPlaceArgs ConstructCylinderPlaceArgs(CylinderController currentCylinder, PlaceResult placeResult) { CylinderPlaceArgs placeArgs = new CylinderPlaceArgs { Cylinder = currentCylinder, PlaceResult = placeResult }; return(placeArgs); }
private void Start() { gameManager = FindObjectOfType <GameManager>(); cylinderController = FindObjectOfType <CylinderController>(); skinsManager = FindObjectOfType <SkinsManager>(); audioManager = FindObjectOfType <AudioManager>(); SetCurrentKnifeSkin(); ResetKnife(); transform.position = new Vector3(transform.position.x, -(cylinderController.transform.position.y - spawnKnifeY), transform.position.z); startAngels = transform.rotation; }
private float GetShrinkAmountForRegularCylinder(CylinderController cylinder, float scaleStored) { float scaleDifference = cylinder.Type != CylinderType.PerfectMoved ? (scaleStored - (scaleStored - CylinderExpandAmount) * CylinderShrinkMultiplier) : CylinderExpandAmount; if (scaleStored - scaleDifference < MinScale) { scaleDifference = scaleStored - MinScale; } float shrinkAmount = -scaleDifference / IterationsAmount; return(shrinkAmount); }
private PlaceResult GetPlaceResultByCylinderScale(CylinderController currentCylinder) { float scale = currentCylinder.Scale; if (scale > _lastCylinderScale) { return(PlaceResult.Incorrent); } else if (_lastCylinderScale - scale <= PerfectPlaceScaleMaxDifference) { return(PlaceResult.Perfect); } return(PlaceResult.Regular); }
public CylinderPlaceArgs StopPlacingCylinder() { if (_currentCylinder == null) { return(null); } CylinderController currentCylinder = _currentCylinder; UnstoreCylinder(); PlaceResult placeResult = GetPlaceResultByCylinderScale(currentCylinder); CylinderPlaceArgs placeArgs = ConstructCylinderPlaceArgs(currentCylinder, placeResult); return(placeArgs); }
private IEnumerator AnimateLastPlacedCylinder(CylinderController cylinder) { for (int i = 0; i < IterationsAmount; i++) { float expandAmount = LastCylinderExpandAmount / IterationsAmount; cylinder.Expand(expandAmount); yield return(new WaitForSeconds(CylinderAnimateTime / IterationsAmount)); } float scaleStored = cylinder.Scale; for (int i = 0; i < IterationsAmount; i++) { float shrinkAmount = GetShrinkAmountForFirstCylinder(scaleStored); cylinder.Expand(shrinkAmount); yield return(new WaitForSeconds(CylinderAnimateTime / IterationsAmount)); } }
private IEnumerator AnimateCylinder(CylinderController cylinder, int cylinderIndex) { for (int i = 0; i < IterationsAmount; i++) { float expandAmount = CylinderExpandAmount / IterationsAmount; cylinder.Expand(expandAmount); yield return(new WaitForSeconds(CylinderAnimateTime / IterationsAmount)); } float scaleStored = cylinder.Scale; for (int i = 0; i < IterationsAmount; i++) { float shrinkAmount = GetShrinkAmountForRegularCylinder(cylinder, scaleStored); cylinder.Expand(shrinkAmount); yield return(new WaitForSeconds(CylinderAnimateTime / IterationsAmount)); } if (cylinderIndex == 0) { FireOnAnimCompletedEvent(); } }
private void StoreCylinder(CylinderController newCylinder) { _currentCylinder = newCylinder; }
private void UnstoreCylinder() { _currentCylinder = null; }
void Start() { levelManager = FindObjectOfType <LevelManager>(); cylinderController = FindObjectOfType <CylinderController>(); }
public SystemService() { ThreadPool.SetMinThreads(50, 50); // read version from AssemblyInfo.cs Version version = Assembly.GetExecutingAssembly().GetName().Version; // force to enable the log, otherwise the initial message could not be recored LogHelper.LogEnabled = true; StringBuilder sb = new StringBuilder(); sb.Append("\r\n"); sb.Append("> =================================================================\r\n"); sb.Append("> = 4x25G/10x10G Alignment System =\r\n"); sb.Append("> = Copyright (C) 2017 Irixi =\r\n"); sb.Append("> =================================================================\r\n"); LogHelper.WriteLine(sb.ToString()); this.LastMessage = new MessageItem(MessageType.Normal, "System startup ..."); this.LastMessage = new MessageItem(MessageType.Normal, "Application Version {0}", version); // read the configuration from the file named SystemCfg.json // the file is located in \Configuration ConfigManager conf_manager = SimpleIoc.Default.GetInstance <ConfigManager>(); // whether output the log LogHelper.LogEnabled = conf_manager.ConfSystemSetting.LogEnabled; // initialize the properties BusyComponents = new List <IServiceSystem>(); PhysicalMotionControllerCollection = new Dictionary <Guid, IMotionController>(); LogicalAxisCollection = new ObservableCollection <LogicalAxis>(); LogicalMotionComponentCollection = new ObservableCollection <LogicalMotionComponent>(); MeasurementInstrumentCollection = new ObservableCollection <InstrumentBase>(); ActiveInstrumentCollection = new ObservableCollection <InstrumentBase>(); State = SystemState.BUSY; SpiralScanArgs = new SpiralScanArgs(); AlignmentXDArgs = new AlignmentXDArgs(); /* * enumerate all physical motion controllers defined in the config file, * and create the instance of the motion controller class. */ foreach (var conf in conf_manager.ConfSystemSetting.PhysicalMotionControllers) { IMotionController motion_controller = null; switch (conf.Model) { case MotionControllerModel.LUMINOS_P6A: motion_controller = new LuminosP6A(conf); motion_controller.OnMoveBegin += PhysicalMotionController_OnMoveBegin; motion_controller.OnMoveEnd += PhysicalMotionController_OnMoveEnd; break; case MotionControllerModel.THORLABS_TDC001: //TODO create the instance of thorlabs TDC001 break; case MotionControllerModel.IRIXI_EE0017: motion_controller = new IrixiEE0017(conf); motion_controller.OnMoveBegin += PhysicalMotionController_OnMoveBegin; motion_controller.OnMoveEnd += PhysicalMotionController_OnMoveEnd; ((IrixiEE0017)motion_controller).OnMessageReported += ((sender, message) => { Application.Current.Dispatcher.Invoke(() => { this.LastMessage = new MessageItem(MessageType.Normal, string.Format("{0} {1}", sender, message)); }); }); break; default: this.LastMessage = new MessageItem(MessageType.Error, "Unrecognized controller model {0}.", conf.Model); break; } // Add the controller to the dictionary<Guid, Controller> if (motion_controller != null) { this.PhysicalMotionControllerCollection.Add(motion_controller.DeviceClass, motion_controller); } } // create the instance of the Logical Motion Components foreach (var cfg_motion_comp in conf_manager.ConfSystemSetting.LogicalMotionComponents) { LogicalMotionComponent comp = new LogicalMotionComponent(cfg_motion_comp.Caption, cfg_motion_comp.Icon); int axis_id = 0; foreach (var cfg_axis in cfg_motion_comp.LogicalAxisArray) { // new logical axis object will be added to the Logical Motion Component LogicalAxis axis = new LogicalAxis(this, cfg_axis, cfg_motion_comp.Caption, axis_id); axis.OnHomeRequsted += LogicalAxis_OnHomeRequsted; axis.OnMoveRequsted += LogicalAxis_OnMoveRequsted; axis.OnStopRequsted += LogicalAxis_OnStopRequsted; // bind the physical axis instance to logical axis object BindPhysicalAxis(axis); comp.LogicalAxisCollection.Add(axis); this.LogicalAxisCollection.Add(axis); axis_id++; } this.LogicalMotionComponentCollection.Add(comp); } // create the instance of the cylinder try { IrixiEE0017 ctrl = PhysicalMotionControllerCollection[Guid.Parse(conf_manager.ConfSystemSetting.Cylinder.Port)] as IrixiEE0017; CylinderController = new CylinderController(conf_manager.ConfSystemSetting.Cylinder, ctrl); } catch (Exception e) { this.LastMessage = new MessageItem(MessageType.Error, "Unable to initialize the cylinder controller, {0}", e.Message); } // create instance of the keithley 2400 foreach (var cfg in conf_manager.ConfSystemSetting.Keithley2400s) { this.MeasurementInstrumentCollection.Add(new Keithley2400(cfg)); } // create instance of the newport 2832C foreach (var cfg in conf_manager.ConfSystemSetting.Newport2832Cs) { this.MeasurementInstrumentCollection.Add(new Newport2832C(cfg)); } }
private void ExpandTower(CylinderController newCylinder) { TowerController.Expand(newCylinder); }
public void Expand(CylinderController newCylinder) { Cylinders.Add(newCylinder); }
public void StartAnimateLose(CylinderController cylinderLostGame) { _loseCylinderStored = cylinderLostGame; SetCylinderMaterial(); StartCoroutine(AnimateLoseCoroutine()); }
private void SetCylinderPerfect(CylinderController currentCylinder) { currentCylinder.MakePerfect(); }
public void LoseGame(CylinderController cylinderCausedLose) { SetActionsEnabled(false); AnimateLose(cylinderCausedLose); }
private void AnimateLose(CylinderController cylinderCausedLose) { LoseAnimator.StartAnimateLose(cylinderCausedLose); }
private void RestoreState() { _loseCylinderStored = null; }
private void CompleteAnimatingLose(CylinderController cylinderCausedLose) { cylinderCausedLose.Destroy(); CameraPositionController.SetCameraLoosePosition(TowerController.CylindersAmount); IsGameLost = true; }
// here we add first cylinder which is actually on the field public void InitByFirstCylinder(CylinderController firstCylinder) { firstCylinder.Init(null); // first cylinder requires no pool though it never will be destroyed. Cylinders.Add(firstCylinder); }
// Use this for initialization void Start() { cc = ( CubeController)cube.GetComponent(typeof(CubeController)); cyc = (CylinderController)cylinder.GetComponent(typeof(CylinderController)); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow)) { if (currentCylinder) { currentCylinder.SetTargetPosition(currentCylinder.CurrentTarget + 1); } } if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow)) { if (currentCylinder) { currentCylinder.SetTargetPosition(currentCylinder.CurrentTarget - 1); } } if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow)) { if (currentCylinder == null) { currentCylinder = padlock.Cylinders[currentCylinderIndex]; currentCylinder.gameObject.GetComponent <Renderer>().material = selected; } if (currentCylinderIndex > 0) { currentCylinder.gameObject.GetComponent <Renderer>().material = normal; currentCylinderIndex -= 1; currentCylinder = padlock.Cylinders[currentCylinderIndex]; currentCylinder.gameObject.GetComponent <Renderer>().material = selected; } } if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow)) { if (currentCylinder == null) { currentCylinder = padlock.Cylinders[currentCylinderIndex]; currentCylinder.gameObject.GetComponent <Renderer>().material = selected; } if (currentCylinderIndex < padlock.Cylinders.Length - 1) { currentCylinder.gameObject.GetComponent <Renderer>().material = normal; currentCylinderIndex += 1; currentCylinder = padlock.Cylinders[currentCylinderIndex]; currentCylinder.gameObject.GetComponent <Renderer>().material = selected; } } if (Input.GetKeyDown(KeyCode.Alpha0) || Input.GetKeyDown(KeyCode.Keypad0)) { if (currentCylinder) { currentCylinder.SetTargetPosition(0); } } if (Input.GetKeyDown(KeyCode.Alpha1) || Input.GetKeyDown(KeyCode.Keypad1)) { if (currentCylinder) { currentCylinder.SetTargetPosition(1); } } if (Input.GetKeyDown(KeyCode.Alpha2) || Input.GetKeyDown(KeyCode.Keypad2)) { if (currentCylinder) { currentCylinder.SetTargetPosition(2); } } if (Input.GetKeyDown(KeyCode.Alpha3) || Input.GetKeyDown(KeyCode.Keypad3)) { if (currentCylinder) { currentCylinder.SetTargetPosition(3); } } if (Input.GetKeyDown(KeyCode.Alpha4) || Input.GetKeyDown(KeyCode.Keypad4)) { if (currentCylinder) { currentCylinder.SetTargetPosition(4); } } if (Input.GetKeyDown(KeyCode.Alpha5) || Input.GetKeyDown(KeyCode.Keypad5)) { if (currentCylinder) { currentCylinder.SetTargetPosition(5); } } if (Input.GetKeyDown(KeyCode.Alpha6) || Input.GetKeyDown(KeyCode.Keypad6)) { if (currentCylinder) { currentCylinder.SetTargetPosition(6); } } if (Input.GetKeyDown(KeyCode.Alpha7) || Input.GetKeyDown(KeyCode.Keypad7)) { if (currentCylinder) { currentCylinder.SetTargetPosition(7); } } if (Input.GetKeyDown(KeyCode.Alpha8) || Input.GetKeyDown(KeyCode.Keypad8)) { if (currentCylinder) { currentCylinder.SetTargetPosition(8); } } if (Input.GetKeyDown(KeyCode.Alpha9) || Input.GetKeyDown(KeyCode.Keypad9)) { if (currentCylinder) { currentCylinder.SetTargetPosition(9); } } }