//生成在普通位抓卡 public ResInfoData GenerateTakeGelFromNormal(ResInfoData take_seat, ref Sequence seque) { if (take_seat != null) { //抓手移动 seque.AddAction(MoveTo.create(Engine.getInstance().handDevice, 3001, (int)take_seat.X, (int)(take_seat.Y), 0)); //抓手抓卡 var take_act = HandTakeCard.create(Engine.getInstance().handDevice, 3001, (int)take_seat.Z, (int)take_seat.ZLimit, (int)take_seat.ZCatch, 0); seque.AddAction(take_act); //把测试卡放在Gel位中 var geltem = take_seat.Values[take_seat.CountX, 0]; if (take_seat.Values != null) { take_seat.Values[take_seat.CountX, 0] = null; } take_act.successfun = (ActionBase act) => { ResManager.getInstance().handseat_resinfo = (ResInfoData)geltem; return(true); }; take_act.destroyfun = (ActionBase act) => { take_seat.Values[take_seat.CountX, 0] = geltem; return(true); }; } else { ErrorSystem.WriteActError("普通位找不到卡", true, false); } return(take_seat); }
//生成卡仓抓卡动作 public ResInfoData GenerateTakeGelFromWare(ResInfoData take_seat, ref Sequence seque, string gelmask = "") { if (take_seat != null) { //卡仓位移动 //抓手移动到卡仓机位 var move_act = Spawn.create( MoveTo.create(Engine.getInstance().gelwareDevice, 3001, take_seat.StoreX, -1, -1), MoveTo.create(Engine.getInstance().handDevice, 3001, take_seat.X, take_seat.Y)); seque.AddAction(move_act); //抓手抓卡 var take_act = HandTakeCard.create(Engine.getInstance().handDevice, 3001, take_seat.Z, take_seat.ZLimit, take_seat.ZCatch, 0); seque.AddAction(take_act); //把测试卡放在卡仓Gel位中 var geltem = take_seat.Values[take_seat.CountX, 0]; take_seat.Values[take_seat.CountX, 0] = null; take_act.successfun = (ActionBase act) => { ResManager.getInstance().handseat_resinfo = (ResInfoData)geltem; return(true); }; take_act.destroyfun = (ActionBase act) => { take_seat.Values[take_seat.CountX, 0] = geltem; return(true); }; } else { ErrorSystem.WriteActError("卡仓无卡", true, false); } return(take_seat); }
// TODO NOTE // Si besoin de créer des particules, il faut un générateur de particules ( ParticleGenerator<ClasseDeParticle> ) /* * "J'ai un système de particules statique deans Game1, Il te faut un générateur de particules pour créer des particules" */ public Soul(Vector2 initialPosition, Player player) { //m_transform.ParentTransform = player.Transform; m_playerInstance = player; m_sprite = new Sprite(Program.TheGame, TextureLibrary.GetSpriteSheet("soul"), m_transform); Vector2 explodePosition; if (player.IsToLeft) { explodePosition.X = player.Transform.PosX + Program.Random.Next(-72, -20); } else { explodePosition.X = player.Transform.PosX + Program.Random.Next(20, 73); } explodePosition.Y = Program.Random.Next((int)player.Transform.PosY + 50, (int)(player.Transform.PosY + 50 + ExplosionBreadth * m_playerInstance.SpeedMultiplier)); MoveToStaticAction moveToExplosionPoint = new MoveToStaticAction(Program.TheGame, m_transform, explodePosition, 1); moveToExplosionPoint.StartPosition = initialPosition; moveToExplosionPoint.Timer.Interval = BaseExplosionDuration / player.SpeedMultiplier; moveToExplosionPoint.Interpolator = new PSmoothstepInterpolation(); m_moveToPlayer = new MoveToStaticAction(Program.TheGame, m_transform, explodePosition, 1); m_moveToPlayer.StartPosition = explodePosition; m_moveToPlayer.Interpolator = new PSquareInterpolation(1); m_moveToPlayer.Timer.Interval = MoveToPlayerTime; m_animation = new Sequence(1); m_animation.AddAction(moveToExplosionPoint); m_animation.AddAction(new DelayAction(Program.TheGame, (float)(Program.Random.NextDouble() * 0.5f + 0.1f) / m_playerInstance.SpeedMultiplier)); m_animation.AddAction(m_moveToPlayer); m_animation.Start(); }
//生成放卡在普通位 public bool GeneratePutGelToNormal(T_Gel gel, ref Sequence seque, string code = "", int seatindex = -1) { var resmanager = ResManager.getInstance(); T_BJ_GelSeat gelselect = (T_BJ_GelSeat)resmanager.SearchGelCard(typeof(T_BJ_GelSeat).Name, gel, false, code, seatindex); if (gelselect != null) { //抓手移动 seque.AddAction(MoveTo.create(300000, (int)gelselect.X, (int)(gelselect.Y + gelselect.Gap * seatindex), 0)); //抓手放卡 seque.AddAction(HandPutCard.create(500000, (int)gelselect.ZPut, 0)); //把测试卡放在Gel位中 gelselect.Values[seatindex, 0] = gel; seque.destroyfun = (ActionBase act) => { gelselect.Values[seatindex, 0] = null; return(true); }; } else { ErrorSystem.WriteActError(gelselect.Code + "位已满"); } return(gelselect != null); }
//生成离心机抓卡动作 public bool GenerateTakeGelFromCent(T_Gel gel, ref Sequence seque, string code = "", int seatindex = -1) { var resmanager = ResManager.getInstance(); T_BJ_Centrifuge gelselect = (T_BJ_Centrifuge)resmanager.SearchGelCard(typeof(T_BJ_Centrifuge).Name, gel, true, code, seatindex); var centrifuge = cenMrg.GetCentrifugeByCode(code); if (centrifuge == null) { centrifuge = cenMrg.GetFreeCentrifuge(); } if (gelselect != null) { //离心机位移动 //抓手移动到离心机位 var move_act = Spawn.create( MoveTo.create(centrifuge, 30000, -1, -1, (int)(seatindex * (double)gelselect.Gel0), 5), MoveTo.create(handDevice, 30000, (int)gelselect.HandX, (int)gelselect.HandY)); seque.AddAction(move_act); //抓手抓卡 seque.AddAction(HandTakeCard.create(700000, (int)gelselect.HandZ, (int)gelselect.ZLimit, (int)gelselect.ZCatch, 0)); //把测试卡放在离心Gel位中 gelselect.Values[seatindex, 0] = null; seque.destroyfun = (ActionBase act) => { gelselect.Values[seatindex, 0] = gel; return(true); }; } else { ErrorSystem.WriteActError("离心机位打不到卡"); } return(gelselect != null); }
public void SequenceStartsOnlyOnceSubscribedTo() { _sequence.AddAction(() => _value = 2); Assert.That(_value, Is.EqualTo(0)); _sequence.Subscribe(); Assert.That(_value, Is.EqualTo(2)); }
public GameScene() { Concurrent cameraPan; Sequence panZoomSequence = new Sequence(); //m_backpackers[2].Transform.PosX += 100; Party.Initialise(); m_introSequence = new Sequence(); m_introSequence.AddAction(Party.GetMovingOutAnimation()); #region Camera Intro Pan Forward T = 5s m_cameraIntroForwardPan = new MoveToStaticAction(Globals.TheGame, World.cam_Main.Transform, Vector2.Zero, 1); m_cameraIntroForwardPan.Timer.Interval = 5.0f; m_cameraIntroForwardPan.Interpolator = new PSmoothstepInterpolation(); ScaleToAction zoom1 = new ScaleToAction(Globals.TheGame, World.cam_Main.Transform, new Vector2(IntroZoom, IntroZoom), 1); zoom1.Timer.Interval = 3.0f; zoom1.StartScale = new Vector2(WaveZoom, WaveZoom); zoom1.Interpolator = new PSmoothstepInterpolation(); panZoomSequence.AddAction(zoom1); panZoomSequence.AddAction(new DelayAction(Globals.TheGame, 1.0f)); ScaleToAction zoom2 = new ScaleToAction(Globals.TheGame, World.cam_Main.Transform, new Vector2(IntroOnExitZoom, IntroOnExitZoom), 1); zoom2.Timer.Interval = 1.0f; zoom2.StartScale = zoom1.Target; zoom2.Interpolator = new PSmoothstepInterpolation(); panZoomSequence.AddAction(zoom2); cameraPan = new Concurrent(new PastaGameLibrary.Action[] { m_cameraIntroForwardPan, panZoomSequence }); m_introSequence.AddAction(cameraPan); m_introSequence.AddAction(new DelayAction(Globals.TheGame, 0.5f)); #endregion #region Camera pan backwards T = 3s m_cameraIntroBackwardsPan = new MoveToStaticAction(Globals.TheGame, World.cam_Main.Transform, Vector2.Zero, 1); m_cameraIntroBackwardsPan.Timer.Interval = 3.0f; m_cameraIntroBackwardsPan.Interpolator = new PSmoothstepInterpolation(); zoom1 = new ScaleToAction(Globals.TheGame, World.cam_Main.Transform, new Vector2(1.0f, 1.0f), 1); zoom1.Timer.Interval = 1.0f; zoom1.StartScale = zoom2.Target; zoom1.Interpolator = new PSmoothstepInterpolation(); cameraPan = new Concurrent(new PastaGameLibrary.Action[] { m_cameraIntroBackwardsPan, zoom1 }); m_introSequence.AddAction(cameraPan); #endregion }
public Individual(Crowd crowd, Vector2 positionInCrowd) : base() { m_transform.Position = positionInCrowd; m_transform.ParentTransform = crowd.Transform; m_spriteTransform = new Transform(); m_jumpTransform = new PastaGameLibrary.Transform(m_spriteTransform, true); m_sprite = new PastaGameLibrary.Sprite(Program.TheGame, TextureLibrary.GetSpriteSheet("perso_foule"), m_jumpTransform); m_sprite.Origin = new Vector2(0.5f, 1.0f); m_saut = new Sequence(-1); /// ///Jump animation /// Vector2 jumpTarget = new Vector2(0, (float)(Program.Random.NextDouble() * JumpHeight * 0.5 + JumpHeight * 0.5)); float movementTime = (float)(Program.Random.NextDouble() * 0.5 * JumpMovementTime + JumpMovementTime * 0.5); MoveToStaticAction jumpMovement = new MoveToStaticAction(Program.TheGame, m_jumpTransform, jumpTarget, 1); jumpMovement.Timer.Interval = movementTime; jumpMovement.Interpolator = new PBounceInterpolation(0); m_saut.AddAction(jumpMovement); m_saut.AddAction(new DelayAction(Program.TheGame, TotalJumpTime - movementTime)); /// ///Walk animation /// m_walk = new MoveToStaticAction(Program.TheGame, m_jumpTransform, new Vector2(0, 1), -1); m_walk.Timer.Interval = (float)Program.Random.NextDouble() * WalkAnimationTime * 0.5f + WalkAnimationTime * 0.5f; m_walk.Interpolator = new BooleanInterpolation(); /// ///Throw player animation /// m_throw = new Sequence(1); float intensity = 1 - Math.Min(1, m_transform.Position.Length() * 0.02f); m_throwStretch = new ScaleToAction(Program.TheGame, m_jumpTransform, new Vector2(1.0f, 1 - intensity * 0.5f), 1); m_throwStretch.Interpolator = new PSmoothstepInterpolation(); ScaleToAction throwDestretch = new ScaleToAction(Program.TheGame, m_jumpTransform, new Vector2(1.0f, 1.0f), 1); throwDestretch.Timer.Interval = 0.1f; m_throw.AddAction(m_throwStretch); MoveToStaticAction throwMovement = new MoveToStaticAction(Program.TheGame, m_jumpTransform, Vector2.Zero, 1); throwMovement.StartPosition = new Vector2(0, -20 - 30 * intensity); throwMovement.Timer.Interval = 0.4f; throwMovement.Interpolator = new PBounceInterpolation(0, 1); m_throw.AddAction(new Concurrent(new PastaGameLibrary.Action[] { throwMovement, throwDestretch })); m_actionManager = new SingleActionManager(); }
//生成离心机放卡动作 public bool GeneratePutGelToCent(string cen_code, ResInfoData put_seat, ResInfoData put_gel, ref Sequence seque) { var centrifuge = Engine.getInstance().cenMrg.GetCentrifugeByCode(cen_code); if (centrifuge == null) { centrifuge = Engine.getInstance().cenMrg.GetFreeCentrifuge(); } if (put_seat != null) { //打开离心机门 var opendoor_act = HandOpenCloseDoor.create(Engine.getInstance().handDevice, 5000, cen_code, true); seque.AddAction(opendoor_act); //离心机位移动 //抓手移动到离心机位 var move_act = Spawn.create( MoveTo.create(centrifuge, 30001, -1, -1, put_seat.CenGelP[put_seat.CountX]), MoveTo.create(Engine.getInstance().handDevice, 3001, (int)put_seat.X, (int)put_seat.CenHandYP[put_seat.CountX])); seque.AddAction(move_act); //抓手放卡 var put_act = HandPutCard.create(Engine.getInstance().handDevice, 3001, (int)put_seat.ZPut); seque.AddAction(put_act); //把测试卡放在离心Gel位中 put_seat.Values[put_seat.CountX, 0] = put_gel; if (put_gel != null) { put_gel.PutOk = false; } put_act.successfun = (ActionBase act) => { if (put_gel != null) { put_gel.PutOk = true; put_gel.SetSeatInfo(put_seat); } ResManager.getInstance().handseat_resinfo = null; return(true); }; put_act.destroyfun = (ActionBase act) => { put_seat.Values[put_seat.CountX, 0] = null; ResManager.getInstance().handseat_resinfo = null; return(true); }; } else { ErrorSystem.WriteActError("离心机位已满", true, false); } return(put_seat != null); }
//生成离心机放卡动作 public bool GeneratePutGelToCent(T_Gel gel, ref Sequence seque, string code = "", int seatindex = -1) { int[] gelseatindex = { 0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11 }; var centrifuge = cenMrg.GetCentrifugeByCode(code); if (centrifuge == null) { centrifuge = cenMrg.GetFreeCentrifuge(); } var gelseat = centrifuge.GetGelSeatsInfo(); var gelseatsetting = centrifuge.GetGelSeatSetting(); bool isfind = seatindex != -1; if (seatindex == -1) { for (int i = 0; i < 12; i++) { int index = gelseatindex[i]; if (gelseat[index] == false) { seatindex = index; isfind = true; break; } } } if (isfind) { //离心机位移动 //抓手移动到离心机位 var move_act = Spawn.create( MoveTo.create(centrifuge, 30000, -1, -1, (int)(seatindex * (double)gelseatsetting.Gel0), 5), MoveTo.create(handDevice, 30000, (int)gelseatsetting.HandX, (int)gelseatsetting.HandY)); seque.AddAction(move_act); //抓手放卡 seque.AddAction(HandPutCard.create(handDevice, 30000, (int)gelseatsetting.ZPut)); //把测试卡放在离心Gel位中 gelseatsetting.Values[seatindex, 0] = gel; seque.destroyfun = (ActionBase act) => { gelseatsetting.Values[seatindex, 0] = null; return(true); }; } else { ErrorSystem.WriteActError("离心机位已满"); } return(isfind); }
//Constructor public Form_SplashScreen() { InitializeComponent(); //ProgressBar Setup ProgressBar.Maximum = 100; ProgressBar.Step = 1; ProgressBar.Value = 0; //Animation Setup this.Opacity = 0.0f; m_animTimer = new Timer(); m_animTimer.Interval = 17; //ms m_animTimer.Tick += AnimEvent; m_tweener = new Tweener <float>(); m_tweener.duration = 0.3f; //second; m_tweener.tweenDelegate = delegate(ref float value) { value = Tween.DoTween(0f, 1f, m_tweener.progress, m_tweener.type); this.Opacity = value; }; m_tweener.Start(); m_animTimer.Start(); //Sequence Execution m_sequence = new Sequence(); m_sequence.OnEachActionStart = OnEachActionStart; m_sequence.OnEachActionFinish = OnEachActionFinish; m_sequence.OnSequenceFinish = OnSequenceFinish; m_sequence.AddAction(delegate { //Initialize App App.Initialize(); }); m_sequence.AddAction(delegate { //Pinging Server Ping ping = new Ping(); m_pingReply = ping.Send(DB.ipString); }); m_sequence.AddAction(delegate { //Testing Connection DBSql.Test(); }); }
public Sequence GetNext(IState state, DeterministicRandom random) { Sequence sequence = null; ConvenienceStressState stressState = (ConvenienceStressState)state; Queue <Type> possibleActions = stressState.GetActions(random); while (possibleActions.Count > 0 && sequence == null) { DiscoverableAction action = (DiscoverableAction)Activator.CreateInstance(possibleActions.Dequeue()); Trace.WriteLine("[DiscoverableActionSequencer]Populating Action."); bool hasValidInputs = PopulateDiscoverableInputs(action, random, stressState, 0); //Add action to sequence only CanPerform is true, and input has been created successfully. if (hasValidInputs && action.CanPerform()) { sequence = new Sequence(); sequence.AddAction(action); } } if (sequence == null) { throw new InvalidOperationException("Stress could not find a new Action to perform at this state."); } return(sequence); }
static void InitialiseMovingOutAnimation() { #region Backpacker 0 Sequence waveAnimation_0 = new Sequence(); MoveToStaticAction walkMove_0 = new MoveToStaticAction(Globals.TheGame, Backpackers[0].Transform, new Vector2(MeetingPoint, 0), 1); walkMove_0.Timer.Interval = 0.5f; SpriteSheetAnimation walkAnim_0 = new SpriteSheetAnimation(Backpackers[0].Sprite, 0, 1, 0.1f, 5); waveAnimation_0.AddAction(new Concurrent(new PastaGameLibrary.Action[] { walkMove_0, walkAnim_0 })); waveAnimation_0.AddAction(new SpriteSheetAnimation(Backpackers[0].Sprite, 0, 0, 0.5f, 1)); waveAnimation_0.AddAction(new SpriteSheetAnimation(Backpackers[0].Sprite, 2, 3, 0.2f, 4)); waveAnimation_0.AddAction(new SpriteSheetAnimation(Backpackers[0].Sprite, 0, 0, 0.1f, 1)); #endregion #region Backpacker 1 Sequence waveAnimation_1 = new Sequence(); MoveToStaticAction walkMove_1 = new MoveToStaticAction(Globals.TheGame, Backpackers[1].Transform, new Vector2(MeetingPoint - 40, 0), 1); walkMove_1.Timer.Interval = 0.5f; SpriteSheetAnimation walkAnim_1 = new SpriteSheetAnimation(Backpackers[1].Sprite, 0, 1, 0.1f, 5); waveAnimation_1.AddAction(new DelayAction(Globals.TheGame, 0.2f)); waveAnimation_1.AddAction(new Concurrent(new PastaGameLibrary.Action[] { walkMove_1, walkAnim_1 })); waveAnimation_1.AddAction(new SpriteSheetAnimation(Backpackers[1].Sprite, 0, 0, 0.5f, 1)); waveAnimation_1.AddAction(new SpriteSheetAnimation(Backpackers[1].Sprite, 2, 3, 0.1f, 5)); waveAnimation_1.AddAction(new SpriteSheetAnimation(Backpackers[1].Sprite, 0, 0, 0.1f, 1)); #endregion #region Backpacker 2 Sequence waveAnimation_2 = new Sequence(); MoveToStaticAction walkMove_2 = new MoveToStaticAction(Globals.TheGame, Backpackers[2].Transform, new Vector2(MeetingPoint - 80, 0), 1); walkMove_2.Timer.Interval = 0.5f; SpriteSheetAnimation walkAnim_2 = new SpriteSheetAnimation(Backpackers[2].Sprite, 0, 1, 0.1f, 5); waveAnimation_2.AddAction(new DelayAction(Globals.TheGame, 0.4f)); waveAnimation_2.AddAction(new Concurrent(new PastaGameLibrary.Action[] { walkMove_2, walkAnim_2 })); waveAnimation_2.AddAction(new SpriteSheetAnimation(Backpackers[2].Sprite, 2, 3, 0.2f, 3)); waveAnimation_2.AddAction(new SpriteSheetAnimation(Backpackers[2].Sprite, 0, 0, 0.1f, 1)); #endregion s_movingOutAnimation = new Concurrent(new PastaGameLibrary.Action[] { waveAnimation_0, waveAnimation_1, waveAnimation_2 }); }
//生成放卡在普通位 public bool GeneratePutGelToNormal(ResInfoData put_seat, ResInfoData put_gel, ref Sequence seque) { if (put_seat != null) { //抓手移动 seque.AddAction(MoveTo.create(Engine.getInstance().handDevice, 3001, (int)put_seat.X, (int)(put_seat.Y), 0)); //抓手放卡 var put_act = HandPutCard.create(Engine.getInstance().handDevice, 3001, (int)put_seat.ZPut, 0); seque.AddAction(put_act); //把测试卡放在Gel位中 if (put_seat.Values != null) { put_seat.Values[put_seat.CountX, 0] = put_gel; } if (put_gel != null) { put_gel.PutOk = false; } put_act.successfun = (ActionBase act) => { if (put_gel != null) { put_gel.PutOk = true; put_gel.SetSeatInfo(put_seat); } ResManager.getInstance().handseat_resinfo = null; return(true); }; put_act.destroyfun = (ActionBase act) => { if (put_seat.Values != null) { put_seat.Values[put_seat.CountX, 0] = null; } ResManager.getInstance().handseat_resinfo = null; return(true); }; } else { ErrorSystem.WriteActError("普通位已满", true, false); } return(put_seat != null); }
public Monster() : base() { m_spriteSheetNomNom = TextureLibrary.GetSpriteSheet("anim_monstre_miam", 8, 1); m_spriteSheetIdle = TextureLibrary.GetSpriteSheet("anim_monstre_neutre", 5, 1); m_sprite = new Sprite(Program.TheGame, m_spriteSheetIdle, m_transform); m_sprite.PixelCorrection = true; m_idle = new SpriteSheetAnimation(m_sprite, 0, 4, 3.0f, -1); m_openMouth = new SpriteSheetAnimation(m_sprite, 4, 6, 0.5f, 1); m_closeMouth = new Sequence(1); m_closeMouth.AddAction(new SpriteSheetAnimation(m_sprite, 6, 7, 0.45f, 1)); m_closeMouth.AddAction(new MethodAction(Idle)); m_actionManager = new SingleActionManager(); m_transform.Position = new Vector2(MonsterPosX, MonsterPosY); m_breathing = new MoveToStaticAction(Program.TheGame, m_transform, m_transform.Position + new Vector2(0, 3), -1); m_breathing.Interpolator = new PSineInterpolation(); m_breathing.Timer.Interval = 4.0f; m_breathing.Start(); }
//生成离心机抓卡动作 public ResInfoData GenerateTakeGelFromCent(ResInfoData take_seat, string cen_code, ref Sequence seque) { var centrifuge = Engine.getInstance().cenMrg.GetCentrifugeByCode(cen_code); if (centrifuge == null) { centrifuge = Engine.getInstance().cenMrg.GetFreeCentrifuge(); } if (take_seat != null) { //打开离心机门 var opendoor_act = HandOpenCloseDoor.create(Engine.getInstance().handDevice, 5000, cen_code, true); seque.AddAction(opendoor_act); //离心机位移动 //抓手移动到离心机位 var move_act = Spawn.create( MoveTo.create(centrifuge, 30001, -1, -1, (int)take_seat.CenGelP[take_seat.CountX]), MoveTo.create(Engine.getInstance().handDevice, 3001, (int)take_seat.X, (int)take_seat.CenHandYP[take_seat.CountX])); seque.AddAction(move_act); //抓手抓卡 var take_act = HandTakeCard.create(Engine.getInstance().handDevice, 3001, (int)take_seat.Z, (int)take_seat.ZLimit, (int)take_seat.ZCatch, 0, centrifuge); seque.AddAction(take_act); //把测试卡放在离心Gel位中 var geltem = take_seat.Values[take_seat.CountX, 0]; take_seat.Values[take_seat.CountX, 0] = null; take_act.successfun = (ActionBase act) => { ResManager.getInstance().handseat_resinfo = (ResInfoData)geltem; return(true); }; take_act.destroyfun = (ActionBase act) => { take_seat.Values[take_seat.CountX, 0] = geltem; return(true); }; } else { ErrorSystem.WriteActError("离心机位找不到卡", true, false); } return(take_seat); }
private void Setup() { root = new Root(); var seq = new Sequence(root); seq.AddAction(new Task(Task1)); seq.AddAction(new Task(Task2)); seq.AddAction(new Task(Task3)); seq.Setup(); var sel = new Selector(root); sel.AddAction(new Task(Task4)); sel.AddAction(new Task(Task5)); seq.Setup(); root.AddNode(seq); root.AddNode(sel); root.Setup(); }
//得到恢复当前状态的动作 public bool GetReSetAct(ref Sequence seque_act) { int x = 0; int [] y = IMask.Gen(-1); int[] z = IMask.Gen(-1); var device = new ActionDevice(this); var inject_list = Injector.Entercloses.Where(item => item.InjEnable).ToList(); bool ret = device.GetRealX(ref x); ret = ret && device.GetRealY(inject_list.ToArray(), ref y); ret = ret && device.GetRealZ(inject_list.ToArray(), ref z); for (int i = 0; i < inject_list.Count; i++) { y[inject_list[i].Index] += (int)inject_list[i].TipDis; } seque_act.AddAction(InjectMoveTo.create(3000, inject_list.ToArray(), -1, IMask.Gen(-1), IMask.Gen(0))); seque_act.AddAction(InjectMoveTo.create(3000, inject_list.ToArray(), x, y, IMask.Gen(-1))); seque_act.AddAction(InjectMoveTo.create(3000, inject_list.ToArray(), -1, IMask.Gen(-1), z)); return(ret); }
//生成卡仓放卡动作 public bool GeneratePutGelToWare(ResInfoData put_seat, ResInfoData put_gel, ref Sequence seque) { if (put_seat != null) { var move_act = Spawn.create( MoveTo.create(Engine.getInstance().gelwareDevice, 3001, (int)(put_seat.StoreX), -1, -1), MoveTo.create(Engine.getInstance().handDevice, 3001, (int)put_seat.X, (int)put_seat.Y)); seque.AddAction(move_act); //抓手放卡 var put_act = HandPutCard.create(Engine.getInstance().handDevice, 3001, (int)put_seat.ZPut); seque.AddAction(put_act); //把测试卡放在离心Gel位中 put_seat.Values[put_seat.CountX, 0] = put_gel; if (put_gel != null) { put_gel.PutOk = false; } put_act.successfun = (ActionBase act) => { if (put_gel != null) { put_gel.PutOk = true; put_gel.SetSeatInfo(put_seat); } ResManager.getInstance().handseat_resinfo = null; return(true); }; put_act.destroyfun = (ActionBase act) => { put_seat.Values[put_seat.CountX, 0] = null; ResManager.getInstance().handseat_resinfo = null; return(true); }; } else { ErrorSystem.WriteActError("卡仓位已满", true, false); } return(put_seat != null); }
//生成加样移动组合 public void GenerateInjectActGroup(ref Sequence seque, ref int index, ref int[] tager, ref int[] point, ref int[] width, ref bool is_ok) { bool isforward = false; bool isback = false; if (index == 4) { is_ok = true; return; } else { isforward = index - 1 >= 0 ? tager[index] >= point[index - 1] + width[index - 1] : true; isback = index + 1 <= 3 ? tager[index] + width[index] <= point[index + 1] : true; } if (tager[index] < 0) { index++; GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } else if (isforward && isback) { //单移 bool is_moveok = point[index] == tager[index];//是否已经在那个位置了 point[index] = tager[index]; int[] y = { -1, -1, -1, -1 }; int[] z = { -1, -1, -1, -1 }; y[index] = point[index]; z[index] = -1; for (int i = 0; i < 4; i++) { injectorDevice.Injector.Entercloses[i].Selected = i == index; } var move_act = Sequence.create(); if (is_moveok == false) { move_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, y, z)); } if (index == 0) { move_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(400, -1, -1, -1))); move_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0, -1, -1, -1))); } else { move_act.AddAction(MoveTo.create(handDevice, 300000, -1, -1, 100)); move_act.AddAction(MoveTo.create(handDevice, 300000, -1, -1, 0)); } //查找上一个sp if (seque.actionlist.Count != 0 && seque.actionlist[seque.actionlist.Count() - 1] is Spawn) { int inster = is_moveok?0:1; var spawn = (Spawn)seque.actionlist[seque.actionlist.Count() - 1]; if (index != 0) { move_act.actionlist.Insert(inster, SKSleep.create(spawn.actionlist.Count * 1000)); } spawn.AddAction(move_act); } else { var spawn = Spawn.create(); spawn.AddAction(move_act); seque.AddAction(spawn); } index++; GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } else if (isforward && isback == false) { //全移 int movew = tager[index] - point[index]; bool is_once = true; for (int i = 0; i <= index; i++) { if (point[i] + movew > 20000) { is_once = false; break; } } if (is_once) { int injcount = index + 1; for (int i = index; i < injcount; i++) { point[i] = point[i] + movew; bool is_pass = i + 1 <= 3 ? point[i] + width[i] <= point[i + 1] : true; if (!is_pass) { injcount++; } } int indexx = index; int y = point[index]; //全轴 //var move_act = Sequence.create(SkCallBackFun.create((ActionBase act) => //{ // for (int i = 0; i < 4; i++) // injectorDevice.Injector.Entercloses[i].Selected = false; // for (int i = indexx; i < injcount; i++) // injectorDevice.Injector.Entercloses[i].Selected = true; // return true; //}), MoveTo.create(injectorDevice, 300000, -1, y, -1)); //单轴测 var movesp_act = Spawn.create(); var move_act = Sequence.create(); List <ActionBase> actlist = new List <ActionBase>(); for (int i = indexx; i < injcount; i++) { int[] yy = { -1, -1, -1, -1 }; int[] zz = { -1, -1, -1, -1 }; for (int j = 0; j < 4; j++) { injectorDevice.Injector.Entercloses[j].Selected = false; } injectorDevice.Injector.Entercloses[i].Selected = true; yy[i] = point[i]; actlist.Add(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz)); } for (int i = actlist.Count - 1; i >= 0; i--) { movesp_act.AddAction(actlist[i]); } move_act.AddAction(movesp_act); move_act.AddAction(SKSleep.create(1)); seque.AddAction(move_act); GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } else { int[] pointtem = { -1, -1, -1, -1 }; var movesp_act = Spawn.create(); var move_act = Sequence.create(); for (int i = indexx; i < injcount; i++) { pointtem[i] = tager[index] - width[i] * (index - i); if (pointtem[i] < 0) { is_ok = false; return; } } for (int i = 0; i <= index; i++) { int[] yy = { -1, -1, -1, -1 }; int[] zz = { -1, -1, -1, -1 }; point[i] = pointtem[i]; for (int j = 0; j < 4; j++) { injectorDevice.Injector.Entercloses[j].Selected = false; } yy[i] = point[i]; injectorDevice.Injector.Entercloses[i].Selected = true; movesp_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz)); } move_act.AddAction(movesp_act); move_act.AddAction(SKSleep.create(1)); seque.AddAction(move_act); GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } } else if (isforward == false && isback) { //等待前面完成 int movew = tager[index] - point[index]; bool is_once = true; for (int i = 0; i <= index; i++) { if (point[i] + movew < 0) { is_once = false; break; } } if (is_once) { for (int i = 0; i <= index; i++) { point[i] = point[i] + movew; } int y = point[0]; int count = index; //全轴 //var move_act = Sequence.create(SkCallBackFun.create((ActionBase act) => { // for (int i = 0; i < count; i++) // injectorDevice.Injector.Entercloses[i].Selected = true; // return true; //}), MoveTo.create(injectorDevice, 300000, -1, y, -1)); //单轴测 var movesp_act = Spawn.create(); var move_act = Sequence.create(); for (int i = 0; i <= count; i++) { int[] yy = { -1, -1, -1, -1 }; int[] zz = { -1, -1, -1, -1 }; for (int j = 0; j < 4; j++) { injectorDevice.Injector.Entercloses[j].Selected = false; } yy[i] = point[i]; injectorDevice.Injector.Entercloses[i].Selected = true; movesp_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz)); } move_act.AddAction(movesp_act); move_act.AddAction(SKSleep.create(1)); seque.AddAction(move_act); GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } else { int[] pointtem = { -1, -1, -1, -1 }; var movesp_act = Spawn.create(); var move_act = Sequence.create(); for (int i = 0; i <= index; i++) { pointtem[i] = tager[index] - width[i] * (index - i); if (pointtem[i] < 0) { is_ok = false; return; } } for (int i = 0; i <= index; i++) { int[] yy = { -1, -1, -1, -1 }; int[] zz = { -1, -1, -1, -1 }; point[i] = pointtem[i]; for (int j = 0; j < 4; j++) { injectorDevice.Injector.Entercloses[j].Selected = false; } yy[i] = point[i]; injectorDevice.Injector.Entercloses[i].Selected = true; movesp_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz)); } move_act.AddAction(movesp_act); move_act.AddAction(SKSleep.create(1)); seque.AddAction(move_act); GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } } }
//生成加样移动组合 public void GenerateInjectActGroup(ref Sequence seque, ref int index, ref int[] tager, ref int[] point, ref int[] width, ref bool is_ok) { if (index == 4) { is_ok = true; return; } bool isforward = index - 1 >= 0 ? tager[index] >= point[index - 1] + width[index - 1] : true; bool isback = index + 1 <= 3 ? tager[index] + width[index] <= point[index + 1] : true; if (tager[index] < 0) { index++; GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } else if (isforward && isback) { //单移 bool is_moveok = point[index] == tager[index];//是否已经在那个位置了 point[index] = tager[index]; int[] y = { -1, -1, -1, -1 }; int[] z = { -1, -1, -1, -1 }; y[index] = point[index]; z[index] = -1; for (int i = 0; i < 4; i++) { injectorDevice.Injector.Entercloses[i].Selected = i == index; } var move_act = Sequence.create(); if (is_moveok == false) { move_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, y, z)); } if (index == 0) { move_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(400, -1, -1, -1))); move_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0, -1, -1, -1))); } else { move_act.AddAction(MoveTo.create(handDevice, 300000, -1, -1, 100)); move_act.AddAction(MoveTo.create(handDevice, 300000, -1, -1, 0)); } //查找上一个sp if (seque.actionlist.Count != 0 && seque.actionlist[seque.actionlist.Count() - 1] is Spawn) { int inster = is_moveok?0:1; var spawn = (Spawn)seque.actionlist[seque.actionlist.Count() - 1]; if (index != 0) { move_act.actionlist.Insert(inster, SKSleep.create(spawn.actionlist.Count * 1000)); } spawn.AddAction(move_act); } else { var spawn = Spawn.create(); spawn.AddAction(move_act); seque.AddAction(spawn); } index++; GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } else if (isforward == false || isback == false) { int movew = tager[index] - point[index]; int[] stori = isback ? IMask.Gen(0, 1, 2, 3): IMask.Gen(3, 2, 1, 0); int count = isback ? (index + 1) : (4 - index); int fx = isback ? -1 : 1; int[] pointtem = { point[0], point[1], point[2], point[3] }; for (int i = 0; i < count; i++) { if (pointtem[stori[i]] + movew >= 0) { pointtem[stori[i]] = pointtem[stori[i]] + movew; } else { pointtem[stori[i]] = tager[index] + width[stori[i]] * (stori[i] - index); } if (pointtem[stori[i]] < 0) { is_ok = false; return; } } var movesp_act = Spawn.create(); var move_act = Sequence.create(); for (int i = 0; i < count; i++) { int[] yy = { -1, -1, -1, -1 }; int[] zz = { -1, -1, -1, -1 }; int indextem = stori[i]; point[indextem] = pointtem[indextem]; for (int j = 0; j < 4; j++) { injectorDevice.Injector.Entercloses[j].Selected = false; } yy[indextem] = point[indextem]; injectorDevice.Injector.Entercloses[indextem].Selected = true; movesp_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz)); } move_act.AddAction(movesp_act); move_act.AddAction(SKSleep.create(1)); seque.AddAction(move_act); GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } }
public Player() : base() { isToLeft = true; canClimb = true; isFalling = false; comboCount = 0; isPoweredUp = false; m_actionManager = new SingleActionManager(); m_spriteAnimation = new SingleActionManager(); m_spriteTransform = new Transform(m_transform, true); m_leftTransform = new Transform(m_transform, true); m_rightTransform = new Transform(m_transform, true); m_bounceTransform = new Transform(m_transform, true); m_soulHotspot = new Transform(m_spriteTransform, true); m_soulHotspot.Position = new Vector2(10, -10); m_soulAbsorptionPosition = new Transform(m_spriteTransform, true); m_soulAbsorptionPosition.Position = new Vector2(0, 1); m_transform.PosX = -walkingDistance; m_spriteTransform.PosX = DistanceFromTotemCenter; m_leftTransform.Position = new Vector2(DistanceFromTotemCenter, 0); m_rightTransform.Position = new Vector2(-DistanceFromTotemCenter, 0); m_sprite = new Sprite(Program.TheGame, TextureLibrary.GetSpriteSheet("player", 4, 8), m_spriteTransform); m_spriteAura = new Sprite(Program.TheGame, TextureLibrary.GetSpriteSheet("power_up"), new Transform(m_spriteTransform, true)); m_spriteAura.Origin = new Vector2(-2f, 0.5f); //m_spriteAura.Transform.PosX = -5; m_spriteAura.Transform.Scale = new Vector2(0); // Mouvement walkingToTotem // Mouvement d'introduction au jeu : on voit le personnage à distance, puis // quand on commence, il se rapproche du totem // m_walkingToTotem = new MoveToTransform(Program.TheGame, m_transform, m_transform, new Transform(), 1); m_walkingToTotem.Interpolator = new PSmoothstepInterpolation(); m_walkingToTotem.Timer.Interval = walkingDuration; #region Slash Animations /// /// Slash left to right. /// Le mouvement est exécuté en parallèle avec une séquence délai + action. /// Autrement dit, vers la moitié de l'animation, il y a test de collision. /// Comme ça, le bloc peut être éjecté à un moment très précis, et il n'y a pas de collisions intempestives. /// On a: Concurrent(Mouvement + Sequence(delai => test collision)) /// m_movementLR = new MoveToTransform(Program.TheGame, m_spriteTransform, m_leftTransform, m_rightTransform, 1); m_movementLR.Interpolator = new PSmoothstepInterpolation(); m_movementLR.Timer.Interval = SlashDuration; m_slashDelayLR = new DelayAction(Program.TheGame, CollisionDelayDuration); MethodAction collisionLR = new MethodAction(delegate() { DoCollisionWithSections(false); }); Sequence slashActionLR = new Sequence(1); slashActionLR.AddAction(m_slashDelayLR); slashActionLR.AddAction(collisionLR); m_slashLR = new Concurrent(new PastaGameLibrary.Action[] { slashActionLR, m_movementLR }); m_metalBounceLR = new MoveToTransform(Program.TheGame, m_spriteTransform, m_bounceTransform, m_leftTransform, 1); m_metalBounceLR.Timer.Interval = SlashDuration - CollisionDelayDuration; //Le reste de temps après la collision /// /// Slash Right To Left /// Même principe que l'autre sens /// m_movementRL = new MoveToTransform(Program.TheGame, m_spriteTransform, m_rightTransform, m_leftTransform, 1); m_movementRL.Interpolator = new PSmoothstepInterpolation(); m_movementRL.Timer.Interval = SlashDuration; m_slashDelayRL = new DelayAction(Program.TheGame, CollisionDelayDuration); MethodAction collisionRL = new MethodAction(delegate() { DoCollisionWithSections(true); }); Sequence slashActionRL = new Sequence(1); slashActionRL.AddAction(m_slashDelayRL); slashActionRL.AddAction(collisionRL); m_slashRL = new Concurrent(new PastaGameLibrary.Action[] { slashActionRL, m_movementRL }); #endregion #region Bounce Animations // // Mouvement de rebond volontaire gauche // m_bounceMovementLL = new MoveToTransform(Program.TheGame, m_spriteTransform, m_leftTransform, m_bounceTransform, 1); m_bounceMovementLL.Timer.Interval = SlashDuration; m_bounceMovementLL.Interpolator = new PBounceInterpolation(0.5f); MethodAction actionL = new MethodAction( delegate() { m_bounceTransform.PosY = 0; m_bounceTransform.PosX = m_leftTransform.PosX + (m_rightTransform.PosX - m_leftTransform.PosX) * CollisionDelayRatio; }); m_slashBounceLR = new Concurrent(new PastaGameLibrary.Action[] { actionL, slashActionLR, m_bounceMovementLL }); // // Mouvement de rebond volontaire droite // m_bounceMovementRR = new MoveToTransform(Program.TheGame, m_spriteTransform, m_rightTransform, m_bounceTransform, 1); m_bounceMovementRR.Timer.Interval = SlashDuration; m_bounceMovementRR.Interpolator = new PBounceInterpolation(0.5f); MethodAction actionR = new MethodAction( delegate() { m_bounceTransform.PosY = 0; m_bounceTransform.PosX = m_rightTransform.PosX - (m_rightTransform.PosX - m_leftTransform.PosX) * CollisionDelayRatio; }); m_slashBounceRL = new Concurrent(new PastaGameLibrary.Action[] { actionR, slashActionRL, m_bounceMovementRR }); m_metalBounceRL = new MoveToTransform(Program.TheGame, m_spriteTransform, m_bounceTransform, m_rightTransform, 1); m_metalBounceRL.Timer.Interval = SlashDuration - CollisionDelayDuration; //Le reste de temps après la collision #endregion m_spritAnimLR = new SpriteSheetAnimation(m_sprite, 0, 7, SlashDuration, 1); m_spritAnimRL = new SpriteSheetAnimation(m_sprite, 8, 15, SlashDuration, 1); m_spritAnimLL = new SpriteSheetAnimation(m_sprite, 16, 23, SlashDuration, 1); m_spritAnimRR = new SpriteSheetAnimation(m_sprite, 23, 30, SlashDuration, 1); m_ready = new SpriteSheetAnimation(m_sprite, 0, 4, SlashDuration, 1); m_ready.Timer.Interval = 0.5f; }
//生成加样移动组合 public void GenerateInjectActGroup(ref Sequence seque, int [] hitsort, ref int index, ref ActionPoint[] tager, ref int[] point, ref int[] width, ref double[] width_rate, ref bool is_ok, ActionBase move_x = null) { int hit_index = 0; if (index < 4) { hit_index = hitsort[index]; } if (index == 4) { is_ok = true; return; } else if ((tager[hit_index].isdone && tager[hit_index].y == point[hit_index]) || tager[hit_index].y == -1) { index++; GenerateInjectActGroup(ref seque, hitsort, ref index, ref tager, ref point, ref width, ref width_rate, ref is_ok, move_x); } else { List <int[]> node_list = new List <int[]>(); int[] width_tem = IMask.Gen(0); for (int i = 0; i < 4; i++) { width_tem[i] = (int)(width[i] * width_rate[hit_index]); } for (int i = 0; i < 4; i++) { for (int j = i; j < 4; j++) { for (int k = j; k < 4; k++) { for (int l = k; l < 4; l++) { int[] point_tem = { 0, 0, 0, 0 }; point_tem[i] = tager[i].y; point_tem[j] = tager[j].y; point_tem[k] = tager[k].y; point_tem[l] = tager[l].y; for (int n = 0; n < 4; n++) { if (point_tem[n] < 0) { point_tem[n] = 0; } } bool ispass = true; int frist = 0; for (int n = 0; n < 4; n++) { if (point_tem[n] != 0) { frist = n; break; } } for (int n = frist; n < 4; n++) { if (point_tem[n] == 0 && n - 1 >= 0) { point_tem[n] = point_tem[n - 1] + width_tem[n]; } } for (int n = 0; n < frist; n++) { if (point_tem[n] == 0 && n + 1 <= 3) { point_tem[n] = point_tem[frist] - width_tem[n] * (frist - n); } } for (int n = 0; n < 4; n++) { bool isforward = n - 1 >= 0 ? point_tem[n] >= point_tem[n - 1] + width_tem[n - 1] : true; bool isback = n + 1 <= 3 ? point_tem[n] + width_tem[n] <= point_tem[n + 1] : true; ispass = isforward && isforward; if (!ispass) { break; } } if (ispass && point_tem[hit_index] == tager[hit_index].y) { node_list.Add(point_tem); } } } } } int[] minnode = node_list[0]; foreach (var node in node_list) { if (GetLoss(tager, node) < GetLoss(tager, minnode)) { minnode = node; } } List <int> left = new List <int>(); List <int> right = new List <int>(); for (int i = 0; i < 4; i++) { if (point[i] - minnode[i] < 0) { left.Add(i); } else { right.Add(i); } } left.Sort((a, b) => { return(a < b ? 1 : -1); }); right.Sort((a, b) => { return(a > b ? 1 : -1); }); var movesp_act = Spawn.create(); var move_act = Sequence.create(); string msg = ""; int[] yy = IMask.Gen(-1); int[] zz = IMask.Gen(-1); List <Enterclose> ents = new List <Enterclose>(); for (int i = 0; i < left.Count; i++) { int indextem = left[i]; if (point[indextem] != minnode[indextem]) { ents.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[indextem]); yy[indextem] = minnode[indextem]; } } for (int i = 0; i < right.Count; i++) { int indextem = right[i]; if (point[indextem] != minnode[indextem]) { ents.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[indextem]); yy[indextem] = minnode[indextem]; } } movesp_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, yy, zz)); for (int i = 0; i < 4; i++) { point[i] = minnode[i]; } move_act.AddAction(movesp_act); //得到到达的点 List <ActionPoint> done_points = new List <ActionPoint>(); List <Enterclose> entcloses = new List <Enterclose>(); for (int i = 0; i < 4; i++) { if (tager[i].y == point[i] && tager[i].isdone == false) { done_points.Add(tager[i]); entcloses.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[i]); tager[i].isdone = true; } } var run_act = Sequence.create(); //对到达的点进行分类生成 int[] injz = IMask.Gen(-1); int[] injzl = IMask.Gen(-1); int[] injzd = IMask.Gen(-1); int[] absorbs = IMask.Gen(-1); run_act.AddAction(SkWaitForAction.create(move_x)); if (done_points.Count != 0) { if (done_points[0].type == TestStepEnum.JXZT) { var injact_sp = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z; absorbs[entcloses[i].Index] = (int)entcloses[0].PumpMotor.Maximum.SetValue; } injact_sp.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 2)); injact_sp.AddAction(InjectAbsorbMove.create(3001, entcloses.ToArray(), 100, absorbs)); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].zb; } run_act.AddAction(injact_sp); run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz)); } else if (done_points[0].type == TestStepEnum.PutTip) { var sequ = Sequence.create(); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z; } sequ.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 2)); sequ.AddAction(MoveTo.create(3001, done_points[0].puttip_x, -1, -1)); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z - 1000; } sequ.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 1)); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].zb; } sequ.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz)); run_act.AddAction(sequ); } else if (done_points[0].type == TestStepEnum.AbsLiquid) { run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), IMask.Gen(-1), 0)); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z + done_points[i].deep; absorbs[entcloses[i].Index] = -(done_points[i].capacity); } run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, done_points[0].deepspeed)); run_act.AddAction(InjectAbsorb.create(3001, entcloses.ToArray(), done_points[0].absbspeed, absorbs)); //回吸 var back_act = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { if (done_points[i].backcapacity != 0) { absorbs[entcloses[i].Index] = -(done_points[i].backcapacity); List <Enterclose> ent_tem = new List <Enterclose>(); ent_tem.Add(entcloses[i]); back_act.AddAction(Sequence.create(SKSleep.create(200), InjectAbsorb.create(3001, ent_tem.ToArray(), done_points[i].backspeed, absorbs))); } } for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].zb; } back_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz)); run_act.AddAction(back_act); } else if (done_points[0].type == TestStepEnum.FollowAbsLiquid) { for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z; injzl[entcloses[i].Index] = done_points[i].z + done_points[i].detectordeep; injzd[entcloses[i].Index] = done_points[i].deep; absorbs[entcloses[i].Index] = -(done_points[i].capacity); } run_act.AddAction(InjectDetector.create(3001, entcloses.ToArray(), injz, injzl, injzd, 2, 1)); run_act.AddAction(InjectAbsorb.create(3001, entcloses.ToArray(), done_points[0].absbspeed, absorbs)); //回吸 var back_act = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { if (done_points[i].backcapacity != 0) { absorbs[entcloses[i].Index] = -(done_points[i].backcapacity); List <Enterclose> ent_tem = new List <Enterclose>(); ent_tem.Add(entcloses[i]); back_act.AddAction(Sequence.create(SKSleep.create(200), InjectAbsorb.create(3001, ent_tem.ToArray(), done_points[i].backspeed, absorbs))); } } for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].zb; } back_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz)); run_act.AddAction(back_act); } else if (done_points[0].type == TestStepEnum.SpuLiquid) { for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z; absorbs[entcloses[i].Index] = done_points[i].spucapacity + done_points[i].backcapacity; } run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 2)); run_act.AddAction(InjectAbsorb.create(3001, entcloses.ToArray(), done_points[0].spuspeed, absorbs)); //回吸 var back_act = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { if (done_points[i].backcapacity != 0) { absorbs[entcloses[i].Index] = -(done_points[i].backcapacity); List <Enterclose> ent_tem = new List <Enterclose>(); ent_tem.Add(entcloses[i]); back_act.AddAction(Sequence.create(SKSleep.create(200), InjectAbsorb.create(3001, ent_tem.ToArray(), done_points[i].backspeed, absorbs))); } } for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].zb; } back_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz)); run_act.AddAction(back_act); } else if (done_points[0].type == TestStepEnum.MixLiquid) { for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z; absorbs[entcloses[i].Index] = done_points[i].capacity + done_points[i].backcapacity; } run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 2)); run_act.AddAction(InjectAbsorb.create(3001, entcloses.ToArray(), 100, absorbs));//把稀释液放进去 //混合操作 var mix_act = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { List <Enterclose> ent_tem = new List <Enterclose>(); ent_tem.Add(entcloses[i]); var mix_seq_act = Sequence.create(); if (done_points[i].mixtimes != 0) { for (int j = 0; j < done_points[i].mixtimes * 2; j++) { int mixz = done_points[i].z - done_points[i].mixdeep;//混合高度 if (mixz <= 0) { mixz = done_points[i].z; } absorbs[entcloses[i].Index] = j % 2 == 0 ? -done_points[i].capacity : done_points[i].capacity; injz[entcloses[i].Index] = j % 2 == 0 ? done_points[i].z : mixz; mix_seq_act.AddAction(InjectMoveTo.create(3001, ent_tem.ToArray(), -1, IMask.Gen(-1), injz, 2)); mix_seq_act.AddAction(InjectAbsorb.create(30001, ent_tem.ToArray(), 100, absorbs)); } injz[entcloses[i].Index] = done_points[i].z; mix_seq_act.AddAction(InjectMoveTo.create(3001, ent_tem.ToArray(), -1, IMask.Gen(-1), injz, 2)); absorbs[entcloses[i].Index] = (int)ent_tem[0].PumpMotor.Maximum.SetValue; mix_seq_act.AddAction(InjectAbsorbMove.create(3001, ent_tem.ToArray(), 100, absorbs)); absorbs[entcloses[i].Index] = -(done_points[i].GetTubeList().Count *done_points[i].spucapacity); mix_seq_act.AddAction(InjectAbsorb.create(3001, ent_tem.ToArray(), 100, absorbs)); } mix_act.AddAction(mix_seq_act); } run_act.AddAction(mix_act); var zb_act = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].zb; } zb_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz)); //回吸 var back_act = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { List <Enterclose> ent_tem = new List <Enterclose>(); ent_tem.Add(entcloses[i]); if (done_points[i].backcapacity != 0 && done_points[i].mixtimes != 0) { absorbs[entcloses[i].Index] = -(done_points[i].backcapacity); back_act.AddAction(Sequence.create(SKSleep.create(500), InjectAbsorb.create(3001, ent_tem.ToArray(), done_points[i].backspeed, absorbs))); } } zb_act.AddAction(back_act); run_act.AddAction(zb_act); } } move_act.AddAction(run_act); seque.AddAction(move_act); GenerateInjectActGroup(ref seque, hitsort, ref index, ref tager, ref point, ref width, ref width_rate, ref is_ok, move_x); } }
//生成加样移动组合 public void GenerateInjectActGroup(ref Sequence seque, ref int index, ref int[] tager, ref int[] point, ref int[] width, ref bool is_ok) { if (index == 4) { is_ok = true; return; } else if (tager[index] == point[index] || tager[index] == -1) { if (tager[index] == point[index]) { List <Enterclose> ents = new List <Enterclose>(); if (index == 0) { var move_act = Sequence.create(); ents.Add(injectorDevice.Injector.Entercloses[index]); move_act.AddAction(InjectMoveTo.create(300000, ents.ToArray(), -1, IMask.Gen(-1), IMask.Gen(400, -1, -1, -1))); move_act.AddAction(InjectMoveTo.create(300000, ents.ToArray(), -1, IMask.Gen(-1), IMask.Gen(0, -1, -1, -1))); seque.AddAction(move_act); } else { var move_act = Sequence.create(); move_act.AddAction(MoveTo.create(handDevice, 300000, -1, -1, 100)); move_act.AddAction(MoveTo.create(handDevice, 300000, -1, -1, 0)); seque.AddAction(move_act); } } index++; GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } else { List <int[]> node_list = new List <int[]>(); for (int i = 0; i < 4; i++) { for (int j = i; j < 4; j++) { for (int k = j; k < 4; k++) { for (int l = k; l < 4; l++) { int[] point_tem = { 0, 0, 0, 0 }; point_tem[i] = tager[i]; point_tem[j] = tager[j]; point_tem[k] = tager[k]; point_tem[l] = tager[l]; for (int n = 0; n < 4; n++) { if (point_tem[n] < 0) { point_tem[n] = 0; } } bool ispass = true; int frist = 0; for (int n = 0; n < 4; n++) { if (point_tem[n] != 0) { frist = n; break; } } for (int n = frist; n < 4; n++) { if (point_tem[n] == 0 && n - 1 >= 0) { point_tem[n] = point_tem[n - 1] + width[n]; } } for (int n = 0; n < frist; n++) { if (point_tem[n] == 0 && n + 1 <= 3) { point_tem[n] = point_tem[frist] - width[n] * (frist - n); } } for (int n = 0; n < 4; n++) { bool isforward = n - 1 >= 0 ? point_tem[n] >= point_tem[n - 1] + width[n - 1] : true; bool isback = n + 1 <= 3 ? point_tem[n] + width[n] <= point_tem[n + 1] : true; ispass = isforward && isforward; if (!ispass) { break; } } if (ispass && point_tem[index] == tager[index]) { node_list.Add(point_tem); } } } } } int[] minnode = node_list[0]; foreach (var node in node_list) { if (GetLoss(tager, node) < GetLoss(tager, minnode)) { minnode = node; } } List <int> left = new List <int>(); List <int> right = new List <int>(); for (int i = 0; i < 4; i++) { if (point[i] - minnode[i] < 0) { left.Add(i); } else { right.Add(i); } } left.Sort((a, b) => { return(a < b ? 1 : -1); }); right.Sort((a, b) => { return(a > b ? 1 : -1); }); var movesp_act = Spawn.create(); var move_act = Sequence.create(); string msg = ""; int[] yy = { -1, -1, -1, -1 }; int[] zz = { -1, -1, -1, -1 }; List <Enterclose> ents = new List <Enterclose>(); for (int i = 0; i < left.Count; i++) { int indextem = left[i]; if (point[indextem] != minnode[indextem]) { ents.Add(injectorDevice.Injector.Entercloses[indextem]); yy[indextem] = minnode[indextem]; } } movesp_act.AddAction(InjectMoveTo.create(300000, ents.ToArray(), -1, yy, zz)); ents.Clear(); for (int i = 0; i < right.Count; i++) { int indextem = right[i]; if (point[indextem] != minnode[indextem]) { ents.Add(injectorDevice.Injector.Entercloses[indextem]); yy[indextem] = minnode[indextem]; } } movesp_act.AddAction(InjectMoveTo.create(300000, ents.ToArray(), -1, yy, zz)); //for (int i = 0; i < 4; i++) //{ // for (int j = 0; j < 4; j++) // injectorDevice.Injector.Entercloses[j].Selected = false; // int[] yy = { -1, -1, -1, -1 }; // int[] zz = { -1, -1, -1, -1 }; // if (i < left.Count) // { // //msg = msg + "left " + left[i] + ":" + point[left[i]] + "->" + (minnode[left[i]] + " "); // int indextem = left[i]; // if (point[indextem] !=minnode[indextem]) // { // yy[indextem] = minnode[indextem]; // injectorDevice.Injector.Entercloses[indextem].Selected = true; // movesp_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz)); // } // } // for (int j = 0; j < 4; j++) // injectorDevice.Injector.Entercloses[j].Selected = false; // if (i < right.Count) // { // //msg = msg + "right " + right[i] + ":" + point[right[i]] + "->" + (minnode[right[i]] + " "); // int indextem = right[i]; // if (point[indextem] != minnode[indextem]) // { // yy[indextem] = minnode[indextem]; // injectorDevice.Injector.Entercloses[indextem].Selected = true; // movesp_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz)); // } // } //} for (int i = 0; i < 4; i++) { point[i] = minnode[i]; } move_act.AddAction(movesp_act); move_act.AddAction(SKSleep.create(1)); seque.AddAction(move_act); GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } }
public static void Initalise() { cutscenePlayer = new CutscenePlayer(); cutscenePlayer.Transform.PosX = -100; monster = new Monster(); crowd = new Crowd(40, 18, new Vector2(2.5f, 0.5f)); title = new Title(); DelayAction cameraDelay = new DelayAction(Program.TheGame, CameraDelay); moveToTotem = new MoveToStaticAction(Program.TheGame, Game1.GameCamera.Transform, Vector2.Zero, 1); moveToTotem.StartPosition = new Vector2(CameraMenuX, CameraMenuY); moveToTotem.Interpolator = new PSmoothstepInterpolation(); moveToTotem.Timer.Interval = TimeToFirstTotem; MethodAction moveCrowd = new MethodAction(delegate() { crowd.MoveTo(currentTotemPosition + TotemCrowdOffset, TimeToFirstTotem); }); gotoFirstTotem = new Sequence(1); gotoFirstTotem.AddAction(cameraDelay); gotoFirstTotem.AddAction(moveCrowd); gotoFirstTotem.AddAction(moveToTotem); gotoFirstTotem.AddAction(new MethodAction(delegate() { Cutscenes.ThrowPlayer(Game1.CurrentTotem); })); playerLaunch = new Sequence(1); playerLaunch.AddAction(new DelayAction(Program.TheGame, Crowd.LaunchTensionTime)); moveToAscendingPlayer = new MoveToTransform(Program.TheGame, Game1.GameCamera.Transform, new Transform(), cutscenePlayer.Transform, 1); moveToAscendingPlayer.Interpolator = new PSquareInterpolation(0.1f); moveToAscendingPlayer.RotationActive = false; playerLaunch.AddAction(moveToAscendingPlayer); readySequence = new Sequence(1); Transform end = new Transform(Game1.player.Transform, true); end.PosY = Game1.CameraOffset; moveToFallingPlayer = new MoveToTransform(Program.TheGame, Game1.GameCamera.Transform, new Transform(), end, 1); moveToFallingPlayer.Interpolator = new PSmoothstepInterpolation(); moveToFallingPlayer.RotationActive = false; readySequence.AddAction(new MethodAction(delegate() { Game1.player.GetReady(); })); readySequence.AddAction(moveToFallingPlayer); readySequence.AddAction(new MethodAction(delegate() { Game1.player.StartCountDown(); })); cameraZoom = new ScaleToAction(Program.TheGame, Game1.GameCamera.Transform, Vector2.Zero, 1); cameraZoom.Interpolator = new PSmoothstepInterpolation(); cameraZoom.Timer.Interval = 0.3f; goToPlayerOnGround = new Sequence(1); goToPlayerOnGroundMovement = new MoveToTransform(Program.TheGame, Game1.GameCamera.Transform, new Transform(), cutscenePlayer.Transform, 1); goToPlayerOnGroundMovement.Timer.Interval = 1.0f; goToPlayerOnGroundMovement.Interpolator = new PSmoothstepInterpolation(); goToPlayerOnGround.AddAction(new DelayAction(Program.TheGame, 0.5f)); goToPlayerOnGround.AddAction(goToPlayerOnGroundMovement); intro = new Sequence(1); MoveToStaticAction moveToMenu = new MoveToStaticAction(Program.TheGame, Game1.GameCamera.Transform, new Vector2(CameraMenuX, CameraMenuY), 1); moveToMenu.Timer.Interval = MoveInTime + 1.0f; intro.AddAction(moveToMenu); intro.AddAction(new MethodAction(delegate() { crowd.PushNewGuy(); })); intro.AddAction(new DelayAction(Program.TheGame, 1.5f)); intro.AddAction(new MethodAction(delegate() { StartMainMenu(); })); goToCliff = new Sequence(1); goToCliff.AddAction(moveToTotem); goToCliff.AddAction(new MethodAction(delegate() { cutscenePlayer.GiveSouls(Game1.TotalScore); monster.OpenMouth(); })); auraTexture = TextureLibrary.GetSpriteSheet("soul_temp"); soulTexture = TextureLibrary.GetSpriteSheet("soul"); //moveToAscendingPlayer = new MoveToTransform(Program.TheGame, Game1.GameCamera.Transform, new Transform(), cutscenePlayer.Transform, 1); }
public CutscenePlayer() : base() { m_ascendSound = SoundEffectLibrary.Get("ascend").CreateInstance(); m_cloud = new Prop("cloud"); m_sword = new Prop("sword"); m_shlingSprite = new Sprite(Program.TheGame, TextureLibrary.GetSpriteSheet("shling"), new Transform(m_transform, true)); m_sprite = new PastaGameLibrary.Sprite(Program.TheGame, TextureLibrary.GetSpriteSheet("player_cutscene", 1, 4), new Transform(m_transform, true)); m_sprite.Origin = new Vector2(0.5f, 0.5f); m_sprite.PixelCorrection = false; m_moveToCrowd = new MoveToTransform(Program.TheGame, m_transform, null, null, 1); m_moveToCrowd.Timer.Interval = 0.1f; MoveToStaticAction carryMovement = new MoveToStaticAction(Program.TheGame, m_transform, new Vector2(0, CarryHeight - 5), 1); carryMovement.Interpolator = new PBounceInterpolation(1.0f); carryMovement.StartPosition = new Vector2(0, CarryHeight); carryMovement.Timer.Interval = 0.2f; MethodAction action = new MethodAction(delegate() { carryMovement.StartPosition = new Vector2(0, CarryHeight); }); Sequence bounceAnimation = new Sequence(-1); bounceAnimation.AddAction(carryMovement); bounceAnimation.AddAction(action); m_carryAnimation = new Sequence(1); m_carryAnimation.AddAction(m_moveToCrowd); m_carryAnimation.AddAction(bounceAnimation); //Sword movement Transform start = new Transform(m_transform, true); Transform end = new Transform(m_transform, true); m_swordMovement = new MoveToTransform(Program.TheGame, m_sword.Transform, start, end, 1); end.PosX = SwordOffsetToPlayerX; end.PosY = SwordOffsetToPlayerY; m_swordDelay = new DelayAction(Program.TheGame, AscendDuration * SwordStartTimeRatio); //Cloud movement m_cloudMovement = new MoveToStaticAction(Program.TheGame, m_cloud.Transform, new Vector2(CloudOffsetToPlayerX, CloudOffsetToPlayerY), 1); m_cloudMovement.StartPosition = new Vector2(CloudStartX, 0); m_cloudMovement.Interpolator = new PSquareInterpolation(0.25f); //Delay of the ascend, then sword/cloud movement Sequence swordAndCloudMovement = new Sequence(1); swordAndCloudMovement.AddAction(m_swordDelay); swordAndCloudMovement.AddAction(new Concurrent(new PastaGameLibrary.Action[] { m_swordMovement, m_cloudMovement })); m_ascendMovement = new MoveToTransform(Program.TheGame, m_transform, new Transform(), new Transform(), 1); m_ascendMovement.Interpolator = new PSquareInterpolation(0.5f); MethodAction showPlayer = new MethodAction(delegate() { m_sprite.Transform.PosY -= 1; Game1.player.ShowPlayer(); isVisible = false; m_cloud.IsVisible = false; m_sword.IsVisible = false; }); //Shling! ScaleToAction shlingScale = new ScaleToAction(Program.TheGame, m_shlingSprite.Transform, new Vector2(ShlingScale, ShlingScale), 1); shlingScale.Timer.Interval = ShlingTime; shlingScale.StartScale = Vector2.Zero; shlingScale.Interpolator = new PSquareInterpolation(2); RotateToStaticAction shlingRotate = new RotateToStaticAction(Program.TheGame, m_shlingSprite.Transform, ShlingSpin, 1); shlingRotate.Timer.Interval = ShlingTime; m_shling = new Concurrent(new PastaGameLibrary.Action[] { shlingScale, shlingRotate }); Sequence readyAnim = new Sequence(1); readyAnim.AddAction(new DelayAction(Program.TheGame, 0.5f)); readyAnim.AddAction(new MethodAction(delegate() { Cutscenes.GetReady(); SoundEffectLibrary.Get("sword_slash").Play(); })); Concurrent shlingReady = new Concurrent(new PastaGameLibrary.Action[] { m_shling, readyAnim, }); m_ascend = new Sequence(1); m_ascend.AddAction(new DelayAction(Program.TheGame, Crowd.LaunchTensionTime)); m_ascend.AddAction(new MethodAction(delegate() { m_ascendSound.Play(); })); Concurrent ascendAndSword = new Concurrent(new PastaGameLibrary.Action[] { m_ascendMovement, swordAndCloudMovement }); m_ascend.AddAction(ascendAndSword); m_ascend.AddAction(showPlayer); m_ascend.AddAction(shlingReady); m_physics = new PhysicsComponent(Program.TheGame, m_transform); m_physics.Mass = 3.0f; m_jumpFromTotem = new Sequence(1); m_decelerate = new MoveToStaticAction(Program.TheGame, m_transform, Vector2.Zero, 1); m_decelerate.Interpolator = new PSquareInterpolation(0.5f); m_jumpFromTotem.AddAction(m_decelerate); m_jumpFromTotem.AddAction(new DelayAction(Program.TheGame, 0.2f)); m_jumpFromTotem.AddAction(new MethodAction(delegate() { m_physics.OnBounce = null; m_physics.Throw(1.0f, -2.0f, 0); Game1.CurrentMusic.StopDynamicMusic(); SoundEffectLibrary.Get("sword_slash").Play(); })); m_jumpFromTotem.AddAction(new DelayAction(Program.TheGame, 0.75f)); m_jumpFromTotem.AddAction(new MethodAction(delegate() { Game1.SetupNextRound(); if (Game1.CurrentTotem == null) { Cutscenes.GoToCliff(); } else { Cutscenes.GoToTotem(Game1.CurrentTotem, 1.0f, 0); } })); m_actionManager = new SingleActionManager(); m_hitSpikes = new Sequence(1); m_moveToCrashingPlayer = new MoveToTransform(Program.TheGame, Game1.GameCamera.Transform, new Transform(), new Transform(), 1); m_moveToCrashingPlayer.Timer.Interval = 0.2f; m_hitSpikes.AddAction(new DelayAction(Program.TheGame, 1.0f)); m_hitSpikes.AddAction(m_moveToCrashingPlayer); m_hitSpikes.AddAction(new DelayAction(Program.TheGame, 0.5f)); m_hitSpikes.AddAction(new MethodAction(delegate() { if (Game1.CurrentTotem == null) { Cutscenes.GoToCliff(); } else { Cutscenes.GoToTotem(Game1.CurrentTotem, 1.0f, 0); } m_sprite.SetFrame(0); m_physics.OnBounce = null; m_physics.Throw(0, -3, 0); m_transform.PosY = m_physics.GroundLevel; })); m_auraParticles = new ParticleSystem(Program.TheGame, 100); m_soulParticles = new ParticleSystem(Program.TheGame, 500); m_levitate = new Sequence(1); m_moveToCliffTip = new MoveToStaticAction(Program.TheGame, m_transform, new Vector2(Cutscenes.InitialCharacterPosition + 10, -8), 1); m_moveToCliffTip.Interpolator = new PSmoothstepInterpolation(); m_moveToCliffTip.Timer.Interval = 1.0f; m_levitate.AddAction(m_moveToCliffTip); m_levitate.AddAction(new MethodAction(delegate() { m_generateSouls = true; })); m_particleGenerator = new ParticleGenerator <GlitterParticle>(Program.TheGame, m_auraParticles); m_particleGenerator.Automatic = true; m_particleGenerator.GenerationInterval = 0.01f; m_soulParticleGenerator = new ParticleGenerator <SoulParticle>(Program.TheGame, m_soulParticles); m_jumpInMouth = new Sequence(1); m_jumpInMouth.AddAction(new DelayAction(Program.TheGame, 0.5f)); m_jumpInMouth.AddAction(new MethodAction(delegate() { m_generateSouls = false; })); m_jumpInMouth.AddAction(new DelayAction(Program.TheGame, 0.5f)); m_jumpInMouth.AddAction(new MethodAction(delegate() { JumpInMonsterMouth(); })); m_jumpInMouth.AddAction(new DelayAction(Program.TheGame, 0.25f)); m_jumpInMouth.AddAction(new MethodAction(delegate() { Cutscenes.monster.CloseMouth(); })); m_jumpInMouth.AddAction(new DelayAction(Program.TheGame, 2.0f)); m_jumpInMouth.AddAction(new MethodAction(delegate() { Cutscenes.crowd.PushNewGuy(); })); m_jumpInMouth.AddAction(new DelayAction(Program.TheGame, 1.0f)); m_jumpInMouth.AddAction(new MethodAction(delegate() { Cutscenes.StartMainMenu(); })); }
//生成加样移动组合 public void GenerateInjectActGroup(ref Sequence seque, ref int index, ref ActionPoint[] tager, ref int[] point, ref int[] width, ref bool is_ok, ActionBase move_x = null, Spawn move_zt = null) { if (index == 4) { is_ok = true; return; } else if (tager[index].y == point[index] || tager[index].y == -1) { if (tager[index].y == point[index]) { var action_point = tager[index]; var move_act = Sequence.create(); List <Enterclose> ents = new List <Enterclose>(); int[] injz = IMask.Gen(-1); int[] injzl = IMask.Gen(-1); int[] injzd = IMask.Gen(-1); ents.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[index]); move_act.AddAction(SkWaitForAction.create(move_x)); if (action_point.type == TestStepEnum.JXZT) { int[] absorbs = IMask.Gen(-1); var injact_sp = Spawn.create(); injz[index] = action_point.z; absorbs[index] = (int)ents[0].PumpMotor.Maximum.SetValue; injact_sp.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 2)); injact_sp.AddAction(InjectAbsorbMove.create(3001, ents.ToArray(), 100, absorbs)); move_act.AddAction(injact_sp); injz[index] = action_point.zb; move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz)); } else if (action_point.type == TestStepEnum.PutTip) { injz[index] = action_point.z; var sequ = Sequence.create(); sequ.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 2)); sequ.AddAction(MoveTo.create(3001, action_point.puttip_x, -1, -1)); injz[index] = action_point.z - 1000; sequ.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 100)); injz[index] = action_point.zb; sequ.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz)); move_act.AddAction(sequ); } else if (action_point.type == TestStepEnum.AbsLiquid) { int[] absorbs = IMask.Gen(-1); absorbs[index] = -(action_point.capacity); move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 0)); injz[index] = action_point.z + action_point.deep; move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, action_point.deepspeed)); move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), action_point.absbspeed, absorbs)); //回吸 var back_act = Spawn.create(); if (action_point.backcapacity != 0) { absorbs[index] = -(action_point.backcapacity); back_act.AddAction(Sequence.create(SKSleep.create(500), InjectAbsorb.create(3001, ents.ToArray(), action_point.backspeed, absorbs))); } injz[index] = action_point.zb; back_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz)); move_act.AddAction(back_act); } else if (action_point.type == TestStepEnum.FollowAbsLiquid) { int[] absorbs = IMask.Gen(-1); injz[index] = action_point.z; injzl[index] = action_point.z + action_point.detectordeep; injzd[index] = action_point.deep; absorbs[index] = -(action_point.capacity); move_act.AddAction(InjectDetector.create(3001, ents.ToArray(), injz, injzl, injzd, 2, 1)); move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), action_point.absbspeed, absorbs)); //回吸 var back_act = Spawn.create(); if (action_point.backcapacity != 0) { absorbs[index] = -(action_point.backcapacity); back_act.AddAction(Sequence.create(SKSleep.create(500), InjectAbsorb.create(3001, ents.ToArray(), action_point.backspeed, absorbs))); } injz[index] = action_point.zb; back_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz)); move_act.AddAction(back_act); } else if (action_point.type == TestStepEnum.SpuLiquid) { int[] absorbs = IMask.Gen(-1); injz[index] = action_point.z; absorbs[index] = action_point.spucapacity + action_point.backcapacity; move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 2)); move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), action_point.spuspeed, absorbs)); //回吸 var back_act = Spawn.create(); if (action_point.backcapacity != 0) { absorbs[index] = -(action_point.backcapacity); back_act.AddAction(Sequence.create(SKSleep.create(100), InjectAbsorb.create(3001, ents.ToArray(), action_point.backcapacity, absorbs))); } injz[index] = action_point.zb; back_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz)); move_act.AddAction(back_act); } else if (action_point.type == TestStepEnum.MixLiquid) { int[] absorbs = IMask.Gen(-1); injz[index] = action_point.z; move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 2)); absorbs[index] = action_point.capacity; move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), 100, absorbs));//把稀释液放进去 //混合操作 if (action_point.mixtimes != 0) { for (int i = 0; i < action_point.mixtimes * 2; i++) { int mixz = action_point.z - action_point.mixdeep;//混合高度 if (mixz <= 0) { mixz = action_point.z; } absorbs[index] = i % 2 == 0 ? -action_point.capacity : action_point.capacity; injz[index] = i % 2 == 0 ? action_point.z: mixz; move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 2)); move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), 100, absorbs)); } injz[index] = action_point.z; move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 2)); absorbs[index] = (int)ents[0].PumpMotor.Maximum.SetValue; move_act.AddAction(InjectAbsorbMove.create(3001, ents.ToArray(), 100, absorbs)); absorbs[index] = -(action_point.GetTubeList().Count *action_point.spucapacity); move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), 100, absorbs)); } //回吸 if (action_point.backcapacity != 0) { injz[index] = action_point.z; move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz)); absorbs[index] = -(action_point.backcapacity); move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), action_point.backspeed, absorbs)); } injz[index] = action_point.zb; move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz)); } //查找前面的 if (move_zt != null) { move_zt.AddAction(move_act); } else { seque.AddAction(move_act); } } index++; GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok, move_x, move_zt); } else { List <int[]> node_list = new List <int[]>(); for (int i = 0; i < 4; i++) { for (int j = i; j < 4; j++) { for (int k = j; k < 4; k++) { for (int l = k; l < 4; l++) { int[] point_tem = { 0, 0, 0, 0 }; point_tem[i] = tager[i].y; point_tem[j] = tager[j].y; point_tem[k] = tager[k].y; point_tem[l] = tager[l].y; for (int n = 0; n < 4; n++) { if (point_tem[n] < 0) { point_tem[n] = 0; } } bool ispass = true; int frist = 0; for (int n = 0; n < 4; n++) { if (point_tem[n] != 0) { frist = n; break; } } for (int n = frist; n < 4; n++) { if (point_tem[n] == 0 && n - 1 >= 0) { point_tem[n] = point_tem[n - 1] + width[n]; } } for (int n = 0; n < frist; n++) { if (point_tem[n] == 0 && n + 1 <= 3) { point_tem[n] = point_tem[frist] - width[n] * (frist - n); } } for (int n = 0; n < 4; n++) { bool isforward = n - 1 >= 0 ? point_tem[n] >= point_tem[n - 1] + width[n - 1] : true; bool isback = n + 1 <= 3 ? point_tem[n] + width[n] <= point_tem[n + 1] : true; ispass = isforward && isforward; if (!ispass) { break; } } if (ispass && point_tem[index] == tager[index].y) { node_list.Add(point_tem); } } } } } int[] minnode = node_list[0]; foreach (var node in node_list) { if (GetLoss(tager, node) < GetLoss(tager, minnode)) { minnode = node; } } List <int> left = new List <int>(); List <int> right = new List <int>(); for (int i = 0; i < 4; i++) { if (point[i] - minnode[i] < 0) { left.Add(i); } else { right.Add(i); } } left.Sort((a, b) => { return(a < b ? 1 : -1); }); right.Sort((a, b) => { return(a > b ? 1 : -1); }); var movesp_act = Spawn.create(); var move_act = Sequence.create(); string msg = ""; int[] yy = { -1, -1, -1, -1 }; int[] zz = { -1, -1, -1, -1 }; List <Enterclose> ents = new List <Enterclose>(); for (int i = 0; i < left.Count; i++) { int indextem = left[i]; if (point[indextem] != minnode[indextem]) { ents.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[indextem]); yy[indextem] = minnode[indextem]; } } movesp_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, yy, zz)); ents.Clear(); for (int i = 0; i < right.Count; i++) { int indextem = right[i]; if (point[indextem] != minnode[indextem]) { ents.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[indextem]); yy[indextem] = minnode[indextem]; } } movesp_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, yy, zz)); for (int i = 0; i < 4; i++) { point[i] = minnode[i]; } move_act.AddAction(movesp_act); //同步Z动作 var spawz_action = Spawn.create(); move_act.AddAction(spawz_action); seque.AddAction(move_act); GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok, move_x, spawz_action); } }
public Crowd(int amountOfPopulation, float radius, Vector2 sizeRatio) { m_radius = radius; m_sizeRatio = sizeRatio; m_playerCharacterTransform = new Transform(m_transform, true); m_playerCharacterTransform.Direction = 1.56f; m_playerCharacterTransform.PosY = -25; int maxIndex; float currentRadius, currentAngle; //Générer le devant maxIndex = (int)(amountOfPopulation * FrontToBackRatio); for (int i = 0; i < amountOfPopulation; ++i) { currentRadius = (float)(Program.Random.NextDouble() * m_radius); currentAngle = (float)(Program.Random.NextDouble() * 6.28); Vector2 position = new Vector2((float)Math.Cos(currentAngle) * currentRadius * m_sizeRatio.X, (float)Math.Sin(currentAngle) * currentRadius * m_sizeRatio.Y); Individual individu = new Individual(this, position); m_people.Add(individu); if (individu.Transform.PosY > 0) { m_frontPeople.Add(individu); } else { m_backPeople.Add(individu); } } m_frontPeople = m_frontPeople.OrderBy(o => o.Transform.PosY).ToList(); /// /// MoveTo animation /// m_moveToMovement = new MoveToStaticAction(Program.TheGame, m_transform, Vector2.Zero, 1); MethodAction stopWalk = new MethodAction(delegate() { for (int i = 0; i < m_people.Count; ++i) { m_people[i].StopWalk(); } }); m_moveTo = new Sequence(1); m_moveTo.AddAction(m_moveToMovement); m_moveTo.AddAction(stopWalk); /// /// Pickup player animation /// m_pickupPlayer = new Sequence(1); m_pickupPlayer.AddAction(m_moveToMovement); //m_pickupPlayer.AddAction(new DelayAction(Program.TheGame, 0.1f)); m_pickupPlayer.AddAction(new MethodAction(delegate() { Cutscenes.cutscenePlayer.JumpOnCrowd(); })); m_animationManager = new SingleActionManager(); /// /// Pickup player animation /// m_pushNewGuy = new MoveToStaticAction(Program.TheGame, m_transform, Vector2.Zero, 1); m_pushNewGuy.Interpolator = new PBounceInterpolation(0.5f); m_pushNewGuy.Timer.Interval = 0.2f; }
//生成加样移动 public void GenerateSampleAddAct(ref Sequence seque, ref int index, ref int[] tager, ref int[] point, ref int[] width, ref bool is_ok) { bool isforward = false; bool isback = false; if (index == 4) { is_ok = true; return; } else { isforward = index - 1 >= 0 ? tager[index] >= point[index - 1] + width[index - 1] : true; isback = index + 1 <= 3 ? tager[index] + width[index] <= point[index + 1] : true; } if (tager[index] < 0) { index++; GenerateSampleAddAct(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } else if (isforward && isback) { //单移 point[index] = tager[index]; int[] y = { -1, -1, -1, -1 }; int[] z = { -1, -1, -1, -1 }; y[index] = point[index] - width[index] * index; z[index] = -1; var move_act = Sequence.create(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, y, z), SKSleep.create(index * 500), MoveTo.create(handDevice, 300000, -1, -1, 100), MoveTo.create(handDevice, 300000, -1, -1, 0)); //查找上一个sp if (seque.actionlist[seque.actionlist.Count() - 1] is Spawn) { var spawn = (Spawn)seque.actionlist[seque.actionlist.Count() - 1]; spawn.AddAction(move_act); } else { var spawn = Spawn.create(); spawn.AddAction(move_act); seque.AddAction(spawn); } index++; GenerateSampleAddAct(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } else if (isforward && isback == false) { //全移 int movew = tager[index] - point[index]; for (int i = index; i < 4; i++) { point[i] = point[i] + movew; } int indexx = index; int y = point[index] - width[index] * index; var move_act = Sequence.create(SkCallBackFun.create((ActionBase act) => { for (int i = 0; i < 4; i++) { injectorDevice.Injector.Entercloses[i].Selected = i >= indexx; } return(true); }), MoveTo.create(injectorDevice, 300000, -1, y, -1)); seque.AddAction(move_act); GenerateSampleAddAct(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } else if (isforward == false && isback) { //等待前面完成 int movew = tager[index] - point[index]; for (int i = 0; i < 4; i++) { point[i] = point[i] + movew; if (point[i] < 0) { is_ok = false; return; } } int y = point[0]; var move_act = Sequence.create(SkCallBackFun.create((ActionBase act) => { for (int i = 0; i < 4; i++) { injectorDevice.Injector.Entercloses[i].Selected = true; } return(true); }), MoveTo.create(injectorDevice, 300000, -1, y, -1)); seque.AddAction(move_act); GenerateSampleAddAct(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } }