示例#1
0
    public void Init(ICharacter character)
    {
        gm             = GameObject.FindWithTag("GameController").GetComponent <GameManager>();
        playerScript   = GetComponent <Player>();
        this.character = character;
        input          = character.GetInputModule();
        weapons        = new Weapon[2];
        inventory      = character.GetInventory();
        aimDir         = Vector3.down;

        var weaponSocket1 = transform.Find("Hand1");
        var weaponSocket2 = transform.Find("Hand2");

        dualWieldSockets    = new Transform[] { weaponSocket1, weaponSocket2 };
        singleSocket        = new Transform[] { weaponSocket2 };
        singleSocket2       = new Transform[] { weaponSocket1 };
        cameraControl       = GameObject.FindWithTag("MainCamera").GetComponent <CameraControl>();
        targetFX            = Resources.Load <GameObject>("Prefabs/Effects/TargetCircle");
        isMeleeModeActivate = false;

        targetIcone = Instantiate(targetFX, transform.position, Quaternion.identity);
        targetIcone.SetActive(false);

        hand1Obj                  = GameObject.Find("Player").transform.Find("Hand1").gameObject;
        hand2Obj                  = GameObject.Find("Player").transform.Find("Hand2").gameObject;
        meleeModeHands            = GameObject.Find("Player").transform.Find("MeleeModeHands").gameObject;
        meleeModeImpactEffects    = new GameObject[2];
        meleeModeImpactEffects[0] = GameObject.Find("Player").transform.Find("MeleeModeImpact").gameObject;
        meleeModeImpactEffects[1] = GameObject.Find("Player").transform.Find("MeleeModeImpact (1)").gameObject;

        //activeWeapNo = 1;
    }
        private void SendInput(InputType inputType)
        {
            if (!IsHandling && isPressingAnyButton)
            {
                return;
            }

            if (IsHandling)
            {
                handlingModule = handlingModule.HandleInput(inputType, DeviceInfo);
                selectorManager.CurrentSelector.NotifyHandlingModule(handlingModule);
            }
            else
            {
                var currentModule = selectorManager.CurrentSelector.GetCurrentModule();
                if (currentModule == null)
                {
                    handlingModule = defaultInputModule?.HandleInput(inputType, DeviceInfo);
                    return;
                }

                handlingModule = currentModule.HandleInput(inputType, DeviceInfo);
                selectorManager.CurrentSelector.NotifyHandlingModule(handlingModule);
            }
        }
 public void Init()
 {
     animator      = GetComponent <Animator>();
     character     = GetComponent <ICharacter>();
     bodyRenderer  = transform.Find("Body").GetComponent <SpriteRenderer>();
     faceRenderer  = transform.Find("Face").GetComponent <SpriteRenderer>();
     foot1Renderer = transform.Find("Foot1").GetComponent <SpriteRenderer>();
     foot2Renderer = transform.Find("Foot2").GetComponent <SpriteRenderer>();
     hairRenderer  = transform.Find("Hair").GetComponent <SpriteRenderer>();
     if (gameObject.tag == "FourHandsBoss")
     {
         hand1 = new Hand(transform.Find("TurnObject1").Find("Hand1"), handSprite, true);     //for FourHandsBoss
         hand2 = new Hand(transform.Find("TurnObject1").Find("Hand2").transform, handSprite); //for FourHandsBoss
         hands = new Hand[] { hand1, hand2 };
     }
     else if (gameObject.tag == "OneHandBoss")
     {
         hand1 = new Hand(transform.Find("TurnObject1").Find("Hand1"), handSprite, true); //for for OneHandBoss
         hand2 = new Hand(transform.Find("Hand2").transform, handSprite);                 //for OneHandBoss
         hands = new Hand[] { hand1, hand2 };
     }
     else
     {
         hand1 = new Hand(transform.Find("Hand1"), handSprite, true);
         hand2 = new Hand(transform.Find("Hand2"), handSprite);
         hands = new Hand[] { hand1, hand2 };
     }
     input         = character.GetInputModule();
     isInitialized = true;
     orientation   = Orientation.Down;
     character.OnInputModuleChange += OnInputModuleChange;
     character.OnWeaponChange      += OnWeaponChange;
     SetSpriteColors(character.GetColor());
 }
示例#4
0
 public NetDistributorReceiver(MainLogicModule main, IInputModule input, DistributorModule distributorModule,
                               NetReceiverConfiguration receiverConfigurationForDb,
                               NetReceiverConfiguration receiverConfigurationForFroxy)
 {
     _distributorReceiverForDb    = new NetDistributorReceiverForDb(distributorModule, receiverConfigurationForDb);
     _distributorReceiverForProxy = new NetDistributorReceiverForProxy(main, input, distributorModule,
                                                                       receiverConfigurationForFroxy);
 }
