private IEntity CreateEnemy(String type, Vector2 startingPos, Vector2 abstractPos) { IEntity newEnemy = new Keese(game, startingPos); switch (type) { case "Aquamentus": newEnemy = new Aquamentus(game, startingPos); break; case "BoggusBoss": newEnemy = new BoggusBoss(game, startingPos); break; case "MarioBoss": newEnemy = new MarioBoss(game, startingPos); break; case "Dodongo": newEnemy = new Dodongo(game, startingPos); break; case "Gel": newEnemy = new Gel(game, startingPos); break; case "Zol": newEnemy = new Zol(game, startingPos); break; case "Goriya": newEnemy = new Goriya(game, startingPos); break; case "Keese": newEnemy = new Keese(game, startingPos); break; case "Stalfos": newEnemy = new Stalfos(game, startingPos); break; case "Rope": newEnemy = new Rope(game, startingPos); break; case "Wallmaster": newEnemy = new WallMaster(game, startingPos, abstractPos); break; default: break; } return(newEnemy); }
public StateGelNormal(Gel _p, SpriteRenderer _renderer, Sprite[] _animation) { p = _p; renderer = _renderer; animation = _animation; animation_length = animation.Length; GoToRandomCell(); if (this.animation_length <= 0) Debug.LogError("Empty animation submitted to state machine!"); }
public StateGelNormal(Gel _p, SpriteRenderer _renderer, Sprite[] _animation) { p = _p; renderer = _renderer; animation = _animation; animation_length = animation.Length; GoToRandomCell(); if (this.animation_length <= 0) { Debug.LogError("Empty animation submitted to state machine!"); } }
private void openButton_Click(object sender, RoutedEventArgs e) { InfoStackPanel.Children.RemoveRange(0, InfoStackPanel.Children.Count); char[] delimiter = { ',' }; string[] fileNames = filesTextBox.Text.Split(delimiter, StringSplitOptions.RemoveEmptyEntries); if (fileNames.Length <= 0) { return; } openButton.IsEnabled = false; progressBar.Value = 0; progressBar.Minimum = 0; progressBar.Maximum = fileNames.Length; progressPanel.Visibility = Visibility.Visible; textBlocks = new TextBlock[fileNames.Length]; brightnessValues = new int[fileNames.Length]; bitmaps = new BitmapSource[fileNames.Length]; Thread gelThread = new Thread(new ThreadStart(delegate { for (int i = 0; i < fileNames.Length; ++i) { BitmapFrame frame = BitmapFrame.Create(new Uri(fileNames[i])); bitmaps[i] = ImageUtility.ToGrayScale(frame); Gel.IsInGel(ImageUtility.ToArrayImage(bitmaps[i]), (int)frame.PixelWidth, (int)frame.PixelHeight, configWindow.StartRow, configWindow.EndRow, ref brightnessValues[i], configWindow.NumOfSidePixcel, configWindow.BrightnessThreshold, configWindow.BinarizeThreshold, configWindow.PowerOfDiffrence); Dispatcher.BeginInvoke(new Action(delegate { progressBar.Value = i; progressLabel.Content = string.Format( "{0}/{1}", i.ToString(), fileNames.Length); }), null); } Dispatcher.BeginInvoke(new Action(gelThreadCallback), null); })); gelThread.IsBackground = true; gelThread.Start(); }
private Entity LoadEnemy(Vector2 pos, string enemyType, string startDirection, string itemHeld) { Entity entity; Console.WriteLine("Initializing enemy at pos " + pos); if (startDirection.Equals("")) { startDirection = "right"; } // Parse direction (passed in as string) into Direction enumerable type Constants.Direction direction; switch (startDirection) { case "up": direction = Constants.Direction.UP; break; case "right": direction = Constants.Direction.RIGHT; break; case "down": direction = Constants.Direction.DOWN; break; case "left": direction = Constants.Direction.LEFT; break; default: // start direction not neccessary, default is right direction = Constants.Direction.RIGHT; break; } switch (enemyType) { case "aquamentus": entity = new Aquamentus(pos); break; case "bladetrap": entity = new BladeTrap(pos); break; case "gel": entity = new Gel(pos); break; case "goriya": entity = new Goriya(pos); break; case "keese": entity = new Keese(pos); break; case "rope": entity = new Rope(pos); break; case "stalfo": entity = new Stalfo(pos); if (itemHeld == "regularkey") { BasicSprite keySprite = ItemSpriteFactory.Instance.CreateRegularKey(); keySprite.offsets = new List <Vector2> { new Vector2(4, 0) }; entity.AddComponent(new Sprite(keySprite)); entity.GetComponent <StalfoMovement>().SetItemHeldTrue(); } break; case "wallmaster": entity = new WallMaster(pos, direction); break; default: Console.WriteLine("Level @ LoadEnemy(): Unrecognized enemyType \"" + enemyType + "\"!"); return(null); } var poof = new Poof(pos, entity); Scene.Add(entity); Scene.Add(poof); var transform = Root.GetComponent <Transform>(); transform.AddChild(poof); numEnemiesLeft++; enemyList.Add((Enemy)entity); return(entity); }
private float time_stopped; // Between half and all of pause_seconds. public StateGelStopped(Gel _p) { p = _p; time_stopped = (1 + Random.value) / 2 * (72 * pause_seconds); }
private Entity LoadEnemy(Vector2 pos, string enemyType, string startDirection, string itemHeld) { Entity entity = null; // Parse direction (passed in as string) into Direction enumerable type Constants.Direction direction; switch (startDirection) { case "up": direction = Constants.Direction.UP; break; case "right": direction = Constants.Direction.RIGHT; break; case "down": direction = Constants.Direction.DOWN; break; case "left": direction = Constants.Direction.LEFT; break; default: // start direction not neccessary, default is right direction = Constants.Direction.RIGHT; break; } switch (enemyType) { case "aquamentus": entity = new Aquamentus(pos); break; case "bladetrap": entity = new BladeTrap(pos); break; case "gel": entity = new Gel(pos); break; //case "goriya": // entity = new Goriya(pos); // break; case "keese": entity = new Keese(pos); break; case "rope": entity = new Rope(pos); break; case "stalfo": entity = new Stalfo(pos); if (itemHeld == "regularkey") { entity.AddComponent(new Sprite(ItemSpriteFactory.Instance.CreateRegularKey())); entity.GetComponent <StalfoMovement>().SetItemHeldTrue(); } break; case "wallmaster": entity = new WallMaster(pos, direction); break; default: Console.WriteLine("Level @ LoadEnemy(): Unrecognized enemyType \"" + enemyType + "\"!"); return(null); } Scene.Add(entity); Scene.Add(new Poof(pos, entity)); return(entity); }
public void Logic(ResInfoData resinfo, double dt) { switch (resinfo.GetActionAt(0)) { case ActionPointType.Hatch: { if (resinfo.Purpose == "1") { resinfo.HatchCurTime += dt; if (resinfo.HatchCurTime >= resinfo.HatchTime) { resinfo.RemoveActionAt(0); } } else if (!(resinfo.Purpose == "4" && actionmanager.getAllActionsCount(piercerDevice) != 0)) { var seque = Sequence.create(); var put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "1"); if (put_seat == null && resinfo.Purpose != "3") { put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "3"); } if (put_seat != null) { ResInfoData put_gel = null; if (resinfo.Purpose == "lxj") { //CentrifugeMDevice cendev = cenMrg.GetCentrifugeByCode(resinfo.CenCode); //seque.AddAction(MoveTo.create(cendev, 30000, -1, -1, 0)); //seque.AddAction(InitXyz.create(cendev, 30000, false, false, true)); put_gel = generater.GenerateTakeGelFromCent(resinfo, resinfo.CenCode, ref seque); } else { put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref seque); } put_gel.HatchCurTime = 0; generater.GeneratePutGelToNormal(put_seat, put_gel, ref seque); seque.runAction(handDevice); } } } break; case ActionPointType.Centrifugal: { if (resinfo.Purpose != "lxj" && !(resinfo.Purpose == "4" && actionmanager.getAllActionsCount(piercerDevice) != 0)) { foreach (var seat in resmanager.centrifuge_list) { CentrifugeMDevice cendev = cenMrg.GetCentrifugeByCode(seat.Code); if (seat.Status == 1 && cendev != null) { bool iscanputcen = IsCanPutCen(cendev); var seque = Sequence.create(); var put_seat = resmanager.GetResByCode("null", "T_BJ_Centrifuge", cendev.Centrifugem.Code.SetValue); if (iscanputcen == false) { put_seat = null; } if (put_seat == null && resinfo.Purpose != "3") { put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "3"); } if (put_seat != null) { var spaw = Spawn.create(); var put_seque = Sequence.create(); var put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref put_seque); spaw.AddAction(put_seque); seque.AddAction(spaw); if (put_seat.Purpose == "lxj") { spaw.AddAction(MoveTo.create(cendev, 30001, -1, -1, put_seat.CenGelP[put_seat.CountX])); generater.GeneratePutGelToCent(cendev.Centrifugem.Code.SetValue, put_seat, put_gel, ref seque); } else { generater.GeneratePutGelToNormal(put_seat, put_gel, ref seque); } seque.runAction(handDevice); break; } } } } } break; case ActionPointType.PutPeiGelBack: { var seque = Sequence.create(); var put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "2"); if (put_seat != null && resinfo.Purpose == "lxj") { //CentrifugeMDevice cendev = cenMrg.GetCentrifugeByCode(resinfo.CenCode); //seque.AddAction(MoveTo.create(cendev, 30000, -1, -1, 0)); //seque.AddAction(InitXyz.create(cendev, 30000, false, false, true)); var put_gel = generater.GenerateTakeGelFromCent(resinfo, resinfo.CenCode, ref seque); generater.GeneratePutGelToNormal(put_seat, put_gel, ref seque); seque.AddAction(SkCallBackFun.create((ActionBase acttem) => { resinfo.RemoveActionAt(0); return(true); })); seque.runAction(handDevice); } } break; case ActionPointType.Camera: { var seque = Sequence.create(); var put_seat = resmanager.GetResByCode("", "T_BJ_Camera"); var wasted_seat = resmanager.GetResByCode("", "T_BJ_WastedSeat"); if (put_seat != null && wasted_seat != null && !(resinfo.Purpose == "4" && actionmanager.getAllActionsCount(piercerDevice) != 0)) { ResInfoData put_gel = null; if (resinfo.Purpose == "lxj") { //CentrifugeMDevice cendev = cenMrg.GetCentrifugeByCode(resinfo.CenCode); //seque.AddAction(MoveTo.create(cendev, 30000, -1, -1, 0)); //seque.AddAction(InitXyz.create(cendev, 30000, false, false, true)); put_gel = generater.GenerateTakeGelFromCent(resinfo, resinfo.CenCode, ref seque); } else { put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref seque); } seque.AddAction(MoveTo.create(handDevice, 3000, -1, -1, 0)); seque.AddAction(MoveTo.create(handDevice, 3000, (int)put_seat.X, (int)(put_seat.Y), -1)); seque.AddAction(MoveTo.create(handDevice, 3000, -1, -1, (int)(put_seat.Z))); //拍照分析 seque.AddAction(SkCallBackFun.create((ActionBase acttem) => { bool result = true; if (cameraDevice.IsOpen == false) { result = cameraDevice.Open(); } var bm = cameraDevice.CaptureImage(); var bag = new TestBag(Common.Enums.TestLevelEnum.Normal); var gel = new Gel(resinfo.GetGelMask()); bag.GelType = resinfo.gel; bag.Add(resinfo.GetSampleBarcode(), (byte)resinfo.GetSampleRackIndex(), (byte)resinfo.CountX); bag.SetStartTime(resinfo.StartTime); gel.SampleBarcodes.Add(resinfo.GetSampleBarcode()); cameraDevice.Save(bag, gel, bm, "888"); //cameraDevice.Close(); put_gel.RemoveActionAt(0); return(true); })); seque.AddAction(MoveTo.create(handDevice, 3000, (int)wasted_seat.X, (int)(wasted_seat.Y))); seque.AddAction(HandPutCard.create(handDevice, 3000, (int)wasted_seat.ZPut, 0)); seque.runAction(handDevice); } } break; } }