Exemplo n.º 1
0
        public DamageInfo(float damage,
                          Vector3 sourcePosition,
                          Vector3 targetPosition,
                          int?playerNumber,
                          Collider2D collider)
        {
            Collider       = collider;
            Damage         = damage;
            SourcePosition = sourcePosition;
            TargetPosition = targetPosition;
            PlayerNumber   = playerNumber;

            GameStatistics.AddDamage(this);
        }
Exemplo n.º 2
0
        protected void Die(DamageInfo dmgInfo)
        {
            float oldLife = currentLife;

            currentLife -= dmgInfo.Damage;
            lifeBar.transform.localScale = new Vector3(currentLife / life * 0.5f / transform.localScale.x,
                                                       lifeBar.transform.localScale.y,
                                                       lifeBar.transform.localScale.z);

            if (currentLife < 0.1f)
            {
                ExplosionFactory.Create(transform.position, 1.0f);
                AudioUtils.Play("ZombieDeath", transform.position);

                BloodFactory.SplatFromDamageInfo(dmgInfo);
                GameStatistics.AddKill(dmgInfo.PlayerNumber, this);

                Destroy(this.gameObject);
                switch (enemyType)
                {
                case EnemyType.Regular:
                    Item.CreateRandom(transform.position);
                    break;

                case EnemyType.Boss:
                    var        tileset = (GameObject.Find("Map")).GetComponent <Assets.Scripts.Map.Map>().tilesets;
                    GameObject stairs  = (GameObject)Instantiate(tileset[Assets.Scripts.Map.Tile.Type.Exit][0],
                                                                 transform.position,
                                                                 Quaternion.identity);
                    stairs.transform.SetParent(map.transform);
                    break;
                }
            }
            else
            {
                AudioUtils.Play(damageSound, transform.position, 10.0f);
            }
        }