本文整理汇总了C#中DOL.GS.Keeps.GameKeepComponent.AddToWorld方法的典型用法代码示例。如果您正苦于以下问题:C# GameKeepComponent.AddToWorld方法的具体用法?C# GameKeepComponent.AddToWorld怎么用?C# GameKeepComponent.AddToWorld使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOL.GS.Keeps.GameKeepComponent
的用法示例。
在下文中一共展示了GameKeepComponent.AddToWorld方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCommand
//.........这里部分代码省略.........
//todo good formula
//component.ComponentX = (component.X - myKeep.X) / 148;
//component.ComponentY = (component.Y - myKeep.Y) / 148;
double angle = myKeep.Heading * ((Math.PI * 2) / 360); // angle*2pi/360;
//component.ComponentX = (int)((148 * Math.Sin(angle) * myKeep.X - 148 * Math.Sin(angle) * client.Player.X + client.Player.Y - myKeep.Y)
// / (148 * Math.Sin(angle) - 148 * 148 * 2 * Math.Sin(angle) * Math.Cos(angle)));
//component.ComponentY = (int)((myKeep.Y - client.Player.Y + 148 * Math.Sin(angle) * component.ComponentX) / (148 * Math.Cos(angle)));
component.ComponentX = CalcCX(client.Player, myKeep, angle);
component.ComponentY = CalcCY(client.Player, myKeep, angle);
/*
x = (component.X-myKeep.X)/148 = a*cos(t) - b*sin(t)
y = (component.Y-myKeep.Y)/148 = a*sin(t) + b*cos(t)
a = sqrt((x+b*sin(t))^2 + (y-b*cos(t))^2)
a = sqrt(x²+y²+b² +2*x*b*sin(t)-2*y*b*cos(t))
b = sqrt((x-a*cos(t))^2 + (y-a*sin(t))^2)
b = sqrt(x²+y²+a²-2*x*a*cos(t)-2*y*a*sin(t))
0 = 2x²+2y²-2*x*a*cos(t)-2*y*a*sin(t)+2*x*sqrt(x²+y²+a²-2*x*a*cos(t)-2*y*a*sin(t))*sin(t)-2*y*sqrt(x²+y²+a²-2*x*a*cos(t)-2*y*a*sin(t))*cos(t)
pfff
so must find an other way to find it....
*/
component.Name = myKeep.Name;
component.Model = INVISIBLE_MODEL;
component.Skin = skin;
component.Level = (byte)myKeep.Level;
component.CurrentRegion = client.Player.CurrentRegion;
component.Health = component.MaxHealth;
component.ID = myKeep.KeepComponents.Count;
component.AbstractKeep.KeepComponents.Add(component);
component.SaveInDB = true;
component.AddToWorld();
component.SaveIntoDatabase();
client.Out.SendKeepInfo(myKeep);
client.Out.SendKeepComponentInfo(component);
client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepComponents.Create.KCCreated"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
} break;
#endregion Create
#region Move
case "move":
{
GameKeepComponent component = client.Player.TargetObject as GameKeepComponent;
component.X = client.Player.X;
component.Y = client.Player.Y;
component.Z = client.Player.Z;
component.ComponentHeading = (client.Player.Heading - myKeep.Heading) / 1024;
component.Heading = (ushort)(component.ComponentHeading * 1024 + myKeep.Heading);
component.Keep = myKeep;
//todo good formula
//component.ComponentX = (component.X - myKeep.X) / 148;
//component.ComponentY = (myKeep.Y - component.Y) / 148;
double angle = myKeep.Heading * ((Math.PI * 2) / 360); // angle*2pi/360;
//component.ComponentX = (int)((148 * Math.Sin(angle) * myKeep.X - 148 * Math.Sin(angle) * client.Player.X + client.Player.Y - myKeep.Y)
// / (148 * Math.Sin(angle) - 148 * 148 * 2 * Math.Sin(angle) * Math.Cos(angle)));
//component.ComponentY = (int)((myKeep.Y - client.Player.Y + 148 * Math.Sin(angle) * component.ComponentX) / (148 * Math.Cos(angle)));
component.ComponentX = CalcCX(client.Player, myKeep, angle);
component.ComponentY = CalcCY(client.Player, myKeep, angle);
client.Out.SendKeepInfo(myKeep);
client.Out.SendKeepComponentInfo(component);
client.Out.SendKeepComponentDetailUpdate(component);
示例2: OnCommand
//.........这里部分代码省略.........
//todo good formula
//component.ComponentX = (component.X - myKeep.X) / 148;
//component.ComponentY = (component.Y - myKeep.Y) / 148;
double angle = myKeep.Heading * ((Math.PI * 2) / 360); // angle*2pi/360;
//component.ComponentX = (int)((148 * Math.Sin(angle) * myKeep.X - 148 * Math.Sin(angle) * client.Player.X + client.Player.Y - myKeep.Y)
// / (148 * Math.Sin(angle) - 148 * 148 * 2 * Math.Sin(angle) * Math.Cos(angle)));
//component.ComponentY = (int)((myKeep.Y - client.Player.Y + 148 * Math.Sin(angle) * component.ComponentX) / (148 * Math.Cos(angle)));
component.ComponentX = CalcCX(client.Player, myKeep, angle);
component.ComponentY = CalcCY(client.Player, myKeep, angle);
/*
x = (component.X-myKeep.X)/148 = a*cos(t) - b*sin(t)
y = (component.Y-myKeep.Y)/148 = a*sin(t) + b*cos(t)
a = sqrt((x+b*sin(t))^2 + (y-b*cos(t))^2)
a = sqrt(x²+y²+b² +2*x*b*sin(t)-2*y*b*cos(t))
b = sqrt((x-a*cos(t))^2 + (y-a*sin(t))^2)
b = sqrt(x²+y²+a²-2*x*a*cos(t)-2*y*a*sin(t))
0 = 2x²+2y²-2*x*a*cos(t)-2*y*a*sin(t)+2*x*sqrt(x²+y²+a²-2*x*a*cos(t)-2*y*a*sin(t))*sin(t)-2*y*sqrt(x²+y²+a²-2*x*a*cos(t)-2*y*a*sin(t))*cos(t)
pfff
so must find an other way to find it....
*/
component.Name = myKeep.Name;
component.Model = INVISIBLE_MODEL;
component.Skin = skin;
component.Level = (byte)myKeep.Level;
component.CurrentRegion = client.Player.CurrentRegion;
component.Health = component.MaxHealth;
component.ID = myKeep.KeepComponents.Count;
component.Keep.KeepComponents.Add(component);
component.SaveInDB = true;
component.AddToWorld();
component.SaveIntoDatabase();
client.Out.SendKeepInfo(myKeep);
client.Out.SendKeepComponentInfo(component);
client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.KeepComponents.Create.KCCreated"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
} break;
#endregion Create
#region Move
case "move":
{
GameKeepComponent component = client.Player.TargetObject as GameKeepComponent;
component.X = client.Player.X;
component.Y = client.Player.Y;
component.Z = client.Player.Z;
component.ComponentHeading = (client.Player.Heading - myKeep.Heading) / 1024;
component.Heading = (ushort)(component.ComponentHeading * 1024 + myKeep.Heading);
component.Keep = myKeep;
//todo good formula
//component.ComponentX = (component.X - myKeep.X) / 148;
//component.ComponentY = (myKeep.Y - component.Y) / 148;
double angle = myKeep.Heading * ((Math.PI * 2) / 360); // angle*2pi/360;
//component.ComponentX = (int)((148 * Math.Sin(angle) * myKeep.X - 148 * Math.Sin(angle) * client.Player.X + client.Player.Y - myKeep.Y)
// / (148 * Math.Sin(angle) - 148 * 148 * 2 * Math.Sin(angle) * Math.Cos(angle)));
//component.ComponentY = (int)((myKeep.Y - client.Player.Y + 148 * Math.Sin(angle) * component.ComponentX) / (148 * Math.Cos(angle)));
component.ComponentX = CalcCX(client.Player, myKeep, angle);
component.ComponentY = CalcCY(client.Player, myKeep, angle);
component.SaveIntoDatabase();
client.Out.SendKeepInfo(myKeep);
client.Out.SendKeepComponentInfo(component);