Inheritance: MonoBehaviour
コード例 #1
0
ファイル: Pedestrian.cs プロジェクト: rosendanew/ProCP
        /// <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));
            }
        }
コード例 #2
0
    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);
        }
    }
コード例 #3
0
ファイル: GameManager.cs プロジェクト: linck5/barrels_game
    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();
    }
コード例 #4
0
 public void Remove(MoveBehaviour _moveBehaviour)
 {
     if (behaviours.Contains(_moveBehaviour))
     {
         behaviours.Remove(_moveBehaviour);
     }
 }
コード例 #5
0
ファイル: Enemy_2.cs プロジェクト: TopDown2020/TopDown
 void Start()
 {
     target         = GameObject.Find("Player");
     _moveBehaviour = GetComponent <MoveBehaviour>();
     //_followBehaviour = GetComponent<FollowBehaviour>();
     _spriterenderer = GetComponent <SpriteRenderer>();
 }
コード例 #6
0
    public void Awake()
    {
        _moveBehaviour   = GetComponent <MoveBehaviour>();
        _healthBehaviour = GetComponent <HealthBehaviour>();

        _startPos = transform.position;
    }
コード例 #7
0
ファイル: MeleeEnemy.cs プロジェクト: TopDown2020/TopDown
 public void Awake()
 {
     _moveBehaviour   = GetComponent <MoveBehaviour>();
     _animator        = GetComponent <Animator>();
     _spriteRenderer  = GetComponent <SpriteRenderer>();
     _attackBehaviour = GetComponent <AttackBehaviour>();
     _audioSource     = GetComponent <AudioSource>();
 }
コード例 #8
0
ファイル: Shadow_Move.cs プロジェクト: TopDown2020/TopDown
 public void Awake()
 {
     _moveBehaviour   = GetComponent <MoveBehaviour>();
     _animator        = GetComponent <Animator>();
     _spriteRenderer  = GetComponent <SpriteRenderer>();
     _attackBehaviour = GetComponent <AttackBehaviour>();
     _trailBehaviour  = GetComponent <TrailBehaviour>();
 }
コード例 #9
0
    void DisableHeist()
    {
        MoveBehaviour move = GetComponent <MoveBehaviour>();

        move.walkSpeed   = 0.2f;
        move.runSpeed    = 1.0f;
        move.sprintSpeed = 2.0f;
    }
コード例 #10
0
    void RpcHeist()
    {
        MoveBehaviour move = GetComponent <MoveBehaviour>();

        move.walkSpeed   = 1.0f;
        move.runSpeed    = 2.0f;
        move.sprintSpeed = 4.0f;
        Invoke("DisableHeist", heistTime);
    }
コード例 #11
0
 public void Awake()
 {
     DontDestroyOnLoad(this.gameObject);
     _moveBehaviour   = GetComponent <MoveBehaviour>();
     _animator        = GetComponent <Animator>();
     _spriteRenderer  = GetComponent <SpriteRenderer>();
     _attackBehaviour = GetComponent <AttackBehaviour>();
     _trailBehaviour  = GetComponent <TrailBehaviour>();
 }
コード例 #12
0
        public void TransitionTo(MoveBehaviour behaviour)
        {
            if (CurrentMoveBehaviour == behaviour)
            {
                return;
            }

            //Console.WriteLine(bot.tankName + "  MOVE: " + behaviour);
            CurrentMoveBehaviour = behaviour;
        }
コード例 #13
0
 public void Awake()
 {
     _routineBehaviour = GetComponent <RoutineBehaviour>();
     if (_routineBehaviour == null)
     {
         _patrol = false;
     }
     _moveBehaviour  = GetComponent <MoveBehaviour>();
     _spriteRenderer = GetComponent <SpriteRenderer>();
     _animator       = GetComponent <Animator>();
 }
コード例 #14
0
 // 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>();
 }
コード例 #15
0
ファイル: GameManager.cs プロジェクト: linck5/barrels_game
    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));
    }
コード例 #16
0
ファイル: Unit.cs プロジェクト: JoepvdBroek/DP2_Duckhunt
        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;
        }
コード例 #17
0
    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();
    }
コード例 #18
0
    // 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;
    }
コード例 #19
0
ファイル: ChargeOnInfected.cs プロジェクト: Noutus/Quack
 private void Awake()
 {
     this.movement  = this.GetComponent <MoveBehaviour>();
     this.wander    = this.GetComponent <WanderMovement>();
     this.infection = this.GetComponent <InfectedBehaviour>();
 }
コード例 #20
0
 public void Add(MoveBehaviour _moveBehaviour)
 {
     behaviours.Add(_moveBehaviour);
 }
コード例 #21
0
        //сюда можно ещё будет запихнуть данные типа модификаторов движения, хз

        public MoveProcessor(Entity entityToMove, MoveBehaviour behaviour)
        {
            _entityToMove  = entityToMove;
            _moveBehaviour = behaviour;
        }
コード例 #22
0
ファイル: TrapBehaviour.cs プロジェクト: TopDown2020/TopDown
 private void Awake()
 {
     _moveBehaviour = GetComponent <MoveBehaviour>();
 }
コード例 #23
0
ファイル: Board.cs プロジェクト: MoritzHST/VR-Schach
    public void MovePiece(GameObject piece, Vector2Int gridPoint)
    {
        MoveBehaviour move = piece.AddComponent <MoveBehaviour>();

        move.target = Geometry.PointFromGrid(gridPoint);
    }
コード例 #24
0
 public void ChangeMoveBehaviour(MoveBehaviour moveBehaviour)
 {
     MoveBehaviour = moveBehaviour;
 }
コード例 #25
0
 // Use this for initialization
 void Start()
 {
     basic = GetComponent <BasicBehaviour>();
     move  = GetComponent <MoveBehaviour>();
 }
コード例 #26
0
ファイル: Car.cs プロジェクト: rosendanew/ProCP
        /// <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);
        }
コード例 #27
0
 //public Transform posz;
 void Start()
 {
     _movebehaviour = GetComponent <MoveBehaviour>();
 }
コード例 #28
0
 public void InvokeOnMovePicked(MoveBehaviour _move)
 {
     OnMovePicked?.Invoke(_move);
 }
コード例 #29
0
ファイル: MoveOnInput.cs プロジェクト: Noutus/Quack
 private void Awake()
 {
     this.moveBehaviour = this.GetComponent <MoveBehaviour>();
 }
コード例 #30
0
ファイル: PlayerController.cs プロジェクト: Pyrohova/Runner
 public void SetModifiedMove(MoveBehaviour moveBehaviour)
 {
     SetMoveBehaviour(moveBehaviour);
 }
コード例 #31
0
ファイル: MoveBehaviour.cs プロジェクト: Acartes/X_Tournament
    // *************** //
    // ** Initialisation ** //
    // *************** //

    void Awake()
    {
        Instance = this;
    }
コード例 #32
0
 public void Declare(MoveBehaviour move)
 {
     Debug.Log("UnitAct");
     State = UnitCombatState.preparation;
     Controller.OnMovePicked -= Declare;
 }
コード例 #33
0
 public void Awake()
 {
     _moveBehaviour = GetComponent <MoveBehaviour>();
 }
コード例 #34
0
ファイル: Unit.cs プロジェクト: JoepvdBroek/DP2_Duckhunt
 public void changeMoveBehaviour(string behaviour)
 {
     moveContainer.Remove(moveBehaviour);
     moveBehaviour = behaviourFactory.CreateMoveBehaviour(this, behaviour);
     moveContainer.Add(moveBehaviour);
 }
コード例 #35
0
ファイル: WalkTowardsTarget.cs プロジェクト: Noutus/Quack
 private void Start()
 {
     this.rigidbody = this.GetComponent <Rigidbody>();
     this.movement  = this.GetComponent <MoveBehaviour>();
 }
コード例 #36
0
 internal void addMoveBehaviourToMap(string name, MoveBehaviour moveBehaviour)
 {
     moveBehaviourMap.Add(name, moveBehaviour);
 }
コード例 #37
0
ファイル: Car.cs プロジェクト: rosendanew/ProCP
        /// <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);
 }