public ActionChain DoSwingMotion(WorldObject target, out float animLength) { // FIXME: proper swing animation speeds var baseSpeed = GetAnimSpeed(); var animSpeedMod = IsDualWieldAttack ? 1.2f : 1.0f; // dual wield swing animation 20% faster var animSpeed = baseSpeed * animSpeedMod; var swingAnimation = new MotionItem(GetSwingAnimation(), animSpeed); animLength = MotionTable.GetAnimationLength(MotionTableId, CurrentMotionState.Stance, swingAnimation.Motion, animSpeed); var motion = new UniversalMotion(CurrentMotionState.Stance, swingAnimation); motion.MovementData.CurrentStyle = (uint)CurrentMotionState.Stance; motion.MovementData.TurnSpeed = 2.25f; motion.HasTarget = true; motion.TargetGuid = target.Guid; CurrentMotionState = motion; var actionChain = new ActionChain(); actionChain.AddAction(this, () => EnqueueBroadcastMotion(motion)); actionChain.AddDelaySeconds(animLength); actionChain.AddAction(this, () => Session.Network.EnqueueSend(new GameEventAttackDone(Session))); actionChain.AddAction(this, () => Session.Network.EnqueueSend(new GameEventCombatCommmenceAttack(Session))); actionChain.AddAction(this, () => Session.Network.EnqueueSend(new GameEventAttackDone(Session))); return(actionChain); }
public MotionItemView(MotionEditorContext editorContext, MotionItem data) : base(editorContext, MotionItemType.Motion) { ContentPanel.Children.Remove(FolderContent); CreatePreviewGraph(); Data = data; }
private void fillUserMotions() { OleDbConnection con; OleDbCommand cmd; OleDbDataReader dr; con = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source=login.accdb"); cmd = new OleDbCommand(); con.Open(); cmd.Connection = con; string sql = "SELECT c.cat_name, m.motion_name, m.description, m.id, m.path, m.frame_no, m.repetition FROM category c, user_motion um, motion m, users u where m.category_id = c.id and u.id = um.user_id and m.id = um.motion_id and u.username = '******'"; cmd.CommandText = sql; dr = cmd.ExecuteReader(); Console.WriteLine(sql); while (dr.Read()) { Console.WriteLine(dr); MotionItem mi = new MotionItem(); mi.Id = Int32.Parse(dr["id"].ToString()); mi.MotionName = dr["motion_name"].ToString(); mi.Category = dr["cat_name"].ToString(); mi.Description = dr["description"].ToString(); mi.Path = dr["path"].ToString(); mi.FrameNo = Int32.Parse(dr["frame_no"].ToString()); mi.Repetition = Int32.Parse(dr["repetition"].ToString()); motionList.Items.Add(mi); } con.Close(); }
/// <summary> /// Executes the weapon reload animation for the player /// </summary> public float ReloadMotion() { var reloadAnimation = new MotionItem(GetReloadAnimation(), 1.0f); var animLength = MotionTable.GetAnimationLength(MotionTableId, CurrentMotionState.Stance, reloadAnimation); var motion = new UniversalMotion(CurrentMotionState.Stance); motion.MovementData.CurrentStyle = (uint)CurrentMotionState.Stance; motion.MovementData.ForwardCommand = (uint)MotionCommand.Reload; motion.MovementData.TurnSpeed = 2.25f; //motion.HasTarget = true; //motion.TargetGuid = target.Guid; CurrentMotionState = motion; var actionChain = new ActionChain(); actionChain.AddAction(this, () => DoMotion(motion)); actionChain.AddDelaySeconds(animLength); actionChain.AddAction(this, () => { motion.MovementData.ForwardCommand = (uint)MotionCommand.Invalid; DoMotion(motion); CurrentMotionState = motion; }); actionChain.AddDelaySeconds(animLength); actionChain.AddAction(this, () => Session.Network.EnqueueSend(new GameEventAttackDone(Session))); actionChain.AddAction(this, () => Session.Network.EnqueueSend(new GameEventCombatCommmenceAttack(Session))); actionChain.AddAction(this, () => Session.Network.EnqueueSend(new GameEventAttackDone(Session))); actionChain.EnqueueChain(); var weapon = GetEquippedWeapon(); var reloadTime = weapon.DefaultCombatStyle == CombatStyle.Crossbow ? 3.2f : 1.6f; return(animLength * reloadTime); }
public MotionItem CreateMotionDefault(MotionFolderItem parentFolder = null, string name = null) { MotionItem motion = CreateMotionEmpty(parentFolder, name); MotionItem.CreateDefault(motion); return(motion); }
private void Button_Click_2(object sender, RoutedEventArgs e) { MotionItem mi = (MotionItem)motionList.SelectedItem; Team7Senior.PoseMatchingPage pm = new Team7Senior.PoseMatchingPage(mi, userInfo); pm.Show(); this.Close(); }
public PVector2 GetMotionValue(string motionId, PVector2 linearValue, int maxSample = MotionItem.DefaultMaxSample, float tolerance = MotionItem.DefaultMaxTolerance) { MotionItem motion = GetMotion(motionId); return(new PVector2( motion.GetMotionValue(linearValue.x, maxSample, tolerance), motion.GetMotionValue(linearValue.y, maxSample, tolerance) )); }
public void DuplicateSelectedMotion() { if (!IsSelectedItemCopyable) { return; } MotionItemBase latestNewItem = null; MotionFolderItem parentFolder = SelectedItemParent; foreach (MotionItemBaseView refItem in MotionTreeView.SelectedItemSet) { if (refItem.Type == MotionItemType.Motion) { MotionItem refMotionItem = (MotionItem)refItem.Data; //Create motion MotionItem newItem = EditingFile.CreateMotionEmpty(parentFolder); latestNewItem = newItem; //Copy points foreach (MotionPoint refPoint in refMotionItem.pointList) { MotionPoint point = new MotionPoint(); newItem.AddPoint(point); point.SetMainPoint(refPoint.MainPoint); for (int i = 0; i < refPoint.SubPoints.Length; ++i) { point.SetSubPoint(i, refPoint.SubPoints[i]); } } ((MotionItemView)DataToViewDict[newItem]).UpdatePreviewGraph(); //Set name const string CopyPostfix = "_Copy"; string name = refItem.Data.Name; for (; ;) { if (EditingFile.itemDict.ContainsKey(name)) { name += CopyPostfix; } else { break; } } newItem.SetName(name); } } if (latestNewItem != null) { MotionTreeView.SelectedItemSet.SetSelectedItem(DataToViewDict[latestNewItem]); } }
/// <summary> /// Executes the weapon reload animation for the player /// </summary> public float ReloadMotion() { var reloadAnimation = new MotionItem(GetReloadAnimation(), 1.0f); var animLength = MotionTable.GetAnimationLength(MotionTableId, CurrentMotionState.Stance, reloadAnimation); var motion = new UniversalMotion(CurrentMotionState.Stance); motion.MovementData.CurrentStyle = (uint)CurrentMotionState.Stance; motion.MovementData.ForwardCommand = (uint)MotionCommand.Reload; motion.MovementData.TurnSpeed = 2.25f; //motion.HasTarget = true; //motion.TargetGuid = target.Guid; CurrentMotionState = motion; var actionChain = new ActionChain(); actionChain.AddAction(this, () => DoMotion(motion)); actionChain.AddDelaySeconds(animLength); actionChain.AddAction(this, () => { motion.MovementData.ForwardCommand = (uint)MotionCommand.Invalid; DoMotion(motion); CurrentMotionState = motion; }); var ammo = GetEquippedAmmo(); if (ammo != null) { actionChain.AddAction(this, () => EnqueueBroadcast( new GameMessageParentEvent(this, ammo, (int)ACE.Entity.Enum.ParentLocation.RightHand, (int)ACE.Entity.Enum.Placement.RightHandCombat))); } actionChain.AddDelaySeconds(animLength); var player = this as Player; if (player != null) { actionChain.AddAction(this, () => player.Session.Network.EnqueueSend(new GameEventAttackDone(player.Session))); actionChain.AddAction(this, () => player.Session.Network.EnqueueSend(new GameEventCombatCommmenceAttack(player.Session))); // TODO: This gets rid of the hourglass but doesn't seem to be sent in retail pcaps... actionChain.AddAction(this, () => player.Session.Network.EnqueueSend(new GameEventAttackDone(player.Session))); } actionChain.EnqueueChain(); var weapon = GetEquippedWeapon(); var reloadTime = weapon.DefaultCombatStyle == CombatStyle.Crossbow ? 3.2f : 1.6f; return(animLength * reloadTime); }
public static void Handle(ClientMessage message, Session session) { uint currentHoldkey = 0; ushort instanceTimestamp; ushort serverControlTimestamp; ushort teleportTimestamp; ushort forcePositionTimestamp; /*bool contact; * bool longJump;*/ MotionStateFlag flags = (MotionStateFlag)message.Payload.ReadUInt32(); if ((flags & MotionStateFlag.CurrentHoldKey) != 0) { currentHoldkey = message.Payload.ReadUInt32(); } MovementData md = DeserializeMovement(message.Payload, flags); uint numAnimations = (uint)flags >> 11; MotionItem[] commands = new MotionItem[numAnimations]; for (int i = 0; i < numAnimations; i++) { ushort motionCommand = message.Payload.ReadUInt16(); ushort sequence = message.Payload.ReadUInt16(); float speed = message.Payload.ReadSingle(); commands[i] = new MotionItem((MotionCommand)motionCommand, speed); } var position = new Position(message.Payload); position.LandblockId = new LandblockId(position.Cell); instanceTimestamp = message.Payload.ReadUInt16(); serverControlTimestamp = message.Payload.ReadUInt16(); teleportTimestamp = message.Payload.ReadUInt16(); forcePositionTimestamp = message.Payload.ReadUInt16(); message.Payload.ReadByte(); // FIXME(ddevec): If speed values in the motion need to be updated by the player, this will likely need to be adjusted // Send the motion to the player session.Player.RequestUpdateMotion(currentHoldkey, md, commands); session.Player.RequestUpdatePosition(position); }
/// <summary> /// 判断参数的合法性 /// </summary> /// <param name="item"></param> public void DoAssign(MotionItem item) { this.AxisCard = item.AxisCard; this.AxisCode = item.AxisCode; this.AxisMask = item.AxisMask;// 用于轴编码的二进制占位 //this.AxisScale = item.AxisScale; this.SlowSpeed = item.GetSpeedPul(define_motion.ws_speed_slow); this.HomeSpeed = item.GetSpeedPul(define_motion.ws_speed_home); this.FastSpeed = item.GetSpeedPul(define_motion.ws_speed_fast); this.WorkSpeed = item.GetSpeedPul(define_motion.ws_speed_work); this.isLimit = item.isLimit; this.isServo = item.isServo; this.LimitNeg = item.GetLimitNeg(); this.LimitPos = item.GetLimitPos(); this.OrginMov = item.GetOrginMov(); this.OrginOff = item.GetOrginOff(); this.AccTime = item.AccTime * 0.001; }
/// <summary> /// Perform the melee attack swing animation /// </summary> public virtual ActionChain DoSwingMotion(WorldObject target, out float animLength) { var swingAnimation = new MotionItem(GetSwingAnimation(), 1.25f); animLength = MotionTable.GetAnimationLength(MotionTableId, CurrentMotionState.Stance, swingAnimation); var motion = new UniversalMotion(CurrentMotionState.Stance, swingAnimation); motion.MovementData.CurrentStyle = (uint)CurrentMotionState.Stance; motion.MovementData.TurnSpeed = 2.25f; motion.HasTarget = true; motion.TargetGuid = target.Guid; CurrentMotionState = motion; CurrentLandblock.EnqueueBroadcastMotion(this, motion); return(null); }
/// <summary> /// Perform the melee attack swing animation /// </summary> public void DoSwingMotion(WorldObject target, CombatManeuver maneuver, out float animLength) { var animSpeed = GetAnimSpeed(); var swingAnimation = new MotionItem(maneuver.Motion, animSpeed); animLength = MotionTable.GetAnimationLength(MotionTableId, CurrentMotionState.Stance, maneuver.Motion, animSpeed); var motion = new UniversalMotion(CurrentMotionState.Stance, swingAnimation); motion.MovementData.CurrentStyle = (uint)CurrentMotionState.Stance; motion.MovementData.TurnSpeed = 2.25f; motion.HasTarget = true; motion.TargetGuid = target.Guid; CurrentMotionState = motion; EnqueueBroadcastMotion(motion); }
public MotionItem CreateMotionEmpty(MotionFolderItem parentFolder = null, string name = null) { if (parentFolder == null) { parentFolder = rootFolder; } if (string.IsNullOrEmpty(name)) { name = GetNewName(MotionItemType.Motion); } MotionItem motion = new MotionItem(this); ItemCreated?.Invoke(motion, parentFolder); parentFolder.AddChild(motion); motion.SetName(name); return(motion); }
//MotionItem public void AttachMotion(MotionItem motionItem) { DetachMotion(); EditingMotionData = motionItem; //Register events motionItem.PointInserted += MotionItem_PointInserted; motionItem.PointRemoved += MotionItem_PointRemoved; //Load data for (int i = 0; i < motionItem.pointList.Count; ++i) { MotionItem_PointInserted(i, motionItem.pointList[i]); } UpdateUiAll(); //Update preview PreviewContext.Visibility = Visibility.Visible; PreviewTab.SetPositionContinuumVisible(true); PreviewTab.UpdatePositionContinuum(); }
public override ActionChain DoSwingMotion(WorldObject target, out float animLength) { var swingAnimation = new MotionItem(GetSwingAnimation(), 1.25f); animLength = MotionTable.GetAnimationLength(MotionTableId, CurrentMotionState.Stance, swingAnimation); var motion = new UniversalMotion(CurrentMotionState.Stance, swingAnimation); motion.MovementData.CurrentStyle = (uint)CurrentMotionState.Stance; motion.MovementData.TurnSpeed = 2.25f; motion.HasTarget = true; motion.TargetGuid = target.Guid; CurrentMotionState = motion; var actionChain = new ActionChain(); actionChain.AddAction(this, () => DoMotion(motion)); actionChain.AddDelaySeconds(animLength); actionChain.AddAction(this, () => Session.Network.EnqueueSend(new GameEventAttackDone(Session))); actionChain.AddAction(this, () => Session.Network.EnqueueSend(new GameEventCombatCommmenceAttack(Session))); actionChain.AddAction(this, () => Session.Network.EnqueueSend(new GameEventAttackDone(Session))); return(actionChain); }
/// <summary> /// Perform the melee attack swing animation /// </summary> public ActionChain DoSwingMotion(WorldObject target, CombatManeuver maneuver, out float animLength) { var animSpeed = GetAnimSpeed(); var swingAnimation = new MotionItem(maneuver.Motion, animSpeed); animLength = MotionTable.GetAnimationLength(MotionTableId, CurrentMotionState.Stance, maneuver.Motion, null, animSpeed); var motion = new UniversalMotion(CurrentMotionState.Stance, swingAnimation); motion.MovementData.CurrentStyle = (uint)CurrentMotionState.Stance; motion.MovementData.TurnSpeed = 2.25f; motion.HasTarget = true; motion.TargetGuid = target.Guid; CurrentMotionState = motion; EnqueueBroadcastMotion(motion); // play default script? (special attack) //if (MotionTable.HasDefaultScript(MotionTableId, maneuver.Motion, maneuver.Style)) //EnqueueBroadcast(new GameMessageScript(Guid, (PlayScript)DefaultScriptId)); return(null); }
private void CreateItemButton_OnClick() { MotionItem item = EditingFile.CreateMotionDefault(SelectedItemParent); MotionTreeView.SelectedItemSet.SetSelectedItem((MotionItemView)DataToViewDict[item]); }
public void LoadFromJson(JObject jRoot) { //MotionTree JObject jRootFolder = jRoot[RootFolderName] as JObject; LoadItemRecursive(jRootFolder, null); void LoadItemRecursive(JToken jItem, MotionFolderItem parent) { JToken jType = jItem["Type"]; string typeText = jType != null?jType.ToString() : null; string name = (jItem.Parent as JProperty).Name; if (typeText == "Motion") { LoadMotion(parent, jItem, name); } else { LoadFolder(parent, jItem, name); } } void LoadMotion(MotionFolderItem parent, JToken jItem, string name) { JObject jData = jItem["Data"] as JObject; JArray jPoints = jData["Point"] as JArray; MotionItem motion = CreateMotionEmpty(parent); motion.SetName(name); foreach (JToken jPointToken in jPoints) { JArray jPoint = jPointToken as JArray; MotionPoint point = new MotionPoint( PVector2.Parse(jPoint[0].ToObject <string>()), PVector2.Parse(jPoint[1].ToObject <string>()), PVector2.Parse(jPoint[2].ToObject <string>())); motion.AddPoint(point); } } void LoadFolder(MotionFolderItem parent, JToken jItem, string name) { MotionFolderItem folder = CreateFolder(parent); if (parent == null) { rootFolder = folder; } else { folder.SetName(name); } JObject jItems = jItem["Items"] as JObject; foreach (JToken jChild in jItems.Children()) { JProperty jChildProp = jChild as JProperty; LoadItemRecursive(jChildProp.Value, folder); } } }
public float GetMotionValue(string motionId, float linearValue, int maxSample = MotionItem.DefaultMaxSample, float tolerance = MotionItem.DefaultMaxTolerance) { MotionItem motion = GetMotion(motionId); return(motion.GetMotionValue(linearValue, maxSample, tolerance)); }
public static float GetAnimationLength(uint motionTableId, MotionStance stance, MotionItem motionItem) { var motionTable = DatManager.PortalDat.ReadFromDat <DatLoader.FileTypes.MotionTable>(motionTableId); return(motionTable.GetAnimationLength(stance, motionItem.Motion) / motionItem.Speed); }