本文整理汇总了C#中BCBlockGameState.DelayInvoke方法的典型用法代码示例。如果您正苦于以下问题:C# BCBlockGameState.DelayInvoke方法的具体用法?C# BCBlockGameState.DelayInvoke怎么用?C# BCBlockGameState.DelayInvoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BCBlockGameState
的用法示例。
在下文中一共展示了BCBlockGameState.DelayInvoke方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BehaviourAdded
/// <summary>
/// sealed override, responsible for most of the bulk of the work of the TimedBehaviour.
/// </summary>
/// <param name="toPaddle"></param>
/// <param name="gamestate"></param>
public override sealed void BehaviourAdded(Paddle toPaddle, BCBlockGameState gamestate)
{
//call base implementation
base.BehaviourAdded(toPaddle, gamestate);
//check if we are SingleInstance. If so, that means that there can only be one instance at a time, which may not be surprising given the name.
if (SingleInstance())
{
//check for existing instances of our class. If found, add our delay time to them.
foreach (var iterate in (from p in toPaddle.Behaviours where p != this select p))
{
if (iterate.GetType() == GetType())
{
//if same type, change delay, and break from routine.
(iterate as TimedPaddleBehaviour).ChangeDelayTime(gamestate, _BehaviourTime, true);
//make sure this instance get's removed, too! we are redundant now.
gamestate.NextFrameCalls.Enqueue
(new BCBlockGameState.NextFrameStartup(() => toPaddle.Behaviours.Remove(this)));
return;
}
}
}
//if we are either not singleinstance or we are single instance but there are no existing behaviours of our type attached,
//do the stuff to add us.
DelayIdentifier = gamestate.DelayInvoke(_BehaviourTime, TimeDelayRoutine, new object[] {gamestate});
//if we have ability music, we play it now. Use the SoundManager's capacity to handle temporary music, which works rather well.
if (_AbilityMusic != "") BCBlockGameState.Soundman.PlayTemporaryMusic(_AbilityMusic, 1.0f, true);
//hook Death function. If the paddle dies, obviously the time delay will break out early, so we will need to stop the temporary music ourself.
toPaddle.OnDeath += new Func<Paddle, bool>(toPaddle_OnDeath);
//call abstract method for initialization.
TimedBehaviourInitialize(toPaddle, gamestate);
}
示例2: AbilityInit
public override void AbilityInit(GameCharacter gamechar, BCBlockGameState gstatem)
{
gamechar.OnDeath += gamechar_OnDeath;
DelayIdentifier = gstatem.DelayInvoke(_Duration, revertroutinefunc, new object[] { gamechar, gstatem });
AbilityStart = DateTime.Now;
if (!String.IsNullOrEmpty(_AbilityMusic))
//BCBlockGameState.Soundman.PushMusic(_AbilityMusic, 1.0f, true);
BCBlockGameState.Soundman.PlayTemporaryMusic(_AbilityMusic, 1.0f, true);
}
示例3: BehaviourAdded
public override void BehaviourAdded(cBall onBall, BCBlockGameState currstate)
{
base.BehaviourAdded(onBall, currstate);
//start timer...
currstate.DelayInvoke(_TimeLength, DelayRoutine, null);
}
示例4: PerformBlockHit
public override bool PerformBlockHit(BCBlockGameState parentstate, cBall ballhit)
{
if (_Locked) return false;
Active = !Active;
_hasChanged = true;
BCBlockGameState.Soundman.PlaySound(Active ? ActiveSound : InactiveSound);
int IDcheck = Active ? AllActiveID : AllInactiveID;
IEnumerable<SwitchBlock> dealblocks=null;
bool triggered = false;
bool? triggerbool = null;
if ((SwitchMode & SwitchModeConstants.SwitchMode_MultipleBlock) != SwitchModeConstants.SwitchMode_MultipleBlock)
{
//we need to deal with only this block.
dealblocks = new SwitchBlock[] { this};
}
else if ((SwitchMode & SwitchModeConstants.SwitchMode_MultipleBlock)==SwitchModeConstants.SwitchMode_MultipleBlock)
{
//we need to work with all blocks in the set that are SwitchBlocks and have the same ID.
dealblocks = (from t in parentstate.Blocks where t is SwitchBlock && (t as SwitchBlock).ID(Active) == IDcheck select (SwitchBlock)t);
}
if (dealblocks == null || !dealblocks.Any())
{
//uhhh...
return false;
}
// are all dealblocks activated?
if (AllActiveID != 0)
{
if (dealblocks.All((t) => t.Active))
{
triggered = true;
triggerbool = true; //all active.
BCBlockGameState.Soundman.PlaySound("laser2");
Trigger.InvokeTriggerID(AllActiveID, parentstate);
}
}
if (AllInactiveID != 0)
{
if (dealblocks.All((t) => !t.Active))
{
triggered = true;
triggerbool = false;
BCBlockGameState.Soundman.PlaySound("laser2");
Trigger.InvokeTriggerID(AllInactiveID, parentstate);
}
}
if (triggered) //only destroy or reset if we were triggered.
{
if ((SwitchMode & SwitchModeConstants.SwitchMode_MultiTrigger) != SwitchModeConstants.SwitchMode_MultiTrigger)
{
//we fire once. if activated, destroy all the blocks we worked with.
parentstate.NextFrameCalls.Enqueue(new BCBlockGameState.NextFrameStartup(() =>
{
var removethese = dealblocks.ToList();
foreach (var destroythis in removethese)
{
destroythis.StandardSpray(parentstate,null);
parentstate.Blocks.Remove(destroythis);
}
parentstate.Forcerefresh = true;
}));
}
else if ((SwitchMode & SwitchModeConstants.SwitchMode_MultiTrigger) == SwitchModeConstants.SwitchMode_MultiTrigger)
{
//can fire multiple times. Set the state of all affected blocks to false.
//We will do this on a time delay, however, and set their "Locked" property to true, preventing
//this routine from changing their active state in the future until the delay expires.
foreach (var anullthis in dealblocks)
{
anullthis.Locked = true;
}
parentstate.DelayInvoke(new TimeSpan(0, 0, 0, 1), (a) =>
{
parentstate.NextFrameCalls.Enqueue(new BCBlockGameState.NextFrameStartup(() =>
{
foreach (var unlockit in dealblocks)
{
unlockit.Active = !(triggerbool.Value); //invert to old value.
unlockit.Locked = false;
}
parentstate.Forcerefresh = true;
}
));
});
}
}
return false; //don't destroy.
}