public SpawnObjectsAroundTarget(EncounterRules encounterRules, LogicState state, LookDirection lookDirection, float minDistance, float maxDistance) : base(encounterRules) { this.state = state; this.minDistanceFromTarget = minDistance; this.maxDistanceFromTarget = maxDistance; this.lookDirection = lookDirection; }
// dir 넣기전에 normalize 시킬 것 public virtual void Move(Vector3 dir) { if (acInfo.isAttacking || acInfo.isDashing) { return; } if (dir.x < 0) { lookDir = LookDirection.LookLeft; skel.transform.localScale = Vector3.one * 0.15f; } else if (dir.x > 0) { lookDir = LookDirection.LookRight; skel.transform.localScale = new Vector3(-0.15f, 0.15f, 0.15f); } rigid.velocity = (dir * acInfo.speed); if (nowWeaponInfo.weaponType == WeaponType.BetWeapon) { SetAnimation(0, acInfo.name + "_bet_run", true, 1); } else if (nowWeaponInfo.weaponType == WeaponType.KeyBoardWeapon) { SetAnimation(0, acInfo.name + "_keyboard_run", true, 1); } }
/// <summary> /// /// </summary> protected virtual void Awake() { mRigidBody = this.GetComponent <Rigidbody2D>(); mRender = this.GetComponent <SpriteRenderer>(); mAnimator = this.GetComponent <Animator>(); mLookDir = this.GetComponent <LookDirection>(); }
public void SetLookDirection(LookDirection direction, double? ping = null) { CurrentDirection = direction; if (PreviousDirection == LookDirection.Idle && direction != LookDirection.Idle) { PreviousDirection = direction; // TODO: Send position to all players except him SendPosition(); } // If ping is not null (player want to stay here) else if (ping != null) { // => we set position to a previous position according to message ping double messageLatency = Math.Abs((float)ping - NetTime.Now) * 1000; //Program.Log.Debug("Message latency: " + messagePing + "|NetTime.Now: " + NetTime.Now); var previousPositionIndex = (int)Math.Round(messageLatency / ServerSettings.StorePreviousPlayerPositionTime) - 1; if (previousPositionIndex >= _previousPositions.Count) previousPositionIndex = _previousPositions.Count - 1; //Position = _previousPositions[(_previousPositions.Count - 1) - previousPositionIndex]; _previousPositions.Clear(); //RealMovePlayer((float)messageLatency); SendPosition(false); } }
public static Action <Transform> Rotation(this LookDirection d) { if (d == LookDirection.Forward) { return(LookForward); } else if (d == LookDirection.Backward) { return(LookBackward); } else if (d == LookDirection.Up) { return(LookUp); } else if (d == LookDirection.Down) { return(LookDown); } else if (d == LookDirection.Left) { return(LookLeft); } else if (d == LookDirection.Right) { return(LookRight); } return(LookForward); }
public FindNaoMarkBackup(int markID, NaoConnectionHelper connection, float rotationAmount = DEFAULT_ROTATION_AMOUNT, float maxRotation = DEFAULT_MAX_ROTATION, float headPitchStepAmount = DEFAULT_HEAD_PITCH_STEP_AMOUNT, float headYawStepAmount = DEFAULT_HEAD_YAW_STEP_AMOUNT, float maxHeadYaw = DEFAULT_MAX_HEAD_YAW, LookDirection startLookDirection = LookDirection.Left) { if (!connection.TestConnection(string.Empty)) { throw new ArgumentException("Could not connect to the robot!"); } this._connection = connection; this.RotationAmount = rotationAmount; this.MaxRotation = maxRotation; this.HeadPitchStepAmount = headPitchStepAmount; this.MarkID = markID; this.HeadYawStepAmount = headYawStepAmount; this.MaxHeadYaw = maxHeadYaw; this.StartLookDirection = startLookDirection; // initialize background worker _findMarkWorker = new BackgroundWorker(); _findMarkWorker.DoWork += new DoWorkEventHandler(_findMarkWorker_DoWork); _findMarkWorker.WorkerSupportsCancellation = true; _findMarkWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_findMarkWorker_RunWorkerCompleted); }
public void SetLookDirection(LookDirection direction, double?ping = null) { CurrentDirection = direction; if (PreviousDirection == LookDirection.Idle && direction != LookDirection.Idle) { PreviousDirection = direction; // TODO: Send position to all players except him SendPosition(); } // If ping is not null (player want to stay here) else if (ping != null) { // => we set position to a previous position according to message ping double messageLatency = Math.Abs((float)ping - NetTime.Now) * 1000; //Program.Log.Debug("Message latency: " + messagePing + "|NetTime.Now: " + NetTime.Now); var previousPositionIndex = (int)Math.Round(messageLatency / ServerSettings.StorePreviousPlayerPositionTime) - 1; if (previousPositionIndex >= _previousPositions.Count) { previousPositionIndex = _previousPositions.Count - 1; } //Position = _previousPositions[(_previousPositions.Count - 1) - previousPositionIndex]; _previousPositions.Clear(); //RealMovePlayer((float)messageLatency); SendPosition(false); } }
public void UpdateDirection(Vector3 direction) { LookDirection prevLookDirection = _currentLookDirection; if (direction.y > 0) { _currentLookDirection = _up; } else if (direction.y < 0) { _currentLookDirection = _down; } else if (direction.x > 0) { _currentLookDirection = _right; } else if (direction.x < 0) { _currentLookDirection = _left; } else { _currentLookDirection = _down; } if (prevLookDirection != _currentLookDirection) { _time = 0; } _spriteRenderer.flipX = _currentLookDirection.FlipX; _spriteRenderer.sprite = _currentLookDirection.Update(false); }
public void SetLookDirection(float lookX, float lookZ) { if (Mathf.Abs(lookX) >= Mathf.Abs(lookZ)) { if (lookX > 0) { lookDirection = LookDirection.RIGHT; } else { lookDirection = LookDirection.LEFT; } } else { if (lookZ > 0) { lookDirection = LookDirection.UP; } else { lookDirection = LookDirection.DOWN; } } }
public Soldier() { // Default direction lookDirection = LookDirection.SOUTHEAST; torso = new Torso(); head = new Head(); }
public SuddenDeath(FinalBomber game, Point pos) { _gameRef = game; _hasStarted = false; _suddenDeathShadow = _gameRef.Content.Load<Texture2D>("Graphics/Sprites/suddenDeathShadow"); _suddenDeathWall = _gameRef.Content.Load<Texture2D>("Graphics/Sprites/edgeWall"); _currentPosition = pos; _previousPosition = Point.Zero; _timer = TimeSpan.Zero; _moveTime = TimeSpan.FromSeconds(GameConfiguration.SuddenDeathWallSpeed); _lookDirection = LookDirection.Right; _mapSize = Config.MapSize; //_mapSize = game.GamePlayScreen.World.Levels[game.GamePlayScreen.World.CurrentLevel].Size; _visited = new bool[_mapSize.X, _mapSize.Y]; for (int i = 0; i < _mapSize.X; i++) { _visited[i, 0] = true; _visited[i, _mapSize.Y - 1] = true; } for (int i = 0; i < _mapSize.Y; i++) { _visited[0, i] = true; _visited[_mapSize.X - 1, i] = true; } // Map moving _nextMapPosition = Vector2.Zero; }
public SuddenDeath(FinalBomber game, Point pos) { _gameRef = game; _hasStarted = false; _suddenDeathShadow = _gameRef.Content.Load <Texture2D>("Graphics/Sprites/suddenDeathShadow"); _suddenDeathWall = _gameRef.Content.Load <Texture2D>("Graphics/Sprites/edgeWall"); _currentPosition = pos; _previousPosition = Point.Zero; _timer = TimeSpan.Zero; _moveTime = TimeSpan.FromSeconds(GameConfiguration.SuddenDeathWallSpeed); _lookDirection = LookDirection.Right; _mapSize = Config.MapSize; //_mapSize = game.GamePlayScreen.World.Levels[game.GamePlayScreen.World.CurrentLevel].Size; _visited = new bool[_mapSize.X, _mapSize.Y]; for (int i = 0; i < _mapSize.X; i++) { _visited[i, 0] = true; _visited[i, _mapSize.Y - 1] = true; } for (int i = 0; i < _mapSize.Y; i++) { _visited[0, i] = true; _visited[_mapSize.X - 1, i] = true; } // Map moving _nextMapPosition = Vector2.Zero; }
private void Look(LookDirection direction) { currentCollision.StopLook(); switch (direction) { case LookDirection.Left: spriteRenderer.sprite = listSprites[0]; currentCollision = listCollisions[0]; break; case LookDirection.Right: spriteRenderer.sprite = listSprites[1]; currentCollision = listCollisions[1]; break; case LookDirection.Top: spriteRenderer.sprite = listSprites[2]; currentCollision = listCollisions[2]; break; case LookDirection.Bot: spriteRenderer.sprite = listSprites[3]; currentCollision = listCollisions[3]; break; } currentCollision.StartLook(); }
private void LateUpdate() { if (!CEditorManager.Instance.EditorInput.LeftButton) { Vector2 position = CEditorManager.Instance.EditorInput.LeftStick.normalized; Vector2 rotation = CEditorManager.Instance.EditorInput.RightStick.normalized; float upMovement = CEditorManager.Instance.EditorInput.RightTrigger; float downMovement = CEditorManager.Instance.EditorInput.LeftTrigger; Vector3 forward = Vector3.Scale(transform.forward, new Vector3(1f, 0f, 1f)).normalized *position.y; Vector3 right = Vector3.Scale(transform.right, new Vector3(1f, 0f, 1f)).normalized *position.x; Vector3 up = Vector3.up * (upMovement - downMovement); if (!CEditorManager.Instance.EditorInput.LeftStickPress) { forward = transform.forward.normalized * position.y; right = transform.right * position.x; up = transform.up * (upMovement - downMovement); } transform.position += (forward + right + up).normalized * movementSpeed * Time.deltaTime; transform.Rotate(0f, rotation.x * rotationSpeed * Time.deltaTime, 0f, Space.World); transform.Rotate(-rotation.y * rotationSpeed * Time.deltaTime, 0f, 0f, Space.Self); } float y = transform.rotation.eulerAngles.y; LookingAt = (y >= 315) ? LookDirection.North : (y >= 225 ? LookDirection.West : (y >= 135 ? LookDirection.South : (y >= 45 ? LookDirection.East : LookDirection.North))); }
void ReceiveMovePlayer(Client client, LookDirection movement, double?ping = null) { // Receives the player's current direction if (client.Player.IsAlive) { client.Player.SetLookDirection(movement, ping); } }
public SpawnObjectsAroundTarget(EncounterRules encounterRules, List <string> objectKeys, string orientationTargetKey, LookDirection lookDirection, float minDistance, float maxDistance) : base(encounterRules) { this.objectKeys = objectKeys; this.defaultOrientationTargetKey = orientationTargetKey; this.minDistanceFromTarget = minDistance; this.maxDistanceFromTarget = maxDistance; this.lookDirection = lookDirection; }
public void Move(LookDirection dir) { Point3DAnimation anim = new Point3DAnimation(Position + GetMoveVector(dir), new System.Windows.Duration(TimeSpan.FromMilliseconds(GlobalSettingsManager.Global.TurnSpeed))); anim.Completed += Anim_Completed; IsAnimated = true; BeginAnimation(PerspectiveCamera.PositionProperty, anim); }
public SpawnObjectsAroundTarget(EncounterRules encounterRules, string objectKey, string orientationTargetKey, LookDirection lookDirection) : base(encounterRules) { this.objectKeys = new List <string> { objectKey }; this.defaultOrientationTargetKey = orientationTargetKey; this.lookDirection = lookDirection; }
private void SetDirection(LookDirection direction) { if (_lookDirection != direction) { _lookDirection = direction; SwitchSpriteDirection(); } }
public PlayerCamera(int entryX, int entryY, LookDirection lookDir, float tileSize) : base() { _tileSize = tileSize; _playerHeight = 3; Position = new System.Windows.Media.Media3D.Point3D(entryX + _tileSize / 2, _playerHeight, entryY + _tileSize / 2); LookDirection = GetLookDirectionVector(lookDir); CurrentLookDirection = lookDir; }
public SpawnLanceMembersAroundTarget(EncounterRules encounterRules, string lanceKey, string orientationTargetKey, string lookTargetKey, LookDirection lookDirection, float minDistance, float maxDistance) : base(encounterRules) { this.lanceKey = lanceKey; this.orientationTargetKey = orientationTargetKey; this.lookTargetKey = lookTargetKey; this.lookDirection = lookDirection; minDistanceFromTarget = minDistance; maxDistanceFromTarget = maxDistance; }
/// <summary> /// 追跡状態でないときのランダムな移動 /// </summary> private void RandomMove() { //次に進む方向を選ぶための乱数 int random = Random.Range(0, 4); Debug.Log(random); switch (random) { case 0: //上に移動 if (MoveCheck(Direction.Top)) { m_LookDirection = LookDirection.UP; m_MoveAnimationFlag = true; ArrayPosMove(0, -m_MoveBlockAmount); m_IsMove = false; } break; case 1: //下に移動 if (MoveCheck(Direction.Bottom)) { m_LookDirection = LookDirection.DOWN; m_MoveAnimationFlag = true; ArrayPosMove(0, m_MoveBlockAmount); m_IsMove = false; } break; case 2: //左に移動 if (MoveCheck(Direction.Left)) { m_LookDirection = LookDirection.LEFT; m_MoveAnimationFlag = true; ArrayPosMove(-m_MoveBlockAmount, 0); m_IsMove = false; } break; case 3: //右に移動 if (MoveCheck(Direction.Right)) { m_LookDirection = LookDirection.RIGHT; m_MoveAnimationFlag = true; ArrayPosMove(m_MoveBlockAmount, 0); m_IsMove = false; } break; } }
public SpawnLanceMembersAroundTarget(EncounterRules encounterRules, string lanceKey, string orientationTargetKey, string lookTargetKey, LookDirection lookDirection, float mustBeBeyondDistance, float mustBeWithinDistance) : base(encounterRules) { this.lanceKey = lanceKey; this.orientationTargetKey = orientationTargetKey; this.lookTargetKey = lookTargetKey; this.lookDirection = lookDirection; this.mustBeBeyondDistance = mustBeBeyondDistance; this.mustBeWithinDistance = mustBeWithinDistance; }
void Update() { if (EnemyStates._states == States.Chasing) { ChangeLookDirection(); _lookDirection = LookDirection.None; } FollowPlayerTarget(); }
public FindNaoMarkBackup(int markID, string robotIP, int robotPort, float rotationAmount = DEFAULT_ROTATION_AMOUNT, float maxRotation = DEFAULT_MAX_ROTATION, float headPitchStepAmount = DEFAULT_HEAD_PITCH_STEP_AMOUNT, float headYawStepAmount = DEFAULT_HEAD_YAW_STEP_AMOUNT, float maxHeadYaw = DEFAULT_MAX_HEAD_YAW, LookDirection startLookDirection = LookDirection.Left) : this(markID, new NaoConnectionHelper(robotIP, robotPort), rotationAmount, maxRotation, headPitchStepAmount, headYawStepAmount, maxHeadYaw, startLookDirection) { }
public void Turn(LookDirection dir) { CurrentLookDirection = dir; var anim = new Vector3DAnimation(GetLookDirectionVector(dir), new System.Windows.Duration(TimeSpan.FromMilliseconds(GlobalSettingsManager.Global.TurnSpeed))); anim.Completed += Anim_Completed; IsAnimated = true; BeginAnimation(PerspectiveCamera.PositionProperty, anim); }
private void Update() { if (moveFlag) { if (!moveOnce) { //特殊行動 StartCoroutine(UniqueAct()); moveOnce = true; } //速度が0じゃないなら if (state[Id].MoveSpeed != 0) { //ダメージ待機じゃないなら if (!damageWaitFlag) { //プレイヤーの位置で方向転換 if (transform.position.x <= player.transform.position.x) { lookDirection = LookDirection.Right; } else { lookDirection = LookDirection.Left; } //方向によって移動 switch (lookDirection) { case LookDirection.Left: transform.eulerAngles = Vector3.zero; transform.position += Vector3.left * state[Id].MoveSpeed * Time.fixedDeltaTime * TimeSlowModule.Instance.GetTimeScale(); break; case LookDirection.Right: transform.eulerAngles = new Vector3(0, 180, 0); transform.position += Vector3.right * state[Id].MoveSpeed * Time.fixedDeltaTime * TimeSlowModule.Instance.GetTimeScale(); break; } } } if (damageWaitFlag && damageWaitCoroutine == null) { damageWaitCoroutine = StartCoroutine(DamageWait(damageWaitTime)); } } //hpゲージにhpを適用 hpGauge.value = state[Id].Hp / state[Id].MaxHp; }
/// <summary> /// Flip the spine skeleton if needed /// </summary> /// <param name="xSpeed"></param> private void SetFlip(float xSpeed) { if (xSpeed < -0.01f && _lookDirection == LookDirection.Right) { _components.skeletonMecanim.skeleton.ScaleX = -1f; _lookDirection = LookDirection.Left; } else if (xSpeed > 0.01f && _lookDirection == LookDirection.Left) { _components.skeletonMecanim.skeleton.ScaleX = 1f; _lookDirection = LookDirection.Right; } }
/// <summary> /// /// </summary> private void SpawnShot() { float offsetX = mLookDir.LookLeft ? -0.5f : 0.5f; float offsetY = (this.State == ePlayerState.Crouch) ? 0.75f : 1.6f; Vector3 offset = new Vector3(offsetX, offsetY, 0); GameObject newObj = GameObject.Instantiate(this.PrefabShot, this.transform.position + offset, Quaternion.identity); LookDirection dir = newObj.GetComponent <LookDirection>(); dir.LookLeft = this.mLookDir.LookLeft; PlayerShot pShot = newObj.GetComponent <PlayerShot>(); pShot.ShotType = this.CurrentWeapon; mShots.Add(pShot); }
/// <summary> /// 水平方向の移動(ラジオ) /// </summary> private void RadioHorizontalMove() { //水平方向の右側に傾いているかどうか if (m_InputHorizontal >= 0) { //右回りに方向転換 switch (m_LookDirection) { case LookDirection.UP: m_LookDirection = LookDirection.RIGHT; break; case LookDirection.RIGHT: m_LookDirection = LookDirection.DOWN; break; case LookDirection.DOWN: m_LookDirection = LookDirection.LEFT; break; case LookDirection.LEFT: m_LookDirection = LookDirection.UP; break; } } else { //左回りに方向転換 switch (m_LookDirection) { case LookDirection.UP: m_LookDirection = LookDirection.LEFT; break; case LookDirection.LEFT: m_LookDirection = LookDirection.DOWN; break; case LookDirection.DOWN: m_LookDirection = LookDirection.RIGHT; break; case LookDirection.RIGHT: m_LookDirection = LookDirection.UP; break; } } m_InputReturnWaitFlag = true; }
private void BodyRotation() { Quaternion save = flashlight.transform.rotation; float speed = 0.1f; if (lMovement.z > 0 && isChangingSpatialLine) { modelTransform.rotation = Quaternion.Slerp(modelTransform.rotation, Quaternion.Euler(new Vector3(0, 0, 0)), speed); inverse = 1; currentLookDirection = LookDirection.Front; } else if (lMovement.z < 0 && isChangingSpatialLine) { modelTransform.rotation = Quaternion.Slerp(modelTransform.rotation, Quaternion.Euler(new Vector3(0, 180, 0)), speed); inverse = -1; currentLookDirection = LookDirection.Back; } else { if ((lookAtPos.x - transform.position.x > -bodyRotationDeadZone) || (currentLookDirection == LookDirection.Left && lookAtPos.x - transform.position.x > bodyRotationDeadZone)) { modelTransform.rotation = Quaternion.Slerp(modelTransform.rotation, Quaternion.Euler(new Vector3(0, 89, 0)), speed / 2.0f); currentLookDirection = LookDirection.Right; if (hMove > 0) { inverse = 1; } else { inverse = -1; } } else { modelTransform.rotation = Quaternion.Slerp(modelTransform.rotation, Quaternion.Euler(new Vector3(0, 271, 0)), speed / 2.0f); currentLookDirection = LookDirection.Left; if (hMove < 0) { inverse = 1; } else { inverse = -1; } } } flashlight.transform.rotation = save; animator.SetFloat("Inverse", inverse); }
void Update() { rig.velocity = Vector3.zero; // Controla o deslocamento if (canMove) { LookDirection direction = LookDirection.Front; if (Input.GetAxis("Vertical") > 0.1) { Move(new Vector3(0, velocity * Time.deltaTime, 0)); } else if (Input.GetAxis("Vertical") < -0.1) { Move(new Vector3(0, -1 * velocity * Time.deltaTime, 0)); } if (Input.GetAxis("Horizontal") > 0.1) { direction = LookDirection.Right; Move(new Vector3(-1 * velocity * Time.deltaTime, 0, 0)); } else if (Input.GetAxis("Horizontal") < -0.1) { direction = LookDirection.Left; Move(new Vector3(velocity * Time.deltaTime, 0, 0)); } Look(direction); if (Input.GetButtonDown("Interact")) { if (carrying) { Drop(); } else if (nextToPickable) { Pick(); } } } if (Input.GetButtonDown("Cancel")) { Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name); } }
/// <summary> /// Initialize a new instance of <see cref="Player" />. /// </summary> /// <param name="entityId">The Entity ID of this player.</param> /// <param name="name">Name of the player.</param> /// <param name="skin">The player skin.</param> /// <param name="position">World position of the player (X,Y,Z).</param> /// <param name="direction">The direction the player is looking in (Yaw, Pitch).</param> /// <param name="stance">The stance of the player.</param> public Player(int entityId, string name, Texture2D skin = null, Position position = null, LookDirection direction = null, double stance = 0.0) : base(entityId) { Name = name; _skin = new Skin(skin); Position = position ?? new Position(); Direction = direction ?? new LookDirection(); Stance = stance; if (_skin.GetTexture() == null) return; if (_skin.GetTexture().Width != SkinWidth || _skin.GetTexture().Height != SkinHeight) { // Set the skin to default player skin (Steve) } }
void ReceiveMovePlayer(Client client, LookDirection movement, double? ping = null) { // Receives the player's current direction if (client.Player.IsAlive) client.Player.SetLookDirection(movement, ping); }
public void ChangeDirection(LookDirection lD, int playerId) { Point pos = Point.Zero; switch (lD) { case LookDirection.Up: pos = new Point(CellPosition.X, CellPosition.Y - 1); break; case LookDirection.Down: pos = new Point(CellPosition.X, CellPosition.Y + 1); break; case LookDirection.Left: pos = new Point(CellPosition.X - 1, CellPosition.Y); break; case LookDirection.Right: pos = new Point(CellPosition.X + 1, CellPosition.Y); break; } if (!CollisionLayer[pos.X, pos.Y]) { CurrentDirection = lD; _lastPlayerThatPushIt = playerId; foreach (Point p in ActionField) { HazardMap[p.X, p.Y] = 0; } } else CurrentDirection = LookDirection.Idle; }
/// <summary> /// Set the direction in which this player is heading. /// </summary> /// <param name="direction"><see cref="Direction" /> object defining the direction.</param> public void SetDirection(LookDirection direction) { Direction = direction; }
protected DynamicEntity() { PreviousCellPosition = Point.Zero; CurrentDirection = LookDirection.Idle; PreviousDirection = CurrentDirection; }
void Update() { if (gameManager.Playing) { if (automating) { timer += Time.deltaTime; Timed(); shoulderCamera.gameObject.transform.rotation = Quaternion.RotateTowards(shoulderCamera.transform.rotation, Quaternion.Euler(look), Time.deltaTime * lerpScale); Blink(); } else { ResetAlphas(); if (gameManager.timer > UserContainer.Instance.time * 0.75f) { Blink(); direction = LookDirection.CENTER; gameManager.message = Languages.Instance.GetTranslation("SESSION ENDS SOON"); shoulderCamera.enabled = false; } else if (gameManager.timer > UserContainer.Instance.time * 0.25f) { shoulderCamera.enabled = true; automating = true; timer = 0; } else { Blink(); direction = LookDirection.TOP; } } } }
private void Focused() { if (timer > UserContainer.Instance.time * 0.2f) { ResetAlphas(); timer = 0.0f; alphaTimer = 0.0f; appear = true; relativeRightVolume = ((RightHandBehaviour)gameManager.rightHand).RelativeLowerVolume + ((RightHandBehaviour)gameManager.rightHand).RelativeMiddleVolume + ((RightHandBehaviour)gameManager.rightHand).RelativeUpperVolume; relativeLeftVolume = ((LeftHandBehaviour)gameManager.leftHand).RelativeLowerVolume + ((LeftHandBehaviour)gameManager.leftHand).RelativeMiddleVolume + ((LeftHandBehaviour)gameManager.leftHand).RelativeUpperVolume; if (relativeRightVolume == 0) { shoulderCamera.enabled = true; gameManager.message = Languages.Instance.GetTranslation("FOCUS ON YOUR RIGHT HAND"); look = lookRight; direction = LookDirection.RIGHT; } else if (relativeLeftVolume == 0) { shoulderCamera.enabled = true; gameManager.message = Languages.Instance.GetTranslation("FOCUS ON YOUR LEFT HAND"); look = lookLeft; direction = LookDirection.LEFT; } else if (relativeLeftVolume < relativeRightVolume) { shoulderCamera.enabled = true; gameManager.message = Languages.Instance.GetTranslation("FOCUS ON YOUR LEFT HAND"); look = lookLeft; direction = LookDirection.LEFT; } else { shoulderCamera.enabled = true; gameManager.message = Languages.Instance.GetTranslation("FOCUS ON YOUR RIGHT HAND"); look = lookRight; direction = LookDirection.RIGHT; } } if (gameManager.timer > UserContainer.Instance.time * 0.75f) { automating = false; direction = LookDirection.CENTER; } }
protected BaseArrow(Point cellPosition, LookDirection lookDirection) : base(cellPosition) { Direction = lookDirection; }
private void Timed() { if (gameManager.timer < UserContainer.Instance.time * 0.5f) { look = lookLeft; direction = LookDirection.LEFT; gameManager.message = Languages.Instance.GetTranslation("FOCUS ON YOUR LEFT HAND"); } else if (gameManager.timer < UserContainer.Instance.time * 0.75f) { look = lookRight; direction = LookDirection.RIGHT; gameManager.message = Languages.Instance.GetTranslation("FOCUS ON YOUR RIGHT HAND"); } else { automating = false; } }
private AnimationKey LookDirectionToAnimationKey(LookDirection lookDirection) { var animationKey = AnimationKey.Up; switch (lookDirection) { case LookDirection.Up: animationKey = AnimationKey.Up; break; case LookDirection.Down: animationKey = AnimationKey.Down; break; case LookDirection.Right: animationKey = AnimationKey.Right; break; case LookDirection.Left: animationKey = AnimationKey.Left; break; } return animationKey; }
private void CreateWorld() { var tilesets = new List<Tileset>() { new Tileset(_mapTexture, 64, 32, 32, 32) }; var collisionLayer = new bool[Config.MapSize.X, Config.MapSize.Y]; var mapPlayersPosition = new int[Config.MapSize.X, Config.MapSize.Y]; var map = new IEntity[Config.MapSize.X, Config.MapSize.Y]; var layer = new MapLayer(Config.MapSize.X, Config.MapSize.Y); var voidPosition = new List<Point>(); // Item Map IEntity entity; // List of player position var playerPositions = new Dictionary<int, Point>(); // We don't put wall around the players for (int i = 0; i < Config.PlayersNumber; i++) { Point playerPosition = Config.PlayersPositions[i]; playerPositions[i + 1] = playerPosition; mapPlayersPosition[playerPosition.X, playerPosition.Y] = 2; mapPlayersPosition[playerPosition.X + 1, playerPosition.Y] = 1; mapPlayersPosition[playerPosition.X, playerPosition.Y + 1] = 1; mapPlayersPosition[playerPosition.X, playerPosition.Y - 1] = 1; mapPlayersPosition[playerPosition.X - 1, playerPosition.Y] = 1; mapPlayersPosition[playerPosition.X - 1, playerPosition.Y - 1] = 1; mapPlayersPosition[playerPosition.X - 1, playerPosition.Y + 1] = 1; mapPlayersPosition[playerPosition.X + 1, playerPosition.Y - 1] = 1; mapPlayersPosition[playerPosition.X + 1, playerPosition.Y + 1] = 1; } /* entity = new Teleporter(FinalBomber.Instance, new Vector2( 5 * Engine.TileWidth, 1 * Engine.TileHeight)); teleporterList.Add((Teleporter)entity); map[5,1] = entity; entity = new Teleporter(FinalBomber.Instance, new Vector2( 10 * Engine.TileWidth, 1 * Engine.TileHeight)); teleporterList.Add((Teleporter)entity); map[10, 1] = entity; */ for (int x = 0; x < Config.MapSize.X; x++) { for (int y = 0; y < Config.MapSize.Y; y++) { if (!(x == 0 || y == 0 || x == (Config.MapSize.X - 1) || y == (Config.MapSize.Y - 1) || (x % 2 == 0 && y % 2 == 0)) && (mapPlayersPosition[x, y] != 1 && mapPlayersPosition[x, y] != 2)) voidPosition.Add(new Point(x, y)); } } #region Teleporter if (Config.ActiveTeleporters) { if (Config.TeleporterPositionType == TeleporterPositionTypeEnum.Randomly) { int randomVoid = 0; for (int i = 0; i < MathHelper.Clamp(Config.TeleporterNumber, 0, voidPosition.Count - 1); i++) { randomVoid = Random.Next(voidPosition.Count); entity = new Teleporter(new Point( voidPosition[randomVoid].X, voidPosition[randomVoid].Y)); TeleporterList.Add((Teleporter)entity); map[voidPosition[randomVoid].X, voidPosition[randomVoid].Y] = entity; voidPosition.Remove(voidPosition[randomVoid]); } } else if (Config.TeleporterPositionType == TeleporterPositionTypeEnum.PlusForm) { var teleporterPositions = new Point[] { new Point((int)Math.Ceiling((double)(Config.MapSize.X - 2)/(double)2), 1), new Point(1, (int)Math.Ceiling((double)(Config.MapSize.Y - 2)/(double)2)), new Point((int)Math.Ceiling((double)(Config.MapSize.X - 2)/(double)2), Config.MapSize.Y - 2), new Point(Config.MapSize.X - 2, (int)Math.Ceiling((double)(Config.MapSize.Y - 2)/(double)2)) }; for (int i = 0; i < teleporterPositions.Length; i++) { entity = new Teleporter(new Point( teleporterPositions[i].X, teleporterPositions[i].Y)); TeleporterList.Add((Teleporter)entity); map[teleporterPositions[i].X, teleporterPositions[i].Y] = entity; } } } #endregion #region Arrow if (Config.ActiveArrows) { if (Config.ArrowPositionType == ArrowPositionTypeEnum.Randomly) { var lookDirectionArray = new LookDirection[] { LookDirection.Up, LookDirection.Down, LookDirection.Left, LookDirection.Right }; for (int i = 0; i < MathHelper.Clamp(Config.ArrowNumber, 0, voidPosition.Count - 1); i++) { int randomVoid = Random.Next(voidPosition.Count); entity = new Arrow(new Point( voidPosition[randomVoid].X, voidPosition[randomVoid].Y), lookDirectionArray[Random.Next(lookDirectionArray.Length)]); ArrowList.Add((Arrow)entity); map[voidPosition[randomVoid].X, voidPosition[randomVoid].Y] = entity; voidPosition.Remove(voidPosition[randomVoid]); } } else if (Config.ArrowPositionType == ArrowPositionTypeEnum.SquareForm) { int outsideArrowsLag = 0; var ratio = (int)Math.Ceiling((double)(4 * (Config.MapSize.X - 2)) / (double)5); if (ratio % 2 == 0) outsideArrowsLag = 1; var arrowPositions = new Point[] { // ~~ Inside ~~ // // Top left new Point( (int)Math.Ceiling((double)(Config.MapSize.X - 2)/(double)4) + 1, (int)Math.Ceiling((double)(Config.MapSize.Y - 2)/(double)4) + 1), // Top right new Point( (int)Math.Ceiling((double)(3 * (Config.MapSize.X - 2))/(double)4) - 1, (int)Math.Ceiling((double)(Config.MapSize.Y - 2)/(double)4) + 1), // Bottom left new Point( (int)Math.Ceiling((double)(Config.MapSize.X - 2)/(double)4) + 1, (int)Math.Ceiling((double)(3 * (Config.MapSize.Y - 2))/(double)4) - 1), // Bottom right new Point( (int)Math.Ceiling((double)(3 * (Config.MapSize.X - 2))/(double)4) - 1, (int)Math.Ceiling((double)(3 * (Config.MapSize.Y - 2))/(double)4) - 1), // ~~ Outside ~~ // // Top left new Point( (int)Math.Ceiling((double)(Config.MapSize.X - 2)/(double)5), (int)Math.Ceiling((double)(Config.MapSize.Y - 2)/(double)5)), // Top right new Point( (int)Math.Ceiling((double)(4 * (Config.MapSize.X - 2))/(double)5) + outsideArrowsLag, (int)Math.Ceiling((double)(Config.MapSize.Y - 2)/(double)5)), // Bottom left new Point( (int)Math.Ceiling((double)(Config.MapSize.X - 2)/(double)5), (int)Math.Ceiling((double)(4 * (Config.MapSize.Y - 2))/(double)5) + outsideArrowsLag), // Bottom right new Point( (int)Math.Ceiling((double)(4 * (Config.MapSize.X - 2))/(double)5 + outsideArrowsLag), (int)Math.Ceiling((double)(4 * (Config.MapSize.Y - 2))/(double)5) + outsideArrowsLag) }; for (int i = 0; i < arrowPositions.Length; i++) { entity = new Arrow(new Point( arrowPositions[i].X, arrowPositions[i].Y), Config.ArrowLookDirection[i % 4]); ArrowList.Add((Arrow)entity); map[arrowPositions[i].X, arrowPositions[i].Y] = entity; } } } #endregion int counter = 0; for (int x = 0; x < Config.MapSize.X; x++) { for (int y = 0; y < Config.MapSize.Y; y++) { var tile = new Tile(0, 0); if (x == 0 || y == 0 || x == (Config.MapSize.X - 1) || y == (Config.MapSize.Y - 1) || (x % 2 == 0 && y % 2 == 0)) { // Inside wallList if ((x % 2 == 0 && y % 2 == 0 && !(x == 0 || y == 0 || x == (Config.MapSize.X - 1) || y == (Config.MapSize.Y - 1))) && mapPlayersPosition[x, y] != 2) { entity = new UnbreakableWall(new Point(x, y)); this.UnbreakableWallList.Add((UnbreakableWall)entity); map[x, y] = entity; collisionLayer[x, y] = true; } // Outside wallList else if (mapPlayersPosition[x, y] != 2) { entity = new EdgeWall(new Point(x, y)); this._edgeWallList.Add((EdgeWall)entity); counter++; map[x, y] = entity; collisionLayer[x, y] = true; } } else { // Wall if ((mapPlayersPosition[x, y] != 1 && mapPlayersPosition[x, y] != 2) && map[x, y] == null && Random.Next(0, 100) < GameConfiguration.WallPercentage) { collisionLayer[x, y] = true; entity = new Wall(new Point(x, y)); _wallList.Add((Wall)entity); map[x, y] = entity; } //tile = new Tile(0, 0); } layer.SetTile(x, y, tile); } } var mapLayers = new List<MapLayer> { layer }; var tileMap = new TileMap(tilesets, mapLayers); Map level = null;//new Map(Config.MapSize, tileMap, map, collisionLayer); World = new World(FinalBomber.Instance, FinalBomber.Instance.ScreenRectangle); World.Levels.Add(level); World.CurrentLevel = 0; foreach (int playerID in playerPositions.Keys) { if (Config.AIPlayers[playerID - 1]) { var player = new AIPlayer(Math.Abs(playerID)); PlayerList.Add(player); map[playerPositions[playerID].X, playerPositions[playerID].Y] = player; } else { var player = new HumanPlayer(Math.Abs(playerID), playerID); PlayerList.Add(player); map[playerPositions[playerID].X, playerPositions[playerID].Y] = player; } } }
public override void Update(GameTime aTime) { updateHunger(); updateAllNearby(); switch(_eMyState) { case State.Dead: if (ParentFlock != null) { // I was flocking, now I'm dead, remove me from the flock. ParentFlock.RemovePerson(this); } if (EatingObject != null) Debug.Assert(true); // WTF!? MyMood = getMood(); break; case State.Eating: _Velocity = Vector2.Zero; if (EatingObject != null && !EatingObject.Eat(aTime)) { EatingObject.StopEating(this); EatingObject = null; _eMyState = State.Alone; } MyMood = getMood(); break; case State.Flocking: const float c_fForceSensitivity = .4f; const float c_fCalmingForce = 100.0f; const float c_fHungerFactor = 100.0f; const float c_fExplosionTollerange = 250.0f; const float c_fExplositionForceMul = 100.0f; if (EatingObject != null) { EatingObject.StopEating(this); EatingObject = null; } AccumulateForces(); Location = Location + (_Velocity * (float)aTime.ElapsedGameTime.TotalSeconds); Vector2 moving; switch (ParentFlock.FlockState) { case PersonFlock.State.Held: // Look in the direction we're being dragged. moving = Location - ParentFlock.Location; MyLook = moving.X < 0 ? LookDirection.Right : LookDirection.Left; break; case PersonFlock.State.Eating: // Look at what we're eating moving = Location - ParentFlock.EatingObject.Location; MyLook = moving.X < 0 ? LookDirection.Right : LookDirection.Left; break; } // When you're flocking, you're sensitive to other people. // Use the avoidance force as a basis _fSensitivity += _Forces[2].Length() * c_fForceSensitivity; // Reduce sensitivity depending on the number of people in my flock float dec = (1.0f / (float)(ParentFlock.Count + _Hunger / c_fHungerFactor)) * c_fCalmingForce; _fSensitivity -= dec; if (_fSensitivity < 0) _fSensitivity = 0.0f; Mood myOldMood = MyMood; MyMood = getMood(); if(myOldMood != MyMood && MyMood == Mood.Angry) SoundState.Instance.PlayAngrySound(this, aTime); if (_fSensitivity > c_fExplosionTollerange) { // EXPLODE! ParentFlock.AddExtenralForce(new ExternalForce(this.Location, ParentFlock.Count * c_fExplositionForceMul, 3.0f, 120)); ParentFlock.RemovePerson(this); SoundState.Instance.PlayExplosionSound(aTime); MyMood = Mood.Surprise; _eMyState = State.Alone; } break; case State.Alone: _fSensitivity = 0.0f; AccumulateForces(); if (_iNextThink <= 0) { _iNextThink = c_iThinkTime + RandomInstance.Instance.Next(-c_iRandDelay, c_iRandDelay); _eMyAloneState = (AloneState)RandomInstance.Instance.Next(0, 3); } else _iNextThink -= aTime.ElapsedGameTime.Milliseconds; switch (_eMyAloneState) { case AloneState.StandingStill: _WalkVelocity = Vector2.Zero; MyMood = getMood(); break; case AloneState.Looking: if (_iNextLook <= 0) { _iNextLook = c_iLookTime + RandomInstance.Instance.Next(-c_iLookDelay, c_iLookDelay); MyLook = MyLook == LookDirection.Left ? LookDirection.Right : LookDirection.Left; } else _iNextLook -= aTime.ElapsedGameTime.Milliseconds; _WalkVelocity = Vector2.Zero; MyMood = getMood(); break; case AloneState.Wandering: if (_WalkVelocity == Vector2.Zero) { _WalkVelocity = new Vector2(RandomInstance.Instance.Next(-100, 100) / 100.0f, RandomInstance.Instance.Next(-100, 100) / 100.0f); _WalkVelocity.Normalize(); if (_WalkVelocity.X < 0) MyLook = LookDirection.Left; else MyLook = LookDirection.Right; _WalkVelocity *= c_fSpeed; } _Velocity += _WalkVelocity; Location = Location + (_Velocity * (float)aTime.ElapsedGameTime.TotalSeconds); if (Location.X < _Bounds.X || Location.X > _Bounds.X + _Bounds.Width) { _WalkVelocity.X = -_WalkVelocity.X; MyLook = MyLook == LookDirection.Left ? LookDirection.Right : LookDirection.Left; } if (Location.Y < _Bounds.Y || Location.Y > _Bounds.Y + _Bounds.Height) _WalkVelocity.Y = -_WalkVelocity.Y; MyMood = getMood(); break; } startEatingIfPossible(); break; case State.Held: MyHoverMood = getMood(); if (_NearbyFoodSources.Count > 0) { // Look at what you want to eat. Vector2 lookDirection = Location - _NearbyFoodSources.Peek().Location; MyLook = lookDirection.X < 0 ? LookDirection.Right : LookDirection.Left; } break; } }
//! Add new orientation. public void Add(LookDirection Direction, UnitSpriteAnimationOrientationDescription AnimationDesc) { orienatations[Direction] = AnimationDesc; }
public void Update(GameTime gameTime) { _timer += gameTime.ElapsedGameTime; if (!_hasStarted && _timer >= GameConfiguration.SuddenDeathTimer) { MediaPlayer.Play(_gameRef.GamePlayScreen.MapSongHurry); _hasStarted = true; _timer = TimeSpan.Zero; } if (_hasStarted) { #region Walls // We change sudden death's wall position if (_timer >= _moveTime) { if (!AllVisited()) { _visited[_currentPosition.X, _currentPosition.Y] = true; IEntity entity = _gameRef.GamePlayScreen.World.Levels[_gameRef.GamePlayScreen.World.CurrentLevel]. Board[_currentPosition.X, _currentPosition.Y]; if (entity != null) { if (entity is Player) { entity.Destroy(); List<Player> pl = _gameRef.GamePlayScreen.PlayerList.FindAll( p => p.CellPosition == _currentPosition); foreach (Player p in pl) p.Destroy(); } else if (entity is Teleporter || entity is Arrow || entity is Bomb) { List<Player> pl = _gameRef.GamePlayScreen.PlayerList.FindAll( p => p.CellPosition == _currentPosition); foreach (Player p in pl) p.Destroy(); List<Bomb> bl = _gameRef.GamePlayScreen.BombList.FindAll( b => b.CellPosition == _currentPosition); foreach (Bomb b in bl) b.Remove(); entity.Remove(); } else entity.Remove(); } _gameRef.GamePlayScreen.World.Levels[_gameRef.GamePlayScreen.World.CurrentLevel].CollisionLayer[ _currentPosition.X, _currentPosition.Y] = true; var u = new UnbreakableWall(_currentPosition); _gameRef.GamePlayScreen.World.Levels[_gameRef.GamePlayScreen.World.CurrentLevel].Board[ _currentPosition.X, _currentPosition.Y] = u; _gameRef.GamePlayScreen.UnbreakableWallList.Add(u); _timer = TimeSpan.Zero; _previousPosition = _currentPosition; switch (_lookDirection) { case LookDirection.Up: _currentPosition.Y--; if (!_visited[_currentPosition.X, _currentPosition.Y] && _gameRef.GamePlayScreen.World.Levels[_gameRef.GamePlayScreen.World.CurrentLevel]. Board[_currentPosition.X, _currentPosition.Y] is UnbreakableWall) { _visited[_currentPosition.X, _currentPosition.Y] = true; if (_visited[_currentPosition.X, _currentPosition.Y - 1]) _lookDirection = LookDirection.Right; else _currentPosition.Y--; } if (_visited[_currentPosition.X, _currentPosition.Y - 1]) _lookDirection = LookDirection.Right; break; case LookDirection.Down: _currentPosition.Y++; if (!_visited[_currentPosition.X, _currentPosition.Y] && _gameRef.GamePlayScreen.World.Levels[_gameRef.GamePlayScreen.World.CurrentLevel]. Board[_currentPosition.X, _currentPosition.Y] is UnbreakableWall) { _visited[_currentPosition.X, _currentPosition.Y] = true; if (_visited[_currentPosition.X, _currentPosition.Y + 1]) _lookDirection = LookDirection.Left; else _currentPosition.Y++; } if (_visited[_currentPosition.X, _currentPosition.Y + 1]) _lookDirection = LookDirection.Left; break; case LookDirection.Left: _currentPosition.X--; if (!_visited[_currentPosition.X, _currentPosition.Y] && _gameRef.GamePlayScreen.World.Levels[_gameRef.GamePlayScreen.World.CurrentLevel]. Board[_currentPosition.X, _currentPosition.Y] is UnbreakableWall) { _visited[_currentPosition.X, _currentPosition.Y] = true; if (_visited[_currentPosition.X - 1, _currentPosition.Y]) _lookDirection = LookDirection.Up; else _currentPosition.X--; } if (_visited[_currentPosition.X - 1, _currentPosition.Y]) _lookDirection = LookDirection.Up; break; case LookDirection.Right: _currentPosition.X++; if (!_visited[_currentPosition.X, _currentPosition.Y] && _gameRef.GamePlayScreen.World.Levels[_gameRef.GamePlayScreen.World.CurrentLevel]. Board[_currentPosition.X, _currentPosition.Y] is UnbreakableWall) { _visited[_currentPosition.X, _currentPosition.Y] = true; if (_visited[_currentPosition.X + 1, _currentPosition.Y]) _lookDirection = LookDirection.Down; else _currentPosition.X++; } if (_visited[_currentPosition.X + 1, _currentPosition.Y]) _lookDirection = LookDirection.Down; break; } } // Move the map //Engine.Origin = NextMapPosition(); } #endregion } }
public Arrow(Point position, LookDirection initialLookDirection) { _isAlive = true; _lookDirection = initialLookDirection; }
//! Get the direction and angle for given LookAts. /*! If bool is true, right direction is used. Otherwise left. */ public static Quaternion DirectionToRotation(LookDirection To) { return Quaternion.AngleAxis((byte)To * 45, Vector3.up); }