示例#5
0
 public void NotifyHandlingModule(IInputModule handlingModule)
 {
     if (this.handlingModule != handlingModule)
     {
         onChangedHandlingModule?.Invoke();
     }
     this.handlingModule = handlingModule;
 }
 void OnInputModuleChange()
 {
     if (input != null)
     {
         input.OnTap -= OnTap;
     }
     input        = player.GetInputModule();
     input.OnTap += OnTap;
 }
示例#7
0
 public void Init(ICharacter character)
 {
     this.character = character;
     input          = character.GetInputModule();
     gObj           = character.GetGameObject();
     stats          = character.GetStats();
     // Subscribing to the input change event so we can react to the change
     character.OnInputModuleChange += OnInputModuleChange;
 }
示例#8
0
 public NetDistributorReceiverForProxy(MainLogicModule main, IInputModule input, DistributorModule distributorModule,
                                       NetReceiverConfiguration receiverConfiguration) : base(receiverConfiguration)
 {
     Contract.Requires(main != null);
     Contract.Requires(input != null);
     Contract.Requires(distributorModule != null);
     _mainLogic         = main;
     _input             = input;
     _distributorModule = distributorModule;
 }
        private void Awake()
        {
            inputDevice     = GetComponent <IInputDevice>();
            DeviceInfo      = new DeviceInfo(gameObject, inputDevice);
            selectorManager = new InputModuleSelectorManager(gameObject, inputDevice);

            if (defaultInputModuleObject != null)
            {
                defaultInputModule = defaultInputModuleObject.GetComponent <IInputModule>();
            }
        }
示例#10
0
 private void RemoveInputModule()
 {
     if (collidingCandidates.Any())
     {
         SetInputModule(collidingCandidates[0]);
     }
     else
     {
         currentInputModule?.OnUnset();
         currentInputModule = null;
     }
 }
示例#11
0
        private void SetInputModule(IInputModule inputModule)
        {
            if (currentInputModule == inputModule || handlingModule != null)
            {
                return;
            }

            onSelect.Invoke();

            currentInputModule?.OnUnset();
            currentInputModule = inputModule;
            currentInputModule.OnSet();
        }
示例#12
0
 private void RemoveInputModule()
 {
     if (handlingModule != null)
     {
         return;
     }
     if (currentInputModule == null)
     {
         return;
     }
     currentInputModule?.OnUnset();
     currentInputModule = null;
 }
示例#13
0
    public void UnsubscribeFromInput(IInputModule input)
    {
        // Is this a Knob? Unsubscribe from Input
        if (input._inputType == InputType.Knob)
        {
            input.OnValueChange -= SetBoardParticleBounce;
        }

        // If it's Velocity, toggle the Board bool
        if (input._inputType == InputType.Velocity)
        {
            SetVelocityToBounce(false);
        }
    }
示例#14
0
    public void SubscribeToInput(IInputModule input)
    {
        // Is this a Knob? Subscribe to Input
        if (input._inputType == InputType.Knob)
        {
            input.OnValueChange += SetBoardParticleBounce;
        }

        // If it's Velocity, toggle the Board bool
        if (input._inputType == InputType.Velocity)
        {
            SetVelocityToBounce(true);
        }
    }
示例#15
0
 public void ChangeInputModule(IInputModule input)
 {
     if (this.input != null)
     {
         this.input.OnColorSwitch -= BroadcastColorSwitch;
     }
     this.input = input;
     this.input.OnColorSwitch += BroadcastColorSwitch;
     // Let all the modules know we had an input module change
     if (OnInputModuleChange != null)
     {
         OnInputModuleChange();
     }
 }
示例#16
0
        public InputCore(string fileName, IInputModule module)
        {
            this.fileName = fileName;
            this.module = module;

            this.bindings = new Dictionary<string, string>();
            this.listeners = new List<IInputListener>();

            foreach (string line in File.ReadLines(this.fileName))
            {
                string action = line.Split('=')[0].Trim();
                string key = line.Split('=')[1].Trim();

                this.BindKey(key, action);
            }
        }
示例#17
0
        private void SetInputModule()
        {
            var inputModule = HitInfo.transform.GetComponent <IInputModule>();

            if (currentInputModule == inputModule || IsHandling)
            {
                return;
            }

            if (inputModule == null)
            {
                RemoveInputModule();
                return;
            }
            onSelect.Invoke();

            currentInputModule?.OnUnset();
            currentInputModule = inputModule;
            currentInputModule.OnSet();
        }
