/// <summary> /// Moves the <see cref="Pedestrian"/> depending on the <paramref name="moveBehaviour"/> that is passed. /// </summary> /// <param name="moveBehaviour">The <see cref="MoveBehaviour"/> that is passed.</param> /// <remarks>If the <see cref="MoveBehaviour"/> is <see cref="MoveBehaviour.ACCELERATE"/> /// then the <see cref="Pedestrian"/> will start moving faster;otherwise if it is <see cref="MoveBehaviour.DECELERATE"/> /// the <see cref="Pedestrian"/> will slow down.</remarks> public void Move(MoveBehaviour moveBehaviour) { if (moveBehaviour == MoveBehaviour.ACCELERATE) { this.Accelerate(); } if (this.Speed > 0) { switch (MovementDirection) { case PedestrianMovement.Up: this.Position = new Point(this.Position.X, this.Position.Y - Speed); break; case PedestrianMovement.Down: this.Position = new Point(this.Position.X, this.Position.Y + Speed); break; case PedestrianMovement.Left: this.Position = new Point(this.Position.X + Speed, this.Position.Y); break; case PedestrianMovement.Right: this.Position = new Point(this.Position.X - Speed, this.Position.Y); break; } this.HitBox = new Rectangle(this.Position, new Size(3, 3)); } }
IEnumerator RunMove(PlayerBattleUnit sourceUnit, PlayerBattleUnit targetUnit, MoveBehaviour move) { move.UsageMove--; yield return(dialogBox.TypeDialog($"{sourceUnit.servantInfo.servantBase.Name} used {move.Base.Name}")); sourceUnit.PlayAttackAnimation(); yield return(new WaitForSeconds(1f)); targetUnit.PlayHitAnimation(); var damageDetails = targetUnit.servantInfo.TakeDamage(move, sourceUnit.servantInfo); yield return(targetUnit.Hud.UpdateHP()); yield return(ShowDamageDetails(damageDetails)); if (damageDetails.Fainted) { yield return(dialogBox.TypeDialog($"{targetUnit.servantInfo.servantBase.Name} Fainted")); targetUnit.PlayFaintAnimation(); yield return(new WaitForSeconds(2f)); CheckForBattleOver(targetUnit); } }
public void HandleBarrelHit(GameObject barrelObjHit) { HandleBarrelBeat(barrelObjHit); float rotationDuration = DifficultyManager.MoveDurationBasedOnDifficulty(); Barrel barrelObjHitBarrelScript = barrelObjHit.gameObject.GetComponent <Barrel>(); barrelObjHitBarrelScript.HoldPlayer(); int potentialNextBarrelIndex = barrels.IndexOf(barrelHolingPlayer) + 1; nextBarrel = potentialNextBarrelIndex < barrels.Count ? barrels[potentialNextBarrelIndex] : null; if (barrelsToJump > 0) { barrelObjHitBarrelScript.AutoFire(0.5f); barrelsToJump--; } else { MoveBehaviour barrelObjHitMoveBehaviour = barrelObjHit.gameObject.GetComponent <MoveBehaviour>(); barrelObjHitMoveBehaviour.Activate(); //barrel will only move after the move duration, witch is the rotation duration barrelObjHitMoveBehaviour.RotateToInitialAngle(rotationDuration); } if (nextBarrel) { FocusCameraOnBarrel(nextBarrel); } HandleBarrelsJumped(); }
public void Remove(MoveBehaviour _moveBehaviour) { if (behaviours.Contains(_moveBehaviour)) { behaviours.Remove(_moveBehaviour); } }
void Start() { target = GameObject.Find("Player"); _moveBehaviour = GetComponent <MoveBehaviour>(); //_followBehaviour = GetComponent<FollowBehaviour>(); _spriterenderer = GetComponent <SpriteRenderer>(); }
public void Awake() { _moveBehaviour = GetComponent <MoveBehaviour>(); _healthBehaviour = GetComponent <HealthBehaviour>(); _startPos = transform.position; }
public void Awake() { _moveBehaviour = GetComponent <MoveBehaviour>(); _animator = GetComponent <Animator>(); _spriteRenderer = GetComponent <SpriteRenderer>(); _attackBehaviour = GetComponent <AttackBehaviour>(); _audioSource = GetComponent <AudioSource>(); }
public void Awake() { _moveBehaviour = GetComponent <MoveBehaviour>(); _animator = GetComponent <Animator>(); _spriteRenderer = GetComponent <SpriteRenderer>(); _attackBehaviour = GetComponent <AttackBehaviour>(); _trailBehaviour = GetComponent <TrailBehaviour>(); }
void DisableHeist() { MoveBehaviour move = GetComponent <MoveBehaviour>(); move.walkSpeed = 0.2f; move.runSpeed = 1.0f; move.sprintSpeed = 2.0f; }
void RpcHeist() { MoveBehaviour move = GetComponent <MoveBehaviour>(); move.walkSpeed = 1.0f; move.runSpeed = 2.0f; move.sprintSpeed = 4.0f; Invoke("DisableHeist", heistTime); }
public void Awake() { DontDestroyOnLoad(this.gameObject); _moveBehaviour = GetComponent <MoveBehaviour>(); _animator = GetComponent <Animator>(); _spriteRenderer = GetComponent <SpriteRenderer>(); _attackBehaviour = GetComponent <AttackBehaviour>(); _trailBehaviour = GetComponent <TrailBehaviour>(); }
public void TransitionTo(MoveBehaviour behaviour) { if (CurrentMoveBehaviour == behaviour) { return; } //Console.WriteLine(bot.tankName + " MOVE: " + behaviour); CurrentMoveBehaviour = behaviour; }
public void Awake() { _routineBehaviour = GetComponent <RoutineBehaviour>(); if (_routineBehaviour == null) { _patrol = false; } _moveBehaviour = GetComponent <MoveBehaviour>(); _spriteRenderer = GetComponent <SpriteRenderer>(); _animator = GetComponent <Animator>(); }
// Start is called before the first frame update void Start() { NeedStar = 4; ResetNumberOfTimes = 0; CoinScore = 0; ObtainedStar = 0; ObtainedJumpItem = 0; ObtainedHeart = 1; RemainingHeart = 1; RespawnPoint = this.transform.position; MoveBehaviorScript = this.GetComponent <MoveBehaviour>(); }
public void HandlePlayerFired() { player.GetComponent <Player>().StartMoreGravityOverTimeCoroutine(); MoveBehaviour barrelHoldingPlayerMoveBehaviour = barrelHolingPlayer.GetComponent <MoveBehaviour>(); barrelHoldingPlayerMoveBehaviour.Deactivate(); barrelHoldingPlayerMoveBehaviour.ignoreActivation = true; prevBarrelHoldingPlayer = GameManager.inst.barrelHolingPlayer; barrelHolingPlayer = null; playerRB2D.AddRelativeForce(new Vector2(2000, 0)); }
public Unit(MoveContainer mc, DrawContainer dc, BehaviourFactory bf, MainWindow window) { moveContainer = mc; drawContainer = dc; behaviourFactory = bf; this.window = window; moveBehaviour = behaviourFactory.CreateMoveBehaviour(this, "flying"); drawBehaviour = behaviourFactory.CreateDrawBehaviour(this, "flying"); moveContainer.Add(moveBehaviour); drawContainer.Add(drawBehaviour); this.window = window; dispatcher = Dispatcher.CurrentDispatcher; }
public void UpdateMoveSelection(int selectedMove, MoveBehaviour move) { for (int i = 0; i < moveText.Count; ++i) { if (i == selectedMove) { moveText[i].color = highlightedColor; } else { moveText[i].color = Color.black; } } ppText.text = $"PP {move.UsageMove}/{move.Base.UsageMove}"; TypeText.text = move.Base.servantClass.ToString(); }
// Use this for initialization void Start() { countRespawnZones = 0; //Establecer las zonas de respawn foreach (Transform transformAux in enemyRespawn) { countRespawnZones++; } moveControllerCharacter = mainCharacter.GetComponent <MoveBehaviour> (); lightAnimator = mainLight.GetComponent <Animator> (); isAnimationActive = false; isAnimationDone = false; currentTime = 0.0f; cinematicAudio.Stop(); numberEnemyDead = 0; enemyNumberNotGenerated = totalEnemies; currentEnemy = 0; }
private void Awake() { this.movement = this.GetComponent <MoveBehaviour>(); this.wander = this.GetComponent <WanderMovement>(); this.infection = this.GetComponent <InfectedBehaviour>(); }
public void Add(MoveBehaviour _moveBehaviour) { behaviours.Add(_moveBehaviour); }
//сюда можно ещё будет запихнуть данные типа модификаторов движения, хз public MoveProcessor(Entity entityToMove, MoveBehaviour behaviour) { _entityToMove = entityToMove; _moveBehaviour = behaviour; }
private void Awake() { _moveBehaviour = GetComponent <MoveBehaviour>(); }
public void MovePiece(GameObject piece, Vector2Int gridPoint) { MoveBehaviour move = piece.AddComponent <MoveBehaviour>(); move.target = Geometry.PointFromGrid(gridPoint); }
public void ChangeMoveBehaviour(MoveBehaviour moveBehaviour) { MoveBehaviour = moveBehaviour; }
// Use this for initialization void Start() { basic = GetComponent <BasicBehaviour>(); move = GetComponent <MoveBehaviour>(); }
/// <summary> /// Initializes a new instance of the <see cref="Car"/> class. /// </summary> /// <param name="direction">The direction in which the <see cref="Car"/> is going.</param> /// <param name="color">The color of the <see cref="Car"/>.</param> /// <param name="lane">The <see cref="Traffic_Light_Simulator.Lane"/> in which the <see cref="Car"/> currently is.</param> public Car(Direction direction, Color color, Lane lane) { this.Lane = lane; this.Direction = direction; this.Speed = 0; this.Position = direction == Direction.LEFT ? lane.CarStartingPositionLeftLane : lane.CarStartingPositionStraightAndRightLane; this.HitBox = new Rectangle(this.Position.X, this.Position.Y, CAR_WIDTH, CAR_HEIGHT); this.MovingBehaviour = MoveBehaviour.ACCELERATE; this.Color = color; TrafficTimer.Timer.Elapsed += (s, e) => Move(this.MovingBehaviour); }
//public Transform posz; void Start() { _movebehaviour = GetComponent <MoveBehaviour>(); }
public void InvokeOnMovePicked(MoveBehaviour _move) { OnMovePicked?.Invoke(_move); }
private void Awake() { this.moveBehaviour = this.GetComponent <MoveBehaviour>(); }
public void SetModifiedMove(MoveBehaviour moveBehaviour) { SetMoveBehaviour(moveBehaviour); }
// *************** // // ** Initialisation ** // // *************** // void Awake() { Instance = this; }
public void Declare(MoveBehaviour move) { Debug.Log("UnitAct"); State = UnitCombatState.preparation; Controller.OnMovePicked -= Declare; }
public void Awake() { _moveBehaviour = GetComponent <MoveBehaviour>(); }
public void changeMoveBehaviour(string behaviour) { moveContainer.Remove(moveBehaviour); moveBehaviour = behaviourFactory.CreateMoveBehaviour(this, behaviour); moveContainer.Add(moveBehaviour); }
private void Start() { this.rigidbody = this.GetComponent <Rigidbody>(); this.movement = this.GetComponent <MoveBehaviour>(); }
internal void addMoveBehaviourToMap(string name, MoveBehaviour moveBehaviour) { moveBehaviourMap.Add(name, moveBehaviour); }
/// <summary> /// Moves the <see cref="Car"/> depending on the <paramref name="moveBehaviour"/> that is passed. /// </summary> /// <param name="moveBehaviour">The <see cref="MoveBehaviour"/> that is passed.</param> /// <remarks>If the <see cref="MoveBehaviour"/> is <see cref="MoveBehaviour.ACCELERATE"/> /// then the <see cref="Car"/> will start moving faster;otherwise if it is <see cref="MoveBehaviour.DECELERATE"/> /// the <see cref="Car"/> will slow down.</remarks> public void Move(MoveBehaviour moveBehaviour) { if (moveBehaviour == MoveBehaviour.ACCELERATE) { if (this.Lane is LeftLane) { foreach (var lane in this.Lane.Intersection.Lanes) { try { if (this.Lane == lane) { if ( lane.Cars.Any( car => car.HitBox.Contains(new Point(this.Position.X + 16, this.Position.Y)) && this != car)) { return; } } else { for(int i = lane.Cars.Count - 1; i>=0; i--) { try { if(lane.Cars[i].HitBox.Contains(new Point(this.Position.X, this.Position.Y)) && !this.carsCrashedWith.Contains(lane.Cars[i]) && lane.Cars[i] != this) { //car crash IsCrashed = true; carsCrashedWith.Add(lane.Cars[i]); } } catch { } } } } catch (Exception ex) { this.Accelerate(); return; } } } else if (this.Lane is RightLane) { foreach (var lane in this.Lane.Intersection.Lanes) { try { if (this.Lane == lane) { if ( lane.Cars.Any( car => car.HitBox.Contains(new Point(this.Position.X - 6, this.Position.Y)) && this != car)) { return; } } else { for (int i = lane.Cars.Count - 1; i >= 0; i--) { try { if (lane.Cars[i].HitBox.Contains(new Point(this.Position.X, this.Position.Y)) && !this.carsCrashedWith.Contains(lane.Cars[i]) && lane.Cars[i] != this) { //car crash IsCrashed = true; carsCrashedWith.Add(lane.Cars[i]); } } catch { } } } } catch (Exception ex) { this.Accelerate(); return; } } } else if (this.Lane is LowerLane) { foreach (var lane in this.Lane.Intersection.Lanes) { try { if (this.Lane == lane) { if ( lane.Cars.Any( car => car.HitBox.Contains(new Point(this.Position.X, this.Position.Y - 6)) && this != car)) { return; } } else { for (int i = lane.Cars.Count - 1; i >= 0; i--) { try { if (lane.Cars[i].HitBox.Contains(new Point(this.Position.X, this.Position.Y)) && !this.carsCrashedWith.Contains(lane.Cars[i]) && lane.Cars[i] != this) { //car crash IsCrashed = true; carsCrashedWith.Add(lane.Cars[i]); } } catch { } } } } catch (Exception ex) { this.Accelerate(); return; } } } else if (this.Lane is UpperLane) { foreach (var lane in this.Lane.Intersection.Lanes) { try { if (this.Lane == lane) { if ( lane.Cars.Any( car => car.HitBox.Contains(new Point(this.Position.X, this.Position.Y + 15)) && this != car)) { return; } } else { for (int i = lane.Cars.Count - 1; i >= 0; i--) { try { if (lane.Cars[i].HitBox.Contains(new Point(this.Position.X, this.Position.Y)) && !this.carsCrashedWith.Contains(lane.Cars[i]) && lane.Cars[i] != this) { //car crash IsCrashed = true; carsCrashedWith.Add(lane.Cars[i]); } } catch { } } } } catch (Exception ex) { this.Accelerate(); return; } } } this.Accelerate(); } else { this.Decelerate(); } if (this.Speed > 0) { if (Lane is LeftLane) { if (Lane.HitBox.Contains(new Point(this.Position.X + Speed, this.Position.Y))) { this.Position = new Point(this.Position.X + Speed, this.Position.Y); } else { bool flag = true; foreach(BaseIntersection intersection in Lane.Intersection.Neighbors) { if(intersection.LeftLane.HitBox.Contains(new Point(this.Position.X + Speed, this.Position.Y))) { flag = false; if (intersection.LeftLane.IsEmpty()) { this.Position = new Point(this.Position.X + Speed, this.Position.Y); } else { return; } } } if (flag) this.Position = new Point(this.Position.X + Speed, this.Position.Y); } } else if (Lane is RightLane) { if (Lane.HitBox.Contains(new Point(this.Position.X - Speed, this.Position.Y))) { this.Position = new Point(this.Position.X - Speed, this.Position.Y); } else { bool flag = true; foreach (BaseIntersection intersection in Lane.Intersection.Neighbors) { if (intersection.RightLane.HitBox.Contains(new Point(this.Position.X - Speed, this.Position.Y))) { flag = false; if (intersection.RightLane.IsEmpty()) { this.Position = new Point(this.Position.X - Speed, this.Position.Y); } else { return; } } } if (flag) this.Position = new Point(this.Position.X - Speed, this.Position.Y); } } else if (Lane is UpperLane) { if (Lane.HitBox.Contains(new Point(this.Position.X, this.Position.Y + Speed))) { this.Position = new Point(this.Position.X, this.Position.Y + Speed); } else { bool flag = true; foreach (BaseIntersection intersection in Lane.Intersection.Neighbors) { if (intersection.UpperLane.HitBox.Contains(new Point(this.Position.X, this.Position.Y + Speed))) { flag = false; if (intersection.UpperLane.IsEmpty()) { this.Position = new Point(this.Position.X, this.Position.Y + Speed); } else { return; } } } if(flag) this.Position = new Point(this.Position.X, this.Position.Y + Speed); } } else if (Lane is LowerLane) { if (Lane.HitBox.Contains(new Point(this.Position.X, this.Position.Y - Speed))) { this.Position = new Point(this.Position.X, this.Position.Y - Speed); } else { bool flag = true; foreach (BaseIntersection intersection in Lane.Intersection.Neighbors) { if (intersection.LowerLane.HitBox.Contains(new Point(this.Position.X, this.Position.Y - Speed))) { flag = false; if (intersection.LowerLane.IsEmpty()) { this.Position = new Point(this.Position.X, this.Position.Y - Speed); } else { return; } } } if(flag) this.Position = new Point(this.Position.X, this.Position.Y - Speed); } } this.HitBox = new Rectangle(this.Position, new Size(CAR_HEIGHT, CAR_WIDTH)); } }
public void ProcessChoice(MoveBehaviour _move, UnitBehaviour _controlledUnit) { Debug.Log("ProcessChoice"); InvokeOnMovePicked(_move); }