本文整理汇总了C#中Controller.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# Controller.Initialize方法的具体用法?C# Controller.Initialize怎么用?C# Controller.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller.Initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: initialize
public override void initialize(int characterID, GameObject gameManager)
{
base.initialize (characterID, gameManager);
bow.Initialize ();
bow.instantiateRangeIndicator (this.gameObject);
quiver = new Quiver ();
quiver.Initialize (7, this.gameObject);
controller = new Controller ();
controller.Initialize (currentMovementSpeed);
setMainPlayer ();
quiver.addArrow (ArrowType.FireArrow, 3);
quiver.addArrow (ArrowType.IceArrow, 3);
quiver.addArrow (ArrowType.ForceArrow, 3);
quiver.addArrow (ArrowType.TreeArrow, 3);
quiver.addArrow (ArrowType.PiercingArrow, 3);
quiver.addArrow (ArrowType.SplitArrow, 3);
currentAmmo = ArrowType.Arrow;
}
示例2: Connect
void Connect(ConnectionDetails details, Controller controller) {
Active = true;
var client = new Client(details.Nickname, details.SteamworksSessionId);
var connection = Connection.CreateWith(details);
var handshaker = new Handshaker(details, client, connection);
var signonProcessor = new SignonProcessor(client, connection);
var gameProcessor = new GameProcessor(client, connection);
var userCmdGenerator = new UserCmdGenerator(client, connection);
controller.Initialize(details.SteamId, client, connection, userCmdGenerator);
Machines.Call tick = () => {
controller.Tick();
userCmdGenerator.Tick();
client.Created.Clear();
client.Deleted.Clear();
};
Machines.Call joinReset = () => {
userCmdGenerator.Reset();
};
var metastates = new Dictionary<SpectateState, Metastate>() {
{ SpectateState.HANDSHAKE_REQUEST, Metastate.HANDSHAKE },
{ SpectateState.HANDSHAKE_CONNECT, Metastate.HANDSHAKE },
{ SpectateState.SIGNON_CONNECTED, Metastate.SIGNON },
{ SpectateState.SIGNON_NEW, Metastate.SIGNON },
{ SpectateState.SIGNON_PRESPAWN, Metastate.SIGNON },
{ SpectateState.SIGNON_SPAWN, Metastate.SIGNON },
{ SpectateState.SIGNON_FULL, Metastate.GAME },
};
var processors = new Dictionary<Metastate, Processor>() {
{ Metastate.HANDSHAKE, handshaker },
{ Metastate.SIGNON, signonProcessor},
{ Metastate.GAME, gameProcessor }
};
Func<SpectateState, Machines.MachineBinding<Event, SpectateState>> Start = Machines.Start<Event, SpectateState>;
Func<SpectateState, Machines.MachineStateBinding<Event, SpectateState>> In = Machines.In<Event, SpectateState>;
Func<Event, Machines.MachineTransitionBinding<Event, SpectateState>> On = Machines.On<Event, SpectateState>;
var machine = Start(SpectateState.DISCONNECTED)
.Add(In(SpectateState.DISCONNECTED)
.Add(On(Event.REQUEST_CONNECT).Transit(SpectateState.HANDSHAKE_REQUEST)))
.Add(In(SpectateState.HANDSHAKE_REQUEST)
.Entry(handshaker.RequestHandshake)
.Add(On(Event.HANDSHAKE_CHALLENGE).Transit(SpectateState.HANDSHAKE_CONNECT))
.Add(On(Event.REJECTED).Transit(SpectateState.REJECTED)))
.Add(In(SpectateState.HANDSHAKE_CONNECT)
.Entry(handshaker.RespondHandshake)
.Add(On(Event.HANDSHAKE_COMPLETE).Transit(SpectateState.SIGNON_CONNECTED))
.Add(On(Event.REJECTED).Transit(SpectateState.REJECTED)))
.Add(In(SpectateState.SIGNON_CONNECTED)
.Entry(signonProcessor.EnterConnected)
.Add(On(Event.GO_NEW).Transit(SpectateState.SIGNON_NEW))
.Add(On(Event.DISCONNECTED).Transit(SpectateState.DISCONNECTED)))
.Add(In(SpectateState.SIGNON_NEW)
.Entry(signonProcessor.EnterNew)
.Add(On(Event.GO_CONNECTED).Transit(SpectateState.SIGNON_CONNECTED))
.Add(On(Event.GO_PRESPAWN).Transit(SpectateState.SIGNON_PRESPAWN))
.Add(On(Event.DISCONNECTED).Transit(SpectateState.DISCONNECTED)))
.Add(In(SpectateState.SIGNON_PRESPAWN)
.Entry(signonProcessor.EnterPrespawn)
.Add(On(Event.GO_SPAWN).Transit(SpectateState.SIGNON_SPAWN))
.Add(On(Event.DISCONNECTED).Transit(SpectateState.DISCONNECTED)))
.Add(In(SpectateState.SIGNON_SPAWN)
.Entry(signonProcessor.EnterSpawn)
.Add(On(Event.BASELINE).Transit(SpectateState.SIGNON_FULL))
.Add(On(Event.DISCONNECTED).Transit(SpectateState.DISCONNECTED)))
.Add(In(SpectateState.SIGNON_FULL)
.Entry(() => { gameProcessor.EnterGame(); joinReset(); })
.Add(On(Event.TICK).Call(tick))
.Add(On(Event.DISCONNECTED).Transit(SpectateState.DISCONNECTED)))
.Add(In(SpectateState.REJECTED))
.Build();
machine.Trigger(Event.REQUEST_CONNECT);
long next_tick = DateTime.Now.Ticks;
while (machine.State != SpectateState.DISCONNECTED &&
machine.State != SpectateState.REJECTED) {
if (next_tick > DateTime.Now.Ticks) {
Thread.Sleep(1);
continue;
}
List<byte[]> outBand = connection.GetOutOfBand();
List<Connection.Message> inBand = connection.GetInBand();
foreach (byte[] message in outBand) {
Nullable<Event> e = processors[metastates[machine.State]].Process(message);
if (e.HasValue) {
machine.Trigger(e.Value);
}
}
foreach (Connection.Message message in inBand) {
Nullable<Event> e = processors[metastates[machine.State]].Process(message);
if (e.HasValue) {
machine.Trigger(e.Value);
//.........这里部分代码省略.........