示例#18
0
        public YASLServer(ServerConfiguration serverConfiguration)
        {
            TokenSource = new CancellationTokenSource();

            // create inputs
            foreach (KeyValuePair <string, QueueDefinition> queueCfg in serverConfiguration.Queues)
            {
                MasterQueue newQueue = new MasterQueue(TokenSource.Token);
                masterQueues.Add(queueCfg.Key, new Tuple <MasterQueue, Thread>(newQueue, new Thread(newQueue.GetWorker())));
            }

            // create queues
            foreach (KeyValuePair <string, InputDefinition> inputCfg in serverConfiguration.Inputs)
            {
                InputDefinition inputDef        = inputCfg.Value;
                Type            inputModuleType = GetModuleAssembly(inputDef).GetType(inputDef.ManagedTypeName);
                IInputModule    newModule       = (IInputModule)Activator.CreateInstance(inputModuleType);
                newModule.Initialize(inputDef.ConfigurationJSON, TokenSource.Token, masterQueues.Where(z => serverConfiguration.Queues.Where(x => x.Value.Inputs.Contains(inputCfg.Key)).Select(y => y.Key).Contains(z.Key)).Select(t => t.Value.Item1));
                inputModules.Add(inputCfg.Key, new Tuple <IInputModule, Thread>(newModule, new Thread(newModule.GetWorker())));
            }
        }
    Transform[][] sockeColl;// take the weapon socket

    public override void Init(ICharacter character)
    {
        base.Init(character);
        foreach (Colors c in colors)
        {
            this.character.AddColor(c);
        }
        character.SetBulletColor(colors[0]);

        gm         = GameObject.FindWithTag("GameController").GetComponent <GameManager>();
        bossScript = GetComponent <TestEnemy>();
        input      = character.GetInputModule();
        weapon     = character.GetActiveWeapon();
        inventory  = character.GetInventory();
        character.OnWeaponChange += OnWeaponChange;
        aimDir = Vector3.down;

        phase = character.phase;

        CreateWeapon();
        shootOnce = false;
    }
示例#20
0
        private void Runner()
        {
            ThreadStart ModuleEntryPoint     = null;
            bool        finishedSuccessfully = true;
            int         moduleFailureCount   = 0;
            DateTime    failureResetTimer    = DateTime.UtcNow;

            do
            {
                // create and initialize module
                while (ModuleEntryPoint == null)
                {
                    try
                    {
                        CancellationTokenSource?.Dispose();
                        CancellationTokenSource = new CancellationTokenSource();
                        CancellationToken       = CancellationTokenSource.Token;
                        InputModule             = Server.CreateModule <IInputModule>(ModuleDefinition);
                        InputModule.LoadConfiguration(ModuleConfiguration);
                        InputModule.SetMessageSender(MessageAcceptor);
                        InputModule.Initialize();
                        ModuleEntryPoint  = InputModule.GetWorker(CancellationToken);
                        failureResetTimer = DateTime.UtcNow;
                    }
                    catch (Exception e)
                    {
                        Server.Logger?.LogEvent(this, Severity.Error, "InputModule", $"Failed to re/create '{ModuleKey}'. Next retry in {ModuleReloadTimeoutSeconds} seconds.", e);
                        ModuleEntryPoint = null;
                        // pause before next attempt
                        for (int waitCount = 0; waitCount < 100; waitCount++)
                        {
                            if (CancellationToken.IsCancellationRequested)
                            {
                                break;
                            }
                            Thread.Sleep(ModuleReloadTimeoutSeconds * 10); // effectively * 1000, i.e. seconds => milliseconds
                        }
                        if (CancellationToken.IsCancellationRequested && IsConfigurationReloadRequested)
                        {
                            continue;
                        }
                        // if canceled not for reload, and still unable to create, just mark completed and exit
                        if (CancellationToken.IsCancellationRequested)
                        {
                            WorkCompleted.Set();
                            return;
                        }
                    }
                }
                // working
                try
                {
                    ModuleEntryPoint.Invoke(); // ModuleEntryPoint != null, see above
                    if (IsConfigurationReloadRequested)
                    {
                        IsConfigurationReloadRequested = false;
                        try { InputModule.Destroy(); } catch { } // to avoid Invoke() catcher
                        ModuleEntryPoint = null; // to initiate module load
                    }
                    finishedSuccessfully = true;
                    if (CancellationToken.IsCancellationRequested)
                    {
                        break;
                    }
                }
                catch (OperationCanceledException)
                {
                    break;
                }
                catch (Exception e)
                {
                    if (DateTime.UtcNow.Subtract(failureResetTimer).TotalSeconds > 10 * ModuleReloadTimeoutSeconds)
                    {
                        failureResetTimer  = DateTime.UtcNow;
                        moduleFailureCount = 0;
                    }
                    Server.Logger.LogEvent(InputModule, Severity.Error, "InputModule", $"Unexpected input module failure. That's happened {moduleFailureCount + 1} times in the row.", e);
                    finishedSuccessfully = false;
                    Server.Logger.LogEvent(this, Severity.Error, "InputModule", $"Recreating input module. Next retry in {ModuleReloadTimeoutSeconds * moduleFailureCount} seconds.");
                    if (moduleFailureCount > 0)
                    {
                        Thread.Sleep(ModuleReloadTimeoutSeconds * moduleFailureCount * 1000); // pause before next attempt
                    }
                    // re-initialize the module
                    try { InputModule.Destroy(); } catch { }
                    ModuleEntryPoint = null;
                    moduleFailureCount++;
                }
            } while (!finishedSuccessfully && !CancellationToken.IsCancellationRequested);

            // All done, but let's drain the queue
            while (AttachedQueue.Count > 0)
            {
                Thread.Sleep(5);
            }
            WorkCompleted.Set();
        }
