public Locomotion(GameObject character, float rotationSpeed, float jumpHeight, Transform viewTransform, AnimationCurve movementVectorBlend, AnimationCurve rotationBlend, ICharacterInput characterInput, IMover characterMover) { _characterGameObject = character; _characterMover = characterMover; _viewTransform = viewTransform; _RotationSpeed = rotationSpeed; _jumpHeight = jumpHeight; _MovementVectorBlend = movementVectorBlend; _RotationBlend = rotationBlend; _characterInput = characterInput; _RootMotionDelta = _characterGameObject.GetComponentInChildren <RootMotionDelta>(); _locomotionMode = LocomotionMode.Idle; if (_RootMotionDelta != null) { _RootMotionDelta.OnRootPositionChange += HandleRootMotion; } //Rotate Character to Desired Forward called _RotateLocomotionEvents = _characterGameObject.GetComponentsInChildren <IRotateDesiredForwardEvent>(); if (_RotateLocomotionEvents.Length > 0) { for (int i = 0; i < _RotateLocomotionEvents.Length; i++) { _RotateLocomotionEvents[i].OnCallDesiredForwardRotationChange += MoveToDesiredForward; } } UseMovementAngleDifference = true; OnStateChange?.Invoke(_state); }
private void Awake() { _animator = GetComponent <FSM>(); _state = GetComponent <EnemyState>(); _input = GetComponent <ICharacterInput <BossInput> >(); _hitFlash = GetComponent <HitFlash>(); _mover = GetComponent <BossMover>(); _groundDetector = GetComponent <ICanDetectGround>(); _stalkTracker = new BezierTracker(); _input.OnReceivedInput += HandleReceivedInput; _groundDetector.OnLandingStateChanged += HandleLandingStateChange; _animator.Subscribe(Animation.AnimationState.FadingIn, HandleFadeInAnimation); _animator.Subscribe(Animation.AnimationState.Completed, HandleCompletedAnimation); _animator.OnReceiveFrameEvent += HandleFrameEvent; foreach (var hitbox in _hitboxes) { hitbox.OnHit += HandleOnHit; } foreach (var weakpoint in _weakpoints) { weakpoint.SetParent(null); } }
private void Awake() { _input = GetComponent <ICharacterInput <PlayerInputCommand> >(); _mover = GetComponent <PlayerMover>(); _animator = GetComponent <FSM>(); _weaponSystem = GetComponent <WeaponSystem>(); _groundDetector = GetComponent <ICanDetectGround>(); _hitbox = GetComponentInChildren <IAttackable>(); _hitFlash = GetComponent <HitFlash>(); colliders = new List <Collider2D>(); colliderLayers = new List <int>(); _dashCooldownTimer = new Timer(); _mover.OnMovingStateChanged += HandleMovingStateChanged; _mover.OnBeginDashingInvincible += HandleDashingInvincibleBegin; _mover.OnStopDashingInvincible += HandleDashingInvincibleStop; _groundDetector.OnLandingStateChanged += HandleLandingStateChanged; _input.OnReceivedInput += HandleReceivedInput; _animator.Subscribe(Animation.AnimationState.FadingIn, HandleAnimationFadeinEvent); _animator.Subscribe(Animation.AnimationState.Completed, HandleAnimationCompletedEvent); _animator.OnReceiveFrameEvent += HandleAnimationFrameEvent; _weaponSystem.OnPull += HandlePull; _hitbox.OnHit += HandleOnHit; TimeManager.Instance.OnBulletTimeBegin += OnBulletTimeBegin; TimeManager.Instance.OnBulletTimeEnd += OnBulletTimeEnd; }
private void Start() { _fSM = this.GetComponent <FSM>(); _playerMover = this.GetComponent <PlayerMover>(); _groundDetect = this.GetComponent <ICanDetectGround>(); _characterInput = this.GetComponent <ICharacterInput <PlayerInputCommand> >(); _hitBox = GetComponentInChildren <IAttackable>(); _fSM.OnReceiveFrameEvent += FrameEventHandler; _playerMover.OnMovingStateChanged += MoveStateChangeHandler; _groundDetect.OnLandingStateChanged += HandleLanding; _characterInput.OnReceivedInput += HandleChargingATK; TimeManager.Instance.OnBulletTimeBegin += TimeManagerHandler; _hitBox.OnHit += OnHittedHandler; _fSM.Subscribe(Animation.AnimationState.FadingIn, HandleAnimationFadeInEvent); _particles = new Dictionary <string, ParticleSystem>(); _audios = new Dictionary <string, AudioClip>(); _volume = new Dictionary <string, float>(); _pitch = new Dictionary <string, float>(); _particles.Add(_particlePairs); _audios.Add(_audioPairs); _volume.Add(_volumePairs); _pitch.Add(_pitchPairs); }
public void pushInput(ICharacterInput input) { if((input)==null)throw new ArgumentNullException("input"); // Move unread characters in buffer, since this new // input sits on top of the existing input stack.Add(new InputAndBuffer(input,buffer,pos,endpos-pos)); endpos=pos; }
private void Start() { healthBar = GetComponent <IHealth>(); input = GetComponent <ICharacterInput>(); weapon = GetComponent <IWeaponFire>(); healthBar.MaxHealth(MaxHealth); }
/// <include file='../../docs.xml' /// path='docs/doc[@name="M:PeterO.Text.NormalizingCharacterInput.#ctor(System.String,System.Int32,System.Int32,PeterO.Text.Normalization)"]/*'/> public NormalizingCharacterInput( string str, int index, int length, Normalization form) { this.nci = new NormalizerInput(str, index, length, form); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (input == null) { input = (ICharacterInput)animator.GetComponent(typeof(ICharacterInput)); } input.IngoreInput(time); }
// Detects a Unicode encoding private int DetectUnicodeEncoding() { int mode = this.mode; int c1 = this.stream.ReadByte(); int c2; if (c1 < 0) { return(-1); } Utf8Reader utf8reader; switch (mode) { case 0: // UTF-8 only utf8reader = new Utf8Reader(this.stream, this.errorThrow); this.reader = utf8reader; utf8reader.Unget(c1); c1 = utf8reader.ReadChar(); if (c1 == 0xfeff && !this.dontSkipUtf8Bom) { // Skip BOM c1 = utf8reader.ReadChar(); } return(c1); case 1: case 3: c2 = this.DetectUtf8OrUtf16(c1); if (c2 >= -1) { return(c2); } break; case 2: case 4: // UTF-8, UTF-16, or UTF-32 c2 = this.DetectUtf8Or16Or32(c1); if (c2 >= -1) { return(c2); } break; } // Default case: assume UTF-8 utf8reader = new Utf8Reader(this.stream, this.errorThrow); this.reader = utf8reader; utf8reader.Unget(c1); c1 = utf8reader.ReadChar(); if (!this.dontSkipUtf8Bom && c1 == 0xfeff) { // Skip BOM c1 = utf8reader.ReadChar(); } return(c1); }
private int bufferCounter = 0;//number of frames waited to execute an input; public CharacterActions (ICharacterInput _charInput, Rigidbody2D _rbToMove, CharacterSettings _charSettings, CharacterState _charState, CharacterAnimations _charAnimations) { charInput = _charInput; rbToMove = _rbToMove; charSettings = _charSettings; charState = _charState; charAnimations = _charAnimations; }
private void Awake() { _canJump = true; if (_characterInput == null) { _characterInput = GetComponentInParent <ICharacterInput>(); } _previousMovmementAxis = Vector2.zero; CharacterState.ActivateJump += SetJumpTrigger; }
protected override void Awake() { base.Awake(); playerInput = GetComponent <ICharacterInput>(); if (playerInput == null) { Debug.LogError("You need to add some Input"); } }
public PlayerMover(ICharacterInput input, Transform objectToMove, CharacterSettings settings) { _input = input as PlayerInput; _objectToMove = objectToMove; _settings = settings; _objectToMoveRig = objectToMove.GetComponent <Rigidbody>(); _charAnim = objectToMove.GetComponentInChildren <CharacterAnimationController>(); _speed = new SpeedParams(settings.Speed); currentSpeed = _speed.walk; }
private void Awake() { _mover = GetComponent <EnemyMover>(); _state = GetComponent <EnemyState>(); _animator = GetComponent <FSM>(); _input = GetComponent <ICharacterInput <EnemyInput> >(); _input.OnReceivedInput += HandleReceivedInput; _hitBox.OnHit += HandleOnHit; _launcher.Target = FindObjectOfType <PlayerCharacter>().HittingPoint; _animator.Subscribe(Animation.AnimationState.Completed, HandleAnimationEvent); }
private void Awake() { MaxHealth = 5; Health = MaxHealth; onFire += SpawnBomb; input = GetComponent <ICharacterInput>(); weapon = GetComponent <IWeaponFire>(); healthBar = GetComponent <IHealth>(); healthBar.MaxHealth(MaxHealth); }
// Detects a Unicode encoding private int DetectUnicodeEncoding() { int mode = this.mode; int c1 = this.stream.ReadByte(); int c2; if (c1 < 0) { return(-1); } Utf8Reader utf8reader; if (mode == 0) { // UTF-8 only utf8reader = new Utf8Reader(this.stream, this.errorThrow); this.reader = utf8reader; c1 = utf8reader.ReadChar(); if (c1 == 0xfeff) { // Skip BOM c1 = utf8reader.ReadChar(); } return(c1); } else if (mode == 1 || mode == 3) { c2 = this.DetectUtf8OrUtf16(c1); if (c2 >= -1) { return(c2); } } else if (mode == 2 || mode == 4) { // UTF-8, UTF-16, or UTF-32 c2 = this.DetectUtf8Or16Or32(c1); if (c2 >= -1) { return(c2); } } // Default case: assume UTF-8 utf8reader = new Utf8Reader(this.stream, this.errorThrow); this.reader = utf8reader; utf8reader.Unget(c1); c1 = utf8reader.ReadChar(); if (!this.dontSkipUtf8Bom && c1 == 0xfeff) { // Skip BOM c1 = utf8reader.ReadChar(); } return(c1); }
private void Awake() { mRigidbody = GetComponent <Rigidbody2D>(); mCollider = GetComponent <Collider2D>(); mInput = GetComponent <ICharacterInput>(); if (mInput == null) { Debug.LogError("No character input script was found on this gameObject"); enabled = false; } }
public int read(int[] buf, int offset, int unitCount) { if ((buf) == null) { throw new ArgumentNullException("buf"); } if ((offset) < 0) { throw new ArgumentOutOfRangeException("offset not greater or equal to 0 (" + Convert.ToString(offset, CultureInfo.InvariantCulture) + ")"); } if ((unitCount) < 0) { throw new ArgumentOutOfRangeException("unitCount not greater or equal to 0 (" + Convert.ToString(unitCount, CultureInfo.InvariantCulture) + ")"); } if ((offset + unitCount) > buf.Length) { throw new ArgumentOutOfRangeException("offset+unitCount not less or equal to " + Convert.ToString(buf.Length, CultureInfo.InvariantCulture) + " (" + Convert.ToString(offset + unitCount, CultureInfo.InvariantCulture) + ")"); } if (unitCount == 0) { return(0); } int count = 0; if (charInput != null) { int c = charInput.read(buf, offset, unitCount); if (c <= 0) { charInput = null; } else { offset += c; unitCount -= c; count += c; } } if (buffer != null) { int c = Math.Min(unitCount, this.buffer.Length - pos); if (c > 0) { Array.Copy(this.buffer, pos, buf, offset, c); } pos += c; count += c; if (c == 0) { buffer = null; } } return((count == 0) ? -1 : count); }
public void pushInput(ICharacterInput input) { if ((input) == null) { throw new ArgumentNullException("input"); } // Move unread characters in buffer, since this new // input sits on top of the existing input stack.Add(new InputAndBuffer(input, buffer, pos, endpos - pos)); endpos = pos; }
public GroundedCharacterMovement(CharacterController controller, ICharacterInput input, Transform transform, Transform pov, Transform groundCheck, CharacterMovementSettings settings, int gravityDirection) { _controller = controller; _input = input; _bodyTransform = transform; _pointOfViewTransform = pov; _groundCheckTransform = groundCheck; _settings = settings; _gravityDirection = gravityDirection; }
public AIMover(ICharacterInput input, GameObject objectToMove, CharacterSettings settings) { _settings = settings; _objectToMove = objectToMove; _input = input as AIInputNav; _charAnim = objectToMove.GetComponentInChildren <CharacterAnimationController>(); _speed = new SpeedParams(settings.Speed); Vector3 startPos = _settings.Path.transform.GetChild(0).position; SetStartPosition(startPos); CreateNavMeshAgent(); }
public InputAndBuffer(ICharacterInput charInput, int[] buffer, int offset, int length) { this.charInput = charInput; if (length > 0) { this.buffer = new int[length]; Array.Copy(buffer, offset, this.buffer, 0, length); } else { this.buffer = null; } }
void Start() { _collider = new CharacterCollider(GetComponentInChildren <Collider2D>(), groundLayer); _stateMachine = new CharacterStateMachine(this); _input = new KeyboardCharacterInput(); _animator = GetComponentInChildren <Animator>(); _spriteRenderer = GetComponentInChildren <SpriteRenderer>(); _gravity = (2 * jumpHeight) / Mathf.Pow(timeToApex, 2); _jumpVelocity = Mathf.Sqrt(2 * _gravity * jumpHeight); _rigidbody = new CharacterRigidbody(_gravity, transform, _collider); }
public void InitializeCharacter(CharacterSettings settings) { this.settings = settings; isPlayer = !settings.IsAi; isAlive = true; //create input for player or AI nav input = !isPlayer ? new AIInputNav(settings, transform, this) as ICharacterInput : new PlayerInput(transform); //create mover characterMover = !isPlayer ? new AIMover(input, gameObject, settings) as ICharacterMover : new PlayerMover(input, transform, settings); //create character combat characterCombat = new CharacterCombat(input, settings.Health, gameObject, this); charAnim = gameObject.GetComponentInChildren <CharacterAnimationController>(); }
/// <include file='../../docs.xml' /// path='docs/doc[@name="M:PeterO.Text.NormalizerInput.#ctor(PeterO.Text.ICharacterInput,PeterO.Text.Normalization)"]/*'/> public NormalizerInput( ICharacterInput stream, Normalization form) { if (stream == null) { throw new ArgumentNullException("stream"); } this.lastQcsIndex = -1; this.iterator = stream; this.form = form; this.readbuffer = new int[1]; this.lastCharBuffer = new int[2]; this.compatMode = form == Normalization.NFKC || form == Normalization.NFKD; }
protected virtual void Awake() { lockOnMovement = GetComponent <LockOnMovement> (); movement = GetComponent <Movement> (); animator = GetComponent <Animator> (); lockOn = false; blocking = false; Cursor.visible = false; state = CharacterState.DEFAULT; rB = GetComponent <Rigidbody> (); characterInput = (ICharacterInput)GetComponent(typeof(ICharacterInput)); direction = Vector3.zero; targetControl = GetComponent <Targets> (); damageDealing = GetComponent <DealDamage> (); health = GetComponent <Health> (); characterCollider = GetComponent <CapsuleCollider> (); }
private void Awake() { _state = GetComponent <EnemyState>(); _input = GetComponent <ICharacterInput <EnemyInput> >(); _input.OnReceivedInput += HandleReceivedInput; hitBox.OnHit += OnHitEventHandler; _particles = new Dictionary <string, ParticleSystem>(); _audios = new Dictionary <string, AudioClip>(); _volume = new Dictionary <string, float>(); _pitch = new Dictionary <string, float>(); _audios.Add(_audioPairs); _pitch.Add(_pitchPairs); _volume.Add(_volumePairs); _particles.Add(_particlePairs); }
public CharacterCombat(ICharacterInput input, float health, GameObject character, MonoBehaviour myMonoBehaviour) { _health = health; _input = input; _characterObject = character; _myMonoBehaviour = myMonoBehaviour; _character = character.GetComponent <Character>(); _characterField = character.GetComponent <FieldOfView>(); _characterRigidbody = character.GetComponent <Rigidbody>(); _agent = character.GetComponent <NavMeshAgent>(); _charAnim = character.GetComponentInChildren <CharacterAnimationController>(); if (_character.isPlayer) { UIController.instance.UpdateHealthUI(_health); } }
private void Awake() { if (_characterInput == null) { _characterInput = GetComponent <ICharacterInput>(); } if (_characterMover == null) { _characterMover = GetComponent <IMover>(); } if (PlayerCamera == null) { if (GameObject.Find("[WorldTransform]") == false) { PlayerCamera = new GameObject("[WorldTransform]").transform; } } _Locomotion = new Locomotion(this.gameObject, rotationSpeed, JumpHeight, PlayerCamera, MovementVectorBlend, TurnRotationBlend, _characterInput, _characterMover); }
public int read() { if (charInput != null) { int c = charInput.read(); if (c >= 0) { return(c); } charInput = null; } if (buffer != null) { if (pos < buffer.Length) { return(buffer[pos++]); } buffer = null; } return(-1); }
private void Awake() { if (_settings.UseAI) { _brains = GetComponent <StateMachineBrains>(); if (_brains == null) { print("AI character doesn't have a StateMachine component."); } _input = new InputAI(_brains) as ICharacterInput; } else { _input = new InputPlayer() as ICharacterInput; } _movement = new GroundedCharacterMovement(GetComponent <CharacterController>(), _input, transform, _pointOfView, _groundCheck, _settings, _initGravityDirection); }
private int DetectUtf8OrUtf16(int c1) { int mode = this.mode; int c2; if (c1 == 0xff || c1 == 0xfe) { c2 = this.stream.ReadByte(); bool bigEndian = c1 == 0xfe; int otherbyte = bigEndian ? 0xff : 0xfe; if (c2 == otherbyte) { var newReader = new Utf16Reader( this.stream, bigEndian, this.errorThrow); this.reader = newReader; return newReader.ReadChar(); } // Assume UTF-8 here, so the 0xff or 0xfe is invalid if (this.errorThrow) { throw new InvalidOperationException("Invalid Unicode stream"); } else { var utf8reader = new Utf8Reader(this.stream, this.errorThrow); utf8reader.Unget(c2); this.reader = utf8reader; return 0xfffd; } } else if (mode == 1) { if (c1 >= 0x01 && c1 <= 0x7f) { // Nonzero ASCII character c2 = this.stream.ReadByte(); if (c2 == 0) { // NZA 0, so UTF-16LE var newReader = new Utf16Reader( this.stream, false, this.errorThrow); this.reader = newReader; } else { // NZA NZ var utf8reader = new Utf8Reader(this.stream, this.errorThrow); utf8reader.Unget(c2); this.reader = utf8reader; } return c1; } else if (c1 == 0) { // Zero c2 = this.stream.ReadByte(); if (c2 >= 0x01 && c2 <= 0x7f) { // 0 NZA, so UTF-16BE var newReader = new Utf16Reader(this.stream, true, this.errorThrow); this.reader = newReader; return c2; } else { var utf8reader = new Utf8Reader(this.stream, this.errorThrow); utf8reader.Unget(c2); this.reader = utf8reader; return c1; } } } // Use default of UTF-8 return -2; }
/// <include file='../../docs.xml' /// path='docs/doc[@name="M:PeterO.Text.NormalizerInput.IsNormalized(PeterO.Text.ICharacterInput,PeterO.Text.Normalization)"]/*'/> public static bool IsNormalized( ICharacterInput chars, Normalization form) { return NormalizerInput.IsNormalized(chars, form); }
// Detects a Unicode encoding private int DetectUnicodeEncoding() { int mode = this.mode; int c1 = this.stream.ReadByte(); int c2; if (c1 < 0) { return -1; } Utf8Reader utf8reader; if (mode == 0) { // UTF-8 only utf8reader = new Utf8Reader(this.stream, this.errorThrow); this.reader = utf8reader; c1 = utf8reader.ReadChar(); if (c1 == 0xfeff) { // Skip BOM c1 = utf8reader.ReadChar(); } return c1; } else if (mode == 1 || mode == 3) { c2 = this.DetectUtf8OrUtf16(c1); if (c2 >= -1) { return c2; } } else if (mode == 2 || mode == 4) { // UTF-8, UTF-16, or UTF-32 c2 = this.DetectUtf8Or16Or32(c1); if (c2 >= -1) { return c2; } } // Default case: assume UTF-8 utf8reader = new Utf8Reader(this.stream, this.errorThrow); this.reader = utf8reader; utf8reader.Unget(c1); c1 = utf8reader.ReadChar(); if (!this.dontSkipUtf8Bom && c1 == 0xfeff) { // Skip BOM c1 = utf8reader.ReadChar(); } return c1; }
private int DetectUtf8Or16Or32(int c1) { int c2, c3, c4; if (c1 == 0xff || c1 == 0xfe) { // Start of a possible byte-order mark // FF FE 0 0 --> UTF-32LE // FF FE ... --> UTF-16LE // FE FF --> UTF-16BE c2 = this.stream.ReadByte(); bool bigEndian = c1 == 0xfe; int otherbyte = bigEndian ? 0xff : 0xfe; if (c2 == otherbyte) { c3 = this.stream.ReadByte(); c4 = this.stream.ReadByte(); if (!bigEndian && c3 == 0 && c4 == 0) { this.reader = new Utf32Reader(this.stream, false, this.errorThrow); return this.reader.ReadChar(); } else { var newReader = new Utf16Reader( this.stream, bigEndian, this.errorThrow); newReader.Unget(c3, c4); this.reader = newReader; return newReader.ReadChar(); } } // Assume UTF-8 here, so the 0xff or 0xfe is invalid if (this.errorThrow) { throw new InvalidOperationException("Invalid Unicode stream"); } else { var utf8reader = new Utf8Reader(this.stream, this.errorThrow); utf8reader.Unget(c2); this.reader = utf8reader; return 0xfffd; } } else if (c1 == 0 && this.mode == 4) { // Here, the relevant cases are: // 0 0 0 NZA --> UTF-32BE (if mode is 4) // 0 0 FE FF --> UTF-32BE // Anything else is treated as UTF-8 c2 = this.stream.ReadByte(); c3 = this.stream.ReadByte(); c4 = this.stream.ReadByte(); if (c2 == 0 && ((c3 == 0xfe && c4 == 0xff) || (c3 == 0 && c4 >= 0x01 && c4 <= 0x7f))) { this.reader = new Utf32Reader(this.stream, true, this.errorThrow); return c3 == 0 ? c4 : this.reader.ReadChar(); } else { var utf8reader = new Utf8Reader(this.stream, this.errorThrow); utf8reader.UngetThree(c2, c3, c4); this.reader = utf8reader; return c1; } } else if (this.mode == 2) { if (c1 >= 0x01 && c1 <= 0x7f) { // Nonzero ASCII character c2 = this.stream.ReadByte(); if (c2 == 0) { // NZA 0, so UTF-16LE or UTF-32LE c3 = this.stream.ReadByte(); c4 = this.stream.ReadByte(); if (c3 == 0 && c4 == 0) { this.reader = new Utf32Reader( this.stream, false, this.errorThrow); return c1; } else { var newReader = new Utf16Reader( this.stream, false, this.errorThrow); newReader.Unget(c3, c4); this.reader = newReader; return c1; } } else { // NZA NZ, so UTF-8 var utf8reader = new Utf8Reader(this.stream, this.errorThrow); utf8reader.Unget(c2); this.reader = utf8reader; return c1; } } else if (c1 == 0) { // Zero c2 = this.stream.ReadByte(); if (c2 >= 0x01 && c2 <= 0x7f) { // 0 NZA, so UTF-16BE var newReader = new Utf16Reader(this.stream, true, this.errorThrow); this.reader = newReader; return c2; } else if (c2 == 0) { // 0 0, so maybe UTF-32BE c3 = this.stream.ReadByte(); c4 = this.stream.ReadByte(); if (c3 == 0 && c4 >= 0x01 && c4 <= 0x7f) { // 0 0 0 NZA this.reader = new Utf32Reader(this.stream, true, this.errorThrow); return c4; } else if (c3 == 0xfe && c4 == 0xff) { // 0 0 FE FF this.reader = new Utf32Reader(this.stream, true, this.errorThrow); return this.reader.ReadChar(); } else { // 0 0 ... var newReader = new Utf8Reader(this.stream, this.errorThrow); newReader.UngetThree(c2, c3, c4); this.reader = newReader; return c1; } } else { // 0 NonAscii, so UTF-8 var utf8reader = new Utf8Reader(this.stream, this.errorThrow); utf8reader.Unget(c2); this.reader = utf8reader; return c1; } } } // Use default of UTF-8 return -2; }
/// <include file='../../docs.xml' /// path='docs/doc[@name="M:PeterO.Text.NormalizingCharacterInput.GetChars(PeterO.Text.ICharacterInput,PeterO.Text.Normalization)"]/*'/> public static IList<int> GetChars(ICharacterInput str, Normalization form) { if (str == null) { throw new ArgumentNullException("str"); } return GetChars(new NormalizingCharacterInput(str, form)); }
/// <include file='../../docs.xml' /// path='docs/doc[@name="M:PeterO.Text.NormalizingCharacterInput.IsNormalized(PeterO.Text.ICharacterInput,PeterO.Text.Normalization)"]/*'/> public static bool IsNormalized(ICharacterInput chars, Normalization form) { if (chars == null) { throw new ArgumentNullException("chars"); } IList<int> list = new List<int>(); var ch = 0; int mask = (form == Normalization.NFC) ? 0xff : 0x7f; var norm = true; while ((ch = chars.ReadChar()) >= 0) { if ((ch & 0x1ff800) == 0xd800) { return false; } if (norm && (ch & mask) != ch) { norm = false; } list.Add(ch); } return norm || IsNormalized(list, form); }
public CharacterInputWithCount(ICharacterInput ci) { this.ci = ci; }
/// <include file='../../docs.xml' /// path='docs/doc[@name="M:PeterO.Text.NormalizerInput.IsNormalized(PeterO.Text.ICharacterInput,PeterO.Text.Normalization)"]/*'/> public static bool IsNormalized( ICharacterInput chars, Normalization form) { if (chars == null) { throw new ArgumentNullException("chars"); } var listIndex = 0; var array = new int[16]; var haveNonQcs = false; while (true) { int c = chars.ReadChar(); if (c < 0) { break; } if ((c & 0x1ff800) == 0xd800) { return false; } bool isQcs = (c >= 0xf0000) ? true : UnicodeDatabase.IsQuickCheckStarter( c, form); if (isQcs) { if (haveNonQcs) { if (!NormalizeAndCheck( array, 0, listIndex, form)) { return false; } } listIndex = 0; haveNonQcs = false; } else { haveNonQcs = true; } if (listIndex >= array.Length) { var newArray = new int[array.Length * 2]; Array.Copy(array, 0, newArray, 0, listIndex); array = newArray; } array[listIndex++] = c; } if (haveNonQcs) { if (!NormalizeAndCheck( array, 0, listIndex, form)) { return false; } } return true; }
/// <include file='../../docs.xml' /// path='docs/doc[@name="M:PeterO.Text.NormalizerInput.#ctor(PeterO.Text.ICharacterInput)"]/*'/> public NormalizerInput( ICharacterInput input) : this(input, Normalization.NFC) { }
public InputAndBuffer(ICharacterInput charInput, int[] buffer, int offset, int length) { this.charInput=charInput; if(length>0){ this.buffer=new int[length]; Array.Copy(buffer,offset,this.buffer,0,length); } else { this.buffer=null; } }
public int read() { if(charInput!=null){ int c=charInput.read(); if(c>=0)return c; charInput=null; } if(buffer!=null){ if(pos<buffer.Length) return buffer[pos++]; buffer=null; } return -1; }
public int read(int[] buf, int offset, int unitCount) { if((buf)==null)throw new ArgumentNullException("buf"); if((offset)<0)throw new ArgumentOutOfRangeException("offset not greater or equal to 0 ("+Convert.ToString(offset,CultureInfo.InvariantCulture)+")"); if((unitCount)<0)throw new ArgumentOutOfRangeException("unitCount not greater or equal to 0 ("+Convert.ToString(unitCount,CultureInfo.InvariantCulture)+")"); if((offset+unitCount)>buf.Length)throw new ArgumentOutOfRangeException("offset+unitCount not less or equal to "+Convert.ToString(buf.Length,CultureInfo.InvariantCulture)+" ("+Convert.ToString(offset+unitCount,CultureInfo.InvariantCulture)+")"); if(unitCount==0)return 0; int count=0; if(charInput!=null){ int c=charInput.read(buf,offset,unitCount); if(c<=0){ charInput=null; } else { offset+=c; unitCount-=c; count+=c; } } if(buffer!=null){ int c=Math.Min(unitCount,this.buffer.Length-pos); if(c>0){ Array.Copy(this.buffer,pos,buf,offset,c); } pos+=c; count+=c; if(c==0){ buffer=null; } } return (count==0) ? -1 : count; }
private int DetectUtf8OrUtf16(int c1) { int mode = this.mode; int c2; if (c1 == 0xff || c1 == 0xfe) { c2 = this.stream.ReadByte(); bool bigEndian = c1 == 0xfe; int otherbyte = bigEndian ? 0xff : 0xfe; if (c2 == otherbyte) { var newReader = new Utf16Reader( this.stream, bigEndian, this.errorThrow); this.reader = newReader; return(newReader.ReadChar()); } // Assume UTF-8 here, so the 0xff or 0xfe is invalid if (this.errorThrow) { throw new InvalidOperationException("Invalid Unicode stream"); } else { var utf8reader = new Utf8Reader(this.stream, this.errorThrow); utf8reader.Unget(c2); this.reader = utf8reader; return(0xfffd); } } else if (mode == 1) { if (c1 >= 0x01 && c1 <= 0x7f) { // Nonzero ASCII character c2 = this.stream.ReadByte(); if (c2 == 0) { // NZA 0, so UTF-16LE var newReader = new Utf16Reader( this.stream, false, this.errorThrow); this.reader = newReader; } else { // NZA NZ var utf8reader = new Utf8Reader(this.stream, this.errorThrow); utf8reader.Unget(c2); this.reader = utf8reader; } return(c1); } else if (c1 == 0) { // Zero c2 = this.stream.ReadByte(); if (c2 >= 0x01 && c2 <= 0x7f) { // 0 NZA, so UTF-16BE var newReader = new Utf16Reader(this.stream, true, this.errorThrow); this.reader = newReader; return(c2); } else { var utf8reader = new Utf8Reader(this.stream, this.errorThrow); utf8reader.Unget(c2); this.reader = utf8reader; return(c1); } } } // Use default of UTF-8 return(-2); }
public StackableCharacterInput(ICharacterInput source) { this.stack.Add(source); }
/// <include file='../../docs.xml' /// path='docs/doc[@name="M:PeterO.Text.NormalizingCharacterInput.#ctor(PeterO.Text.ICharacterInput,PeterO.Text.Normalization)"]/*'/> public NormalizingCharacterInput( ICharacterInput stream, Normalization form) { this.nci = new NormalizerInput(stream, form); }
private static IList<int> GetChars(ICharacterInput input) { var buffer = new int[64]; IList<int> ret = new List<int>(24); var count = 0; while ((count = input.Read(buffer, 0, buffer.Length)) > 0) { for (int i = 0; i < count; ++i) { ret.Add(buffer[i]); } } return ret; }
void Start() { rb = GetComponent <Rigidbody2D>(); input = settings.UseAI ? new EnemyInput() as ICharacterInput : new PlayerInput(); movement = settings.UseAI ? new EnemyMovement() : new PlayerMovement(rb, input, settings) as ICharacterMovement; }
public static IList<int> GetChars( ICharacterInput input, Normalization form) { if (input == null) { throw new ArgumentNullException("input"); } IList<int> ret = new List<int>(); int ch; input = new NormalizingCharacterInput(input, form); while ((ch = input.ReadChar()) >= 0) { ret.Add(ch); } return ret; }