本文整理汇总了C#中TickCount类的典型用法代码示例。如果您正苦于以下问题:C# TickCount类的具体用法?C# TickCount怎么用?C# TickCount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TickCount类属于命名空间,在下文中一共展示了TickCount类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MapGrhEffectSeekPosition
/// <summary>
/// Initializes a new instance of the <see cref="MapGrhEffectSeekPosition"/> class.
/// </summary>
/// <param name="grh">Grh to draw.</param>
/// <param name="position">Position to draw on the map.</param>
/// <param name="target">The destination position.</param>
/// <param name="speed">How fast this object moves towards the target in pixels per second.</param>
public MapGrhEffectSeekPosition(Grh grh, Vector2 position, Vector2 target, float speed)
: base(grh, position)
{
speed = speed / 1000f;
_startTime = TickCount.Now;
_startPosition = position;
_targetPosition = target;
// Calculate the angle between the position and target
var diff = position - target;
var angle = Math.Atan2(diff.Y, diff.X);
var cos = Math.Cos(angle);
var sin = Math.Sin(angle);
// Multiply the normalized direction vector (the cos and sine values) by the speed to get the velocity
// to use for each elapsed millisecond
_velocity = -new Vector2((float)(cos * speed), (float)(sin * speed));
// Precalculate the amount of time it will take to hit the target. This way, we can check if we have reached
// the destination simply by checking the current time.
var dist = Vector2.Distance(position, target);
var reqTime = (int)Math.Ceiling(dist / speed);
_endTime = (TickCount)(_startTime + reqTime);
}
开发者ID:wtfcolt,项目名称:game,代码行数:34,代码来源:MapGrhEffectSeekPosition.cs
示例2: HandleDraw
/// <summary>
/// When overridden in the derived class, draws the graphics to the control.
/// </summary>
/// <param name="currentTime">The current time.</param>
protected override void HandleDraw(TickCount currentTime)
{
base.HandleDraw(currentTime);
if (DesignMode)
return;
if (_drawingManager.RenderWindow == null)
return;
if (Grh == null)
return;
Grh.Update(currentTime);
m.Update(currentTime);
_drawingManager.Update(currentTime);
var sb = _drawingManager.BeginDrawWorld(_camera);
if (sb == null)
return;
// Change the view
var oldView = RenderWindow.GetView();
_drawView.Reset(new FloatRect(Camera.Min.X, Camera.Min.Y, Camera.Size.X, Camera.Size.Y));
RenderWindow.SetView(_drawView);
try
{
try
{
Grh.Draw(sb, Vector2.Zero, Color.White);
}
catch (LoadingFailedException)
{
// A LoadingFailedException is generally fine here since it probably means the graphic file was invalid
// or does not exist
}
// Draw the walls
if (Walls != null)
{
foreach (var wall in Walls)
{
var rect = wall.ToRectangle();
RenderRectangle.Draw(sb, rect, _autoWallColor);
}
}
m.Draw(sb, Camera);
}
finally
{
_drawingManager.EndDrawWorld();
// Restore the view
RenderWindow.SetView(oldView);
}
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:64,代码来源:GrhPreviewScreenControl.cs
示例3: Update
/// <summary>
/// Updates the <see cref="MapGrh"/>.
/// </summary>
/// <param name="currentTime">Current game time.</param>
public override void Update(TickCount currentTime)
{
base.Update(currentTime);
if (IsAlive)
UpdateEffect(currentTime);
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:11,代码来源:MapGrhEffect.cs
示例4: Update
/// <summary>
/// Updates the World.
/// </summary>
public virtual void Update()
{
// Get the current time
var currentTime = GetTime();
// Check if this is the very first update - if so, bring the timer up to date
if (_isFirstUpdate)
{
_lastUpdateTime = currentTime;
_isFirstUpdate = false;
}
// Grab the update rate
var updateRate = GameData.WorldPhysicsUpdateRate;
// Check if we fell too far behind
if (currentTime - _lastUpdateTime > _maxUpdateDeltaTime)
{
const string errmsg = "Fell too far behind in updates to catch up. Jumping ahead to current time.";
if (log.IsWarnEnabled)
log.Warn(errmsg);
// Push the time ahead to a bit before the current time
_lastUpdateTime = (TickCount)(currentTime - updateRate - 1);
}
// Keep updating until there is not enough delta time to fit into the updateRate
while (currentTime > _lastUpdateTime + updateRate)
{
UpdateMaps(updateRate);
_lastUpdateTime += (uint)updateRate;
}
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:36,代码来源:WorldBase.cs
示例5: GetTimeStamp
/// <summary>
/// Gets the time stamp.
/// </summary>
/// <param name="currentTime">The time to get the time stamp for.</param>
/// <returns>The time stamp for the given time.</returns>
public static ushort GetTimeStamp(TickCount currentTime)
{
unchecked
{
return (ushort)((currentTime >> 3) % (MaxTimeStampSize + 1));
}
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:12,代码来源:PacketTimestampHelper.cs
示例6: Update
/// <summary>
/// Updates the GUISettings.
/// </summary>
/// <param name="currentTime">Current time.</param>
public void Update(TickCount currentTime)
{
if (_lastSaveTime + _saveFrequency > currentTime)
return;
_lastSaveTime = currentTime;
AsyncSave();
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:12,代码来源:GUIStatePersister.cs
示例7: Update
/// <summary>
/// Updates the server time.
/// </summary>
/// <param name="currentTime">The current game time. Used to determine if enough time has elapsed since
/// the last update.</param>
public void Update(TickCount currentTime)
{
if (currentTime - _lastUpdateTime < UpdateRate)
return;
_lastUpdateTime = currentTime;
_updateQuery.Execute();
}
开发者ID:wtfcolt,项目名称:game,代码行数:13,代码来源:ServerTimeUpdater.cs
示例8: TimeElapsed
public bool TimeElapsed(TickCount currentTick)
{
if (currentTick.Elapsed(storedTime, this.interval)) {
return true;
} else {
return false;
}
}
开发者ID:pzaps,项目名称:Server,代码行数:8,代码来源:MapGCTimedEvent.cs
示例9: ItemEntity
public ItemEntity(MapEntityIndex mapEntityIndex, Vector2 pos, Vector2 size, GrhIndex graphicIndex, TickCount currentTime)
: base(pos, size)
{
Amount = 0;
((IDynamicEntitySetMapEntityIndex)this).SetMapEntityIndex(mapEntityIndex);
_grh = new Grh(GrhInfo.GetData(graphicIndex), AnimType.Loop, currentTime);
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:8,代码来源:ItemEntity.cs
示例10: MapGrh
/// <summary>
/// Initializes a new instance of the <see cref="MapGrh"/> class.
/// </summary>
/// <param name="reader">The reader to read the values from.</param>
/// <param name="currentTime">The current time.</param>
/// <exception cref="ArgumentNullException"><paramref name="reader" /> is <c>null</c>.</exception>
public MapGrh(IValueReader reader, TickCount currentTime)
{
if (reader == null)
throw new ArgumentNullException("reader");
_grh = new Grh(null, AnimType.Loop, currentTime);
ReadState(reader);
}
开发者ID:Vizzini,项目名称:netgore,代码行数:15,代码来源:MapGrh.cs
示例11: MapNpcBase
public MapNpcBase(DataManager.Maps.MapNpc rawNpc)
{
this.rawNpc = rawNpc;
Darkness = -2;
Mobility = new bool[16];
TimeMultiplier = 1000;
AttackTimer = new TickCount(Core.GetTickCount().Tick);
PauseTimer = new TickCount(Core.GetTickCount().Tick);
}
开发者ID:ScruffyKnight,项目名称:PMU-Server,代码行数:9,代码来源:MapNpcBase.cs
示例12: OnTimeElapsed
public void OnTimeElapsed(TickCount currentTick)
{
storedTime = currentTick;
return;
PMU.Sockets.IPacket packet = PMU.Sockets.TcpPacket.CreatePacket("keepalive");
foreach (Network.Client client in Network.ClientManager.GetAllClients()) {
Network.Messenger.SendDataTo(client, packet);
}
}
开发者ID:ScruffyKnight,项目名称:PMU-Server,代码行数:9,代码来源:ClientKeepAliveTimedEvent.cs
示例13: UpdateEffect
/// <summary>
/// When overridden in the derived class, performs the additional updating that this <see cref="MapGrhEffect"/>
/// needs to do such as checking if it is time to kill the effect. This method should be overridden instead of
/// <see cref="MapGrh.Update"/>. This method will not be called after the effect has been killed.
/// </summary>
/// <param name="currentTime">Current game time.</param>
protected override void UpdateEffect(TickCount currentTime)
{
if (_terminateWhenDoneLooping && Grh.AnimType == AnimType.None)
{
Kill(true);
return;
}
if (TickCount.Now >= _expireTime)
Kill(true);
}
开发者ID:wtfcolt,项目名称:game,代码行数:17,代码来源:MapGrhEffectTimed.cs
示例14: IPSocket
/// <summary>
/// Initializes a new instance of the <see cref="IPSocket"/> class.
/// </summary>
/// <param name="conn">The <see cref="NetConnection"/> that this <see cref="IPSocket"/> is for.</param>
IPSocket(NetConnection conn)
{
_timeCreated = TickCount.Now;
_conn = conn;
var addressBytes = _conn.RemoteEndPoint.Address.GetAddressBytes();
_address = IPAddressHelper.IPv4AddressToUInt(addressBytes, 0);
_addressStr = IPAddressHelper.ToIPv4Address(_address) + ":" + _conn.RemoteEndPoint.Port;
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:15,代码来源:IPSocket.cs
示例15: GrhDataUpdaterProgressForm
/// <summary>
/// Initializes a new instance of the <see cref="GrhDataUpdaterProgressForm"/> class.
/// </summary>
/// <param name="total">The total number of items.</param>
public GrhDataUpdaterProgressForm(int total)
{
InitializeComponent();
_total = total;
_startTime = TickCount.Now;
progBar.Minimum = 0;
progBar.Maximum = total;
progBar.Value = 0;
}
开发者ID:Vizzini,项目名称:netgore,代码行数:15,代码来源:GrhDataUpdaterProgressForm.cs
示例16: MapGrhEffectSeekSpatial
/// <summary>
/// Initializes a new instance of the <see cref="MapGrhEffectLoopOnce"/> class.
/// </summary>
/// <param name="grh">Grh to draw.</param>
/// <param name="position">Position to draw on the map.</param>
/// <param name="target">The <see cref="ISpatial"/> to seek out.</param>
/// <param name="speed">How fast this object moves towards the target in pixels per second.</param>
/// <exception cref="ArgumentNullException"><paramref name="target"/> is null.</exception>
public MapGrhEffectSeekSpatial(Grh grh, Vector2 position, ISpatial target, float speed)
: base(grh, position)
{
if (target == null)
throw new ArgumentNullException("target");
_lastUpdate = TickCount.Now;
_target = target;
_speed = speed / 1000f;
}
开发者ID:wtfcolt,项目名称:game,代码行数:19,代码来源:MapGrhEffectSeekSpatial.cs
示例17: StartCasting
/// <summary>
/// Starts the display of a skill being casted.
/// </summary>
/// <param name="skillType">Type of the skill.</param>
/// <param name="castTime">The time it will take for the skill to be casted.</param>
public void StartCasting(SkillType skillType, TickCount castTime)
{
_currentCastTime = castTime;
_castStartTime = TickCount.Now;
_skillType = skillType;
Text = "Casting " + skillType;
var textSize = Font.MeasureString(Text);
_textOffset = (Size / 2f) - (textSize / 2f);
IsVisible = true;
}
开发者ID:wtfcolt,项目名称:game,代码行数:18,代码来源:SkillCastProgressBar.cs
示例18: ChatBubble
/// <summary>
/// Initializes a new instance of the <see cref="ChatBubble"/> class.
/// </summary>
/// <param name="parent">The parent <see cref="Control"/>.</param>
/// <param name="owner">The <see cref="Entity"/> that this <see cref="ChatBubble"/> is for.</param>
/// <param name="text">The text to display.</param>
/// <exception cref="ArgumentNullException"><paramref name="owner" /> is <c>null</c>.</exception>
/// <exception cref="ArgumentNullException"><paramref name="text" /> is <c>null</c>.</exception>
public ChatBubble(Control parent, Entity owner, string text) : base(parent, Vector2.Zero, Vector2.Zero)
{
if (owner == null)
throw new ArgumentNullException("owner");
if (string.IsNullOrEmpty(text))
throw new ArgumentNullException("text");
_owner = owner;
_deathTime = (TickCount)(TickCount.Now + Lifespan);
_textControl = new ChatBubbleText(this, text) { Font = Font };
_owner.Disposed += ChatBubble_Owner_Disposed;
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:21,代码来源:ChatBubble.cs
示例19: MapGrh
/// <summary>
/// Initializes a new instance of the <see cref="MapGrh"/> class.
/// </summary>
/// <param name="reader">The reader to read the values from.</param>
/// <param name="currentTime">The current time.</param>
/// <exception cref="ArgumentNullException"><paramref name="reader" /> is <c>null</c>.</exception>
public MapGrh(IValueReader reader, TickCount currentTime)
{
if (reader == null)
throw new ArgumentNullException("reader");
_grh = new Grh(null, AnimType.Loop, currentTime);
ReadState(reader);
// Set the initial size value
var grhSize = Grh.Size;
Vector2.Multiply(ref _scale, ref grhSize, out _scaledGrhSizeCache);
}
开发者ID:wtfcolt,项目名称:game,代码行数:19,代码来源:MapGrh.cs
示例20: StartCasting
/// <summary>
/// Starts the display of a skill being casted.
/// </summary>
/// <param name="skillType">Type of the skill.</param>
/// <param name="castTime">The time it will take for the skill to be casted.</param>
public void StartCasting(SkillType skillType, TickCount castTime)
{
_currentCastTime = castTime;
_castStartTime = TickCount.Now;
_skillType = skillType;
Text = GameMessageCollection.CurrentLanguage.GetMessage(GameMessage.CombatCastingBegin, skillType.ToString());
var textSize = Font.MeasureString(Text);
_textOffset = (Size / 2f) - (textSize / 2f);
IsVisible = true;
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:18,代码来源:SkillCastProgressBar.cs
注:本文中的TickCount类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论