示例#1
0
        public void TryPlaceNewCylinder(int treeCylindersAmount, float lastCylinderScale)
        {
            StoreCurrentPlaceData(treeCylindersAmount, lastCylinderScale);
            CylinderController newCylinder = CreateNewCylinder();

            StoreCylinder(newCylinder);
        }
示例#2
0
        private void SetCylinderCoords(CylinderController newCylinder)
        {
            float   cylinderY      = GetCylinderYCoord();
            Vector3 newCylinderPos = new Vector3(0f, cylinderY, 0f);

            newCylinder.Tran.position = newCylinderPos;
        }
示例#3
0
        private void DoAutoLoseActions()
        {
            CylinderController currentCylinder = _currentCylinder;

            UnstoreCylinder();
            FireOnAutoLoseConditionFullified(currentCylinder);
        }
示例#4
0
        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();
            }
        }
    }
示例#6
0
 private void FireOnAutoLoseConditionFullified(CylinderController currentCylinder)
 {
     if (OnAutoLoseConditionFullified != null)
     {
         OnAutoLoseConditionFullified(currentCylinder);
     }
 }
示例#7
0
        private CylinderController CreateNewCylinder()
        {
            CylinderController newCylinder = Factory.Get();

            SetCylinderCoords(newCylinder);
            return(newCylinder);
        }
示例#8
0
	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>();
	}
示例#9
0
        private CylinderPlaceArgs ConstructCylinderPlaceArgs(CylinderController currentCylinder, PlaceResult placeResult)
        {
            CylinderPlaceArgs placeArgs = new CylinderPlaceArgs
            {
                Cylinder    = currentCylinder,
                PlaceResult = placeResult
            };

            return(placeArgs);
        }
示例#10
0
    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);
        }
示例#12
0
        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);
        }
示例#13
0
        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();
            }
        }
示例#16
0
 private void StoreCylinder(CylinderController newCylinder)
 {
     _currentCylinder = newCylinder;
 }
示例#17
0
 private void UnstoreCylinder()
 {
     _currentCylinder = null;
 }
 void Start()
 {
     levelManager       = FindObjectOfType <LevelManager>();
     cylinderController = FindObjectOfType <CylinderController>();
 }
示例#19
0
        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));
            }
        }
示例#20
0
 private void ExpandTower(CylinderController newCylinder)
 {
     TowerController.Expand(newCylinder);
 }
示例#21
0
 public void Expand(CylinderController newCylinder)
 {
     Cylinders.Add(newCylinder);
 }
示例#22
0
 public void StartAnimateLose(CylinderController cylinderLostGame)
 {
     _loseCylinderStored = cylinderLostGame;
     SetCylinderMaterial();
     StartCoroutine(AnimateLoseCoroutine());
 }
示例#23
0
 private void SetCylinderPerfect(CylinderController currentCylinder)
 {
     currentCylinder.MakePerfect();
 }
示例#24
0
 public void LoseGame(CylinderController cylinderCausedLose)
 {
     SetActionsEnabled(false);
     AnimateLose(cylinderCausedLose);
 }
示例#25
0
 private void AnimateLose(CylinderController cylinderCausedLose)
 {
     LoseAnimator.StartAnimateLose(cylinderCausedLose);
 }
示例#26
0
 private void RestoreState()
 {
     _loseCylinderStored = null;
 }
示例#27
0
 private void CompleteAnimatingLose(CylinderController cylinderCausedLose)
 {
     cylinderCausedLose.Destroy();
     CameraPositionController.SetCameraLoosePosition(TowerController.CylindersAmount);
     IsGameLost = true;
 }
示例#28
0
 // 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);
 }
示例#29
0
 // Use this for initialization
 void Start()
 {
     cc  = ( CubeController)cube.GetComponent(typeof(CubeController));
     cyc = (CylinderController)cylinder.GetComponent(typeof(CylinderController));
 }
示例#30
0
    // 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);
            }
        }
    }