示例#21
0
 public void SubscribeToInput(IInputModule input)
 {
     input.OnValueChange += SetBoardParticleSize;
 }
示例#22
0
 public void UnsubscribeFromInput(IInputModule input)
 {
     input.OnValueChange -= SetBoardParticleSize;
 }
示例#23
0
 public void UnsubscribeFromInput(IInputModule input)
 {
     input.OnValueChange -= UpdateSkyboxG;
 }
示例#24
0
 public void SubscribeToInput(IInputModule input)
 {
     input.OnValueChange += UpdateSkyboxG;
 }
示例#25
0
 public Computer(IInputModule inputModule, IOutputModule outputModule)
 {
     InputModule  = inputModule;
     OutputModule = outputModule;
     Reset();
 }
示例#26
0
 private void OnDisable()
 {
     currentInputModule?.OnUnset();
     currentInputModule = null;
     handlingModule     = null;
 }
示例#27
0
 public void UnsubscribeFromInput(IInputModule input)
 {
     input.OnValueChange -= UpdateBoardRotation;
 }
 void OnInputModuleChange()
 {
     input = character.GetInputModule();
 }
示例#29
0
 public void SubscribeToInput(IInputModule input)
 {
     input.OnValueChange += UpdateStageSize;
 }
示例#30
0
        /// <summary>
        /// Executes the main code for this service
        /// </summary>
        /// <param name="state">The service object</param>
        public static void Main(Object state)
        {
            // Set the event log from the servicebase
            EventLog EventLog = state == null ? new EventLog("Application") : ((ServiceBase)state).EventLog;

            // Load registry settings
            CIRegistry registry = new CIRegistry(EventLog);
            var        address  = registry.ReadUserDataFileKey();
            var        logFile  = registry.ReadLogFileKey();

            LogFile = logFile;

            WriteOutput("Starting Service");

            // Load all the assemblies and scan the types
            CIAssemblyLoader.Configure();

            ObjectFactory.Configure(c =>
            {
                foreach (var type in CIAssemblyLoader.TypesToScan)
                {
                    // Make sure the type is assignable to IInputModule
                    if (typeof(IInputModule).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract)
                    {
                        // Run the init method to configure this database endpoint
                        IInputModule obj = Activator.CreateInstance(type) as IInputModule;
                        CIEngine.Headers.Add(obj.Header);

                        // Set the properties for this object
                        obj.EventLog = EventLog;
                        obj.LogFile  = logFile;

                        // Add the object to the ObjectFactory
                        c.For <IInputModule>().Singleton().Use(obj).Named(obj.Header);

                        WriteOutput(String.Format("Adding module: {0}", type.ToString()));
                    }
                }
            });

            try
            {
                // Execute the script
                CIEngine engine = new CIEngine(EventLog, logFile);
                engine.Execute(address);
            }
            catch (Exception ex)
            {
                WriteOutput(ex.Message);
                WriteOutput(ex.StackTrace);
            }

            // Get the log file
            FileInfo info = new FileInfo(logFile);

            foreach (var type in CIAssemblyLoader.TypesToScan)
            {
                // Make sure the type is assignable to INotificationProvider
                if (typeof(INotificationProvider).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract)
                {
                    INotificationProvider obj = Activator.CreateInstance(type) as INotificationProvider;

                    // Make sure the notification is active before sending the notify command
                    if (obj.IsActive)
                    {
                        using (FileStream stream = info.OpenRead())
                            using (StreamReader reader = new StreamReader(stream))
                            {
                                // Send the log file via this notification provider
                                CloudInitSession session = new CloudInitSession(reader.ReadToEnd());
                                obj.Notify(session);
                            }
                    }
                }
            }

            if (state != null)
            {
                ServiceBase service = (ServiceBase)state;

                // Disable this service if run once is enabled
                if (registry.ReadRunOnceKey())
                {
                    ServiceController sc = new ServiceController(service.ServiceName);
                    ServiceHelper.ChangeStartMode(sc, ServiceStartMode.Disabled);
                }

                // Stop the service
                service.Stop();
            }
        }
示例#31
0
 public void UnsubscribeFromInput(IInputModule input)
 {
     input.OnValueChange -= UpdateStageSize;
 }