public virtual void SetUnitData(UnitData data)
        {
            Health.SetHealth(data.Health);
            transform.position    = data.Position;
            transform.eulerAngles = new Vector3(0, data.YRotation, 0);

            // TODO: Set gameobject active?
        }
Exemple #2
0
        public override void Respawn()
        {
            life -= 1;
            if (life > 0)
            {
                Health.SetHealth(100);
                transform.position = startPosition;
            }

            else
            {
                Destroy(gameObject);
                SceneManager.LoadScene("PlayerLost");
            }
        }
Exemple #3
0
 protected virtual void HandleUnitDied(Unit unit)
 {
     GameManager.Instance.MessageBus.Publish(new UnitDiedMessage(this));
     //gameObject.SetActive( false );
     Health.SetHealth(_startingHealth);
     if (this is EnemyUnit)
     {
         transform.position = FindObjectOfType <EnemySpawn>().transform.position;
     }
     else
     {
         transform.position = FindObjectOfType <PlayerSpawn>().transform.position;
         GetComponent <PlayerUnit>()._livesLeft--;
     }
 }
Exemple #4
0
        /// <summary>
        /// Sets loaded data to this unit.
        /// </summary>
        /// <param name="data">Unit data</param>
        public void SetUnitData(UnitData data)
        {
            Health.SetHealth(data.Health, true);
            RemainingRespawnTime = data.RemainingRespawnTime;
            transform.position   = data.Position;

            Vector3 newRotation = transform.rotation.eulerAngles;

            newRotation.y      = data.YRotation;
            transform.rotation = Quaternion.Euler(newRotation);

            ID = data.ID;

            if (Health.IsDead)
            {
                tankModel.SetActive(false);
                GameManager.Instance.SpawnDestroyedTank(this);
            }
            else
            {
                tankModel.SetActive(true);
                ResetTankHead();
            }
        }
Exemple #5
0
 public virtual void Recycle()
 {
     transform.position = _initialPosition;
     Health.SetHealth(_startingHealth);
 }
Exemple #6
0
 public override void Respawn()
 {
     Health.SetHealth(50);
     transform.position = startPosition;
 }
 /// <summary>
 /// Sets unit healt to starting healt and position to zero. Or if commented keeps the current position.
 /// </summary>
 public void Respawn()
 {
     Health.SetHealth(_startingHealth);
     transform.position = new Vector3(0, 0, 0);
 }