// Start is called before the first frame update void Start() { player_hp = StageData._data.GetHP(); _currentAnimationState = STATE_IDLE; _playerRB = GetComponent <Rigidbody2D>(); _animator = GetComponentInChildren <Animator>(); _renderer = GetComponentInChildren <SpriteRenderer>(); _collider = GetComponent <Collider2D>(); _isInvulnerable = false; _isDead = false; _hpBar.SetMaxHp(StageData._data.GetMAXHP()); _hpBar.SetHp(player_hp); }
public void takeDamage(float damage) { hp -= damage; if (hpBar) { hpBar.SetHp(hp); } if (currentSource == null) { currentSource = AudioController.instance.PlaySingle(takeDamageAudio, 0.2f); } if (hp <= 0 && !dead) { dead = true; // Stop this triggering multiple times (shotgun or w/e) AudioController.instance.PlaySingle(deathSoundClip, 0.1f); enemyController.EnemyDied(); if (corpse) { Instantiate(corpse, transform.position, transform.rotation); } Destroy(gameObject); gameController.addToScore(scoreWorth); } }
public void Transform(int monId) { if (IsHero) { NLog.Warn("hero cannot be Transform"); return; } int cardId = Weapon == null ? 0 : Weapon.CardId; var savedWeapon = Weapon == null ? null : Weapon.GetCopy(); DeleteWeapon(); int lifp = Life * 100 / Avatar.Hp; MonsterCoverBox.RemoveAllCover(); SkillManager.CheckRemoveEffect(); OwnerPlayer.State.CheckMonsterEvent(false, this); Avatar = new Monster(monId); Avatar.UpgradeToLevel(Level); OwnerPlayer.State.CheckMonsterEvent(true, this); SetBasicData(); MonsterCoverBox.CheckCover(); SkillManager.CheckInitialEffect(); if (cardId > 0) { AddWeapon(savedWeapon); } HpBar.SetHp(Avatar.Hp * lifp / 100); }
public void Revive() { GhostTime = 0; BattleManager.Instance.MemMap.GetMouseCell(Position.X, Position.Y).UpdateOwner(Id); HpBar.SetHp(1);//复活给1hp SkillManager.CheckInitialEffect(); }
public void SuddenDeath() { if (Avatar.MonsterConfig.IsBuilding) { BattleManager.Instance.FlowWordQueue.Add(new FlowWord("抵抗", Position, 0, "Gold", 26, 0, 0, 1, 15), false); return; } HpBar.SetHp(0); }
public void TakeDmg(int dmg) { if (currentHp > 0) { currentHp -= dmg; if (hpBar != null) { hpBar.SetHp(currentHp); } } }
public void Start() { hp = maxHp; hpBar = gameObject.GetComponentInChildren <HpBar>(); enemyController = FindObjectOfType <EnemyController>(); gameController = FindObjectOfType <GameController>(); body = GetComponent <Rigidbody2D>(); var norm = transform.position / -transform.position.magnitude; angle = Mathf.Atan2(norm.y, norm.x) * Mathf.Rad2Deg; transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward); if (hpBar) { hpBar.SetMaxHp(hp); hpBar.SetHp(hp); } }
public LiveMonster(int level, Monster mon, Point point, bool isLeft) { Id = World.WorldInfoManager.GetCardFakeId(); Level = level; Avatar = mon; Avatar.UpgradeToLevel(level); Position = point; IsLeft = isLeft; Action = 0; roundPast = 0; HpBar = new HpBar(this); SkillManager = new SkillManager(this); AttackType = (int)CardElements.None; CanAttack = true; BuffManager = new BuffManager(this); aiController = new MonsterAi(this); LiveMonsterToolTip = new LiveMonsterToolTip(this); SetBasicData(); HpBar.SetHp(Avatar.Hp); MonsterCoverBox = new MonsterCoverBox(this); }
private void UpdateHpBar(int val) { _hpBar.SetHp(val); }
/// <summary> /// Populate the UI with Monster data. /// </summary> /// <param name="monster">Monster in party.</param> public void SetData(MonsterObj monster) { _nameText.text = monster.Base.Name; _levelText.text = "Lvl " + monster.Level; _hpBar.SetHp((float)monster.CurrentHp / monster.MaxHp); }