public void ConsumeShootAction(SyncMobile syncMobile) { ShotType tmp = syncMobile.SelectedShotType; if (tmp == ShotType.SS) { GameScene.Camera.ApplyCameraEffect(CameraSpecialEffect.FadeOut); } ShootWithModifiers(syncMobile); LastCreatedProjectileList.ForEach((x) => x.OnFinalizeExecutionAction += () => { if (tmp == ShotType.SS) { GameScene.Camera.ApplyCameraEffect(CameraSpecialEffect.FadeIn); } FinalizeTurn(syncMobile.SelectedShotType); LevelScene.HUD.StatusBarDictionary[this].UpdateAttributeList(); OnEndTurn?.Invoke(); OnEndTurn = default; //Refresh Status (if necessary) LevelScene.HUD.StatusBarDictionary[this].UpdateAttributeList(); }); GameScene.Camera.TrackObject(LastCreatedProjectileList.First()); if (IsPlayable) { LevelScene.HUD.DisableSS(); } }
public void RequestItemAsyncCallback(object answer) { try { SyncMobile syncMobile = (SyncMobile)answer; Mobile mob = null; lock (MobileList) { mob = MobileList.Find((x) => syncMobile.Owner.ID == x.Owner.ID); mob.SyncMobile.Delay = syncMobile.Delay; if (syncMobile.Owner.ID == GameInformation.Instance.PlayerInformation.ID) { HUD.Delayboard.ComputeDelay(); } mob.UseItem(syncMobile.UsedItem); } } catch (Exception ex) { Console.WriteLine("Ex: " + ex.Message); Console.WriteLine("Ex: " + ex.StackTrace); } }
public Mobile(Player player, Vector2 position, MobileType mobileType, bool IsSummon = false) : base() { ProjectileList = new List <Projectile>(); UnusedProjectile = new List <Projectile>(); LastCreatedProjectileList = new List <Projectile>(); UninitializedProjectileList = new List <Projectile>(); ItemsUnderEffectList = new List <ItemType>(); MobileType = mobileType; Owner = player; movingSE = AssetHandler.Instance.RequestSoundEffect(SoundEffectParameter.MobileMovement(mobileType)); unableToMoveSE = AssetHandler.Instance.RequestSoundEffect(SoundEffectParameter.MobileUnableToMove(mobileType)); this.IsSummon = IsSummon; IsPlayable = GameInformation.Instance.IsOwnedByPlayer(this) && !IsSummon; if (IsPlayable) { Movement = new LocalMovement(this); } else if (!IsSummon) { Movement = new RemoteMovement(this); } MobileMetadata = MobileMetadata.BuildMobileMetadata(player, mobileType); Position = position; MobileFlipbook = MobileFlipbook.CreateMobileFlipbook(MobileType, position); if (!IsSummon) { Rider = new Rider(this); if (MobileType != MobileType.Random) { Crosshair = new Crosshair(this); } } //Sync SyncMobile = new SyncMobile(); SyncMobile.Owner = player; SyncMobile.Position = Position.ToArray <int>(); SyncMobile.MobileMetadata = MobileMetadata.BuildMobileMetadata(player, player.PrimaryMobile); SyncPosition = Position; IsAlive = true; IsActionsLocked = false; hasShotSequenceStarted = false; #if DEBUG DebugHandler.Instance.Add(debugCrosshair); DebugHandler.Instance.Add(debugCrosshair2); #endif }
private void RequestNextPlayerTurnAsyncCallback(object answer) { try { lock (MobileList) { MatchManager manager = (MatchManager)answer; //A team have won if (answer == null) { return; } MatchMetadata = manager.MatchMetadata; //Weather Variations HUD.WeatherDisplay.AppendWeatherToList(MatchMetadata.IncomingWeatherList); //Change Wind (If Necessary) HUD.WindCompass.ChangeWind(MatchMetadata.WindAngleDegrees, MatchMetadata.WindForce); CurrentTurnOwner = manager.TurnOwner; } Thread.Sleep(Parameter.GameplayConstantDelayTimerWindChange); lock (MobileList) { //Grant Turn foreach (Mobile m in MobileList) { m.Regenerate(); if (m.Owner.ID == CurrentTurnOwner.Owner.ID) { m.GrantTurn(); } } } } catch (Exception ex) { Console.WriteLine("Dsync at RequestNextPlayerTurnAsyncCallback: " + ex.Message); } }
public void HandleSyncMobile(SyncMobile syncMobile) { if (IsPlayable) { return; } SyncMobile.Update(syncMobile); //Position if (LevelScene.MatchMetadata != null && LevelScene.CurrentTurnOwner.Owner.ID == Owner.ID && Movement.IsAbleToMove) { ((RemoteMovement)Movement).EnqueuePosition(Topography.GetTransformedPosition(new Vector2(syncMobile.Position[0], syncMobile.Position[1])).ToVector2()); } //ShotType ChangeShot(SyncMobile.SelectedShotType); }
public void RefreshSyncMobileAsyncCallback(object answer) { try { SyncMobile syncMobile = (SyncMobile)answer; lock (MobileList) { Mobile mob = MobileList.Find((x) => x.Owner.ID == syncMobile.Owner.ID); mob.HandleSyncMobile(syncMobile); } } catch (Exception ex) { Console.WriteLine("Ex: " + ex.Message); Console.WriteLine("Ex: " + ex.StackTrace); } }
public void RequestShotAsyncCallback(object answer) { try { SyncMobile syncMobile = (SyncMobile)answer; Mobile mob = null; lock (MobileList) { mob = MobileList.Find((x) => syncMobile.Owner.ID == x.Owner.ID); mob.HandleSyncMobile(syncMobile); } if (!mob.IsPlayable) { while (!((RemoteMovement)mob.Movement).IsReadyToShoot) { Thread.Sleep(100); } } lock (MobileList) { mob.SyncMobile = syncMobile; mob.HandleSyncMobile(syncMobile); mob.ConsumeShootAction(syncMobile); if (syncMobile.Owner.ID == GameInformation.Instance.PlayerInformation.ID) { HUD.Delayboard.ComputeDelay(); } mob.LoseTurn(); } //Helper.EuclideanDistance(mob.Position, mob.Movement.DesiredPosition) } catch (Exception ex) { Console.WriteLine("Ex: " + ex.Message); Console.WriteLine("Ex: " + ex.StackTrace); } }
private void ShootWithModifiers(SyncMobile syncMobile) { if (ItemsUnderEffectList.Count == 0) { Shoot(syncMobile.SelectedShotType); return; } foreach (ItemType it in ItemsUnderEffectList) { switch (it) { case ItemType.Dual: Shoot(syncMobile.SelectedShotType); Shoot(syncMobile.SelectedShotType, 1 + LastCreatedProjectileList.Max((x) => x.SpawnTime)); break; case ItemType.DualPlus: Shoot(syncMobile.SelectedShotType); if (syncMobile.SelectedShotType == ShotType.S1) { Shoot(ShotType.S2, 1 + LastCreatedProjectileList.Max((x) => x.SpawnTime)); } else { Shoot(ShotType.S1, 1 + LastCreatedProjectileList.Max((x) => x.SpawnTime)); } break; case ItemType.Thunder: Shoot(syncMobile.SelectedShotType); Weather weather = LevelScene.WeatherHandler.AddAbsoluteWeather(WeatherType.Electricity, default, Position, scale: 1000, shouldRender: false); LastCreatedProjectileList.ForEach((x) => x.OnFinalizeExecutionAction += () => { LevelScene.WeatherHandler.RemoveWeather(weather); }); break; case ItemType.Teleport: Shoot(ShotType.TeleportationBeacon); break; } } }
public void ComputePlayerTurnSkip(SyncMobile filter) { SyncMobile sMob = SyncMobileList.Find((x) => x.Owner.ID == filter.Owner.ID); //Clearing the action list to wipe the "Charging" action from the shooting player sMob.SynchronizableActionList.Clear(); filter.Delay = sMob.Delay += NetworkObjectParameters.TurnSkipDelayCost; //Mobile / Delay SyncMobileList = SyncMobileList.OrderBy((x) => x.Delay).ToList(); //Turn pass MatchMetadata.PassTurn(roomMetadata.OriginalTeamSize); //SS Lock (if necessary) if (filter.SelectedShotType == ShotType.SS /* && filter.SSLockRemainingTurns == 0 */) { filter.SSLockRemainingTurns += NetworkObjectParameters.SSCooldownTimer + 1; } }
public void RequestDeathAsyncCallback(object answer) { try { SyncMobile syncMobile = (SyncMobile)answer; lock (MobileList) { Mobile mob = MobileList.Find((x) => x.Owner.ID == syncMobile.Owner.ID); mob.Die(); if (mob.Owner.ID == CurrentTurnOwner.Owner.ID) { RequestNextTurn = true; } } } catch (Exception ex) { Console.WriteLine($"Ex: {ex.Message}"); } }
private void RequestDisconnectAsyncCallback(object answer) { try { SyncMobile sm = (SyncMobile)answer; lock (MobileList) { Mobile mob = MobileList.Find((x) => x.Owner.ID == sm.Owner.ID); mob.Die(); if (mob.Owner.ID != CurrentTurnOwner.Owner.ID || !mob.IsAbleToShoot) { return; } RequestNextTurn = true; } } catch (Exception ex) { Console.WriteLine("Dsync At Disconnect Request: " + ex.Message); } }
public static void RequestLoseTurn(SyncMobile syncMobile) { ServerInformationBroker.Instance.GameServerServiceProvider.RequestQueue.Enqueue( NetworkObjectParameters.GameServerInGameRequestLoseTurn, syncMobile); }
public static void SynchronizeItemUsage(SyncMobile syncMobile) { ServerInformationBroker.Instance.GameServerServiceProvider.RequestQueue.Enqueue( NetworkObjectParameters.GameServerInGameRequestItemUsage, syncMobile); }
public void ComputePlayerItem(SyncMobile filter) { SyncMobile sMob = SyncMobileList.Find((x) => x.Owner.ID == filter.Owner.ID); filter.Delay = sMob.Delay += (int)((1 - filter.Owner.ItemDelay / 100f) * Item.ItemPresets.Find((x) => x.ItemType == filter.UsedItem).ItemCost); }