当前位置: 首页>>代码示例>>C#>>正文


C# Controller.Initialize方法代码示例

本文整理汇总了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;
    }
开发者ID:Stran6,项目名称:ArcherArena,代码行数:20,代码来源:Player.cs

示例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);
//.........这里部分代码省略.........
开发者ID:hot1989hot,项目名称:nora,代码行数:101,代码来源:Lara.cs


注:本文中的Controller.Initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。