Example #1
0
        public virtual void Init()
        {
            _mover = gameObject.GetOrAddComponent <TransformMover>();
            _mover.Init(_moveSpeed, _turnSpeed);

            Weapon = GetComponentInChildren <Weapon>();
            if (Weapon != null)
            {
                Weapon.Init(this);
            }

            Health           = new Health(this, _startingHealth);
            Health.UnitDied += HandleUnitDied;
        }
Example #2
0
        /// <summary>
        /// Initializes the object.
        /// </summary>
        public virtual void Init()
        {
            // Initializes the weapon
            Weapon = GetComponentInChildren <Weapon>();
            if (Weapon != null)
            {
                Weapon.Init(this);
            }

            // Initializes moving
            mover = gameObject.GetOrAddComponent <TransformMover>();
            mover.Init(moveSpeed, turnSpeed);

            // Initializes turning the cannon
            TransformMover[] headMovers =
                tankHead.GetComponentsInChildren <TransformMover>();
            headMover   = headMovers[0];
            barrelMover = headMovers[1];
            headMover.Init(0f, turnSpeed);
            barrelMover.Init(0f, turnSpeed);

            // Initializes health
            Health = new Health(this, startingHealth);

            // Registers to listen to the UnitDied event
            Health.UnitDied += OnUnitDied;

            // Sets spawn position and rotation
            startPosition = transform.position;
            startRotation = transform.rotation;

            if (tankModel == null)
            {
                Debug.LogError("Tank model is not set.");
            }
        }
Example #3
0
 public void PrepareState()
 {
     _collisionMover.Init();
     _playerEventsNotifier.CollisionFinished += OnCollisionFinished;
 }
Example #4
0
 public void PrepareState()
 {
     _pathMover.Init();
     _playerEventsNotifier.EscapedTransitionZone += OnEscapedTransitionZone;
 }
Example #5
0
 public void PrepareState()
 {
     _physicalMover.Init();
     _playerEventsNotifier.CollisionStarted      += OnCollisionStarted;
     _playerEventsNotifier.EnteredTransitionZone += OnEnteredTransitionZone;
 }