Example #1
0
    void Start()
    {
        creatureHPBar = new HPBar(self, curHP / maxHP, Color.green);

        //Enemy HP Regen
        InvokeRepeating("regen", 0, 1f);
    }
Example #2
0
    protected override void Start()
    {
        base.Start();
        instanceID = GetInstanceID();
        mainRend   = GetComponentInChildren <Renderer>();
        obstacle   = GetComponent <NavMeshObstacle>();
        mainColor  = mainRend.material.color;

        // UI related
        hpBar              = GetComponentInChildren <HPBar>();
        hpBar.anchor       = transform;
        hpbarImage         = hpBar.GetComponent <Image>();
        hpbarImage.enabled = false;
        hpBar.transform.SetParent(UIController.instance.attributesContainer.transform, false);
        buildBar        = GetComponentInChildren <BuildTimeBar>();
        buildBar.anchor = transform;
        buildBar.transform.SetParent(UIController.instance.attributesContainer.transform, false);
        marker         = GetComponentInChildren <SpriteRenderer>();
        marker.enabled = false;
        spawnPoint     = transform.Find("_spawn_point");

        if (currentState == BuildingState.Complete)
        {
            ToComplete();
        }
        else
        {
            ToPrepare();
        }
    }
Example #3
0
    public void Start()
    {
        m_Hpbar = UIAdd.Get <HPBar>(UIType.HpBarUI);
        m_nHp   = DataMng.Get(TableType.TowerTable).ToI(Index, "HP");

        m_GuardPos = m_Launch.transform.position;
    }
Example #4
0
        /// <summary>
        /// 유닛을 필드에 오브젝트로 생성시키는 함수
        /// 생성하면서 이벤트 콜벡을 할당해줘야 한다.
        /// </summary>
        /// <param name="unit"></param>
        public static void MakeUnitObject(Unit unit)
        {
            // 미리 존재 여부 확인
            if (UnitObjects.ContainsKey(unit) == true)
            {
                Debug.LogError($"이미 필드에 유닛({unit.Name}) 오브젝트가 존재합니다.");
                return;
            }

            // 게임 오브젝트 생성
            GameObject newObj = new GameObject(unit.Name);

            // 위치 지정
            newObj.transform.position = new Vector3(unit.Position.x, unit.Position.y, 0);

            // 박스 콜라이더 컴포넌트 추가
            BoxCollider2D boxCollider2D = newObj.AddComponent <BoxCollider2D>();

            boxCollider2D.size = new Vector2(1, 1);

            // 이벤트 트리거 컴포넌트 추가
            EventTrigger eventTrigger = newObj.AddComponent <EventTrigger>();

            GameObject imgObj = new GameObject("image");

            imgObj.transform.SetParent(newObj.transform);

            // 스프라이터 랜더러 추가
            SpriteRenderer spriteRenderer = imgObj.AddComponent <SpriteRenderer>();

            spriteRenderer.sprite = unit.Sprite;

            // 애니메이터 추가
            Animator animator = imgObj.AddComponent <Animator>();

            animator.runtimeAnimatorController = instance.animatorController;

            UnitObjects.Add(unit, newObj);

            // HP 바 생성
            GameObject hpBarObj = Instantiate(instance.hPBarPrefab, MainPanel.transform);

            hpBarObj.transform.SetAsFirstSibling();
            HPBar newHPBar = hpBarObj.GetComponent <HPBar>();

            newHPBar.Init(unit);
            HPBars.Add(UnitObjects[unit].transform, newHPBar);

            //유닛 오브젝트 상호작용 콜백 등록
            unit.OnPosition.after.AddListener(MoveObject);
            unit.OnCurHP.after.AddListener(newHPBar.SetValue);

            //최초 갱신
            //newHPBar.SetValue(unit.CurHP);
            int        tempHP       = unit.CurHP;
            Vector2Int tempPosition = unit.Position;

            unit.OnPosition.after.Invoke(tempPosition);
            unit.OnCurHP.after.Invoke(tempHP);
        }
Example #5
0
 private void OnEnable()
 {
     anim.SetBool(AnimationHashList.AnimHashDead, false);
     player = null;
     hpBar  = null;
     state  = eEnemyState.SeekPlayer;
 }
    public IEnumerator TestHPBarFluctuation()
    {
        // Use the Assert class to test conditions.
        // yield to skip a frame

        // Cycle between draining the player's HP to 0 and bringing it back to full
        GameObject playerPrefab = Resources.Load <GameObject>("Prefabs/Player");
        GameObject hpBarPrefab  = Resources.Load <GameObject>("Prefabs/HPBar");

        GameObject playerGO = MonoBehaviour.Instantiate <GameObject>(playerPrefab);
        GameObject hpBarGO  = MonoBehaviour.Instantiate <GameObject>(hpBarPrefab);

        SidescrollerCharacter player = playerGO.GetComponent <SidescrollerCharacter>();
        HPBar hpBar = hpBarGO.GetComponentInChildren <HPBar>();

        float prevFillAmount = hpBar.fillAmount;

        player.TakeDamage(1);

        yield return(null);

        float newFillAmount = hpBar.fillAmount;

        Assert.AreNotEqual(prevFillAmount, newFillAmount);
    }
Example #7
0
    public void AddBuff(Buff buff, bool can_stack)
    {
        if (BattleBase.Instance.IsBattleEnd == true)
        {
            return;
        }

        if (buff.IsMainBuff == true && can_stack == false)
        {
            foreach (Buff find_buff in Buffs.FindAll(b => b.Skill == buff.Skill))
            {
                find_buff.Finish();
            }
        }

        buff.EndTime = PlaybackTime + buff.Duration;
        buff.DoAction();
        Buffs.Add(buff);
        //        Buffs.Sort(Buff.SortByEndTime);

        if (buff.BuffContainer.Asset)
        {
            HPBar.AddBuff(buff.BuffContainer.Asset);
        }

        switch (buff.ActionInfo.actionType)
        {
        case eActionType.buff:
        case eActionType.debuff:
        case eActionType.buff_percent:
        case eActionType.debuff_percent:
            RefreshStat();
            break;
        }
    }
        protected virtual void Start()
        {
            AddConstruct    = Player.AddConstruct;
            RemoveConstruct = Player.RemoveConstruct;

            hpimage = this.GetComponentInChildren <HPBar>();
            InitOffset();
        }
Example #9
0
 // When enabled, turn on this UI and turn off the other UI.
 void OnEnable()
 {
     //ar = player.GetComponent<KirbyWalk> ().getAirRide ();
     kirbySpeedometer.enabled = false;
     speedometer.enabled      = true;
     speedometerNums.SetActive(true);
     HPBar.SetActive(true);
 }
Example #10
0
    void Start()
    {
        UnityEngine.Object perfab = Resources.Load("Builds/UI/HPBar/Prefabs/HPBar");
        GameObject         go     = Instantiate(perfab) as GameObject;

        m_hpBar = go.AddComponent <HPBar>();
        m_hpBar.SetTarget(transform);
    }
Example #11
0
 public void Start()
 {
     HP    = maxHP;
     hpbar = transform.GetComponentInChildren <HPBar>();
     hpbar.Init(maxHP, HP);
     buffs = new List <Buff>();
     SetAutoTarget(this);
     StartCoroutine(FSM());
 }
Example #12
0
 public void Awake()
 {
     healthBar      = GameObject.Find("HPBar").GetComponent <HPBar>();
     globesCount    = 0;
     globesMaxCount = 5;
     AddNewGlobe();
     playerCurHp     = playerMaxHp;
     lastActiveGlobe = 0;
 }
Example #13
0
    void Start()
    {
        randomPowerUp = Random.Range(0, powerUpSprites.Length);
//		randomPowerUp = powerUpSprites.Length-1;
//		randomPowerUp = 0;
        gameObject.GetComponent <SpriteRenderer>().sprite = powerUpSprites[randomPowerUp];
        playerController = GameObject.FindObjectOfType <PlayerController>();
        hpBar            = GameObject.FindObjectOfType <HPBar>();
    }
Example #14
0
        protected override void InitializeHpBar()
        {
            base.InitializeHpBar();

            var title = Costumes.FirstOrDefault(costume =>
                                                costume.ItemSubType == ItemSubType.Title && costume.equipped);

            HPBar.SetTitle(title);
        }
Example #15
0
 // Start is called before the first frame update
 void Start()
 {
     health = 100;
     GS     = FindObjectOfType <GameSystem>();
     body   = GetComponent <Rigidbody2D>();
     PM     = GetComponent <PlayerMoving>();
     PE     = GetComponent <PlayerEffects>();
     bar    = FindObjectOfType <HPBar>();
     bar.updateHealth(health);
 }
Example #16
0
    protected void AddHpBar()
    {
        GameObject go = Managers.Resource.Instantiate("UI/HpBar", transform);

        go.transform.localPosition = new Vector3(0, 0.5f, 0);
        go.name = "HPBar";
        _hpBar  = go.GetComponent <HPBar>();

        UpdateHPBar();
    }
Example #17
0
    public HPBar NewHealthBar(Transform selfTransform)
    {
        HPBar   newBar    = Instantiate(_hpBarPrefab).GetComponent <HPBar>();
        Vector3 barOffset = newBar.transform.position;

        newBar.transform.position = selfTransform.position + barOffset;
        newBar.transform.parent   = selfTransform.parent;
        newBar.gameObject.SendMessage("UpdateBarValues", selfTransform);
        return(newBar);
    }
 protected virtual void Init()
 {
     _bar         = GetComponentInChildren <HPBar>();
     _mat         = GetComponentInChildren <Renderer>().material;
     _manager     = GameObject.FindWithTag("Manager").GetComponent <Manager>();
     _tr          = transform;
     _tr.position = curr.transform.position;
     curr.infra   = this;
     SetColor(Color.white);
 }
Example #19
0
    public void Restart(float attack_next_time)
    {
        PlaybackTime   = 0f;
        AttackNextTime = attack_next_time;
        IsManaFill     = false;
        m_WaitTime     = 0f;

        HPBar.UpdateHPBar();

        //        Character.UpdatePlay(0f);
    }
Example #20
0
 public HeroData()
 {
     TextAsset default_hero = Resources.Load(DEFAULT_HERO) as TextAsset;
     string hero = PlayerPrefs.GetString("battle_value", default_hero.text);
     var hero_data = JSON.Parse(hero);
     _hitPoint = _maxHitPoint = hero_data["hit_point"].AsFloat;
     _attack = hero_data["attack_point"].AsFloat;
     _recover = hero_data["recovery"].AsFloat;
     _mana = hero_data["mana"].AsFloat;
     _hpBar = GameObject.Find("HeroHPBar").GetComponent<HPBar>();
 }
Example #21
0
 // When this code is disabled, switch back to the other UI.
 void OnDisable()
 {
     ar = null;
     topChargeBar.fillAmount = 0;
     botChargeBar.fillAmount = 0;
     flashing = false;
     kirbySpeedometer.enabled = true;
     speedometer.enabled      = false;
     speedometerNums.SetActive(false);
     HPBar.SetActive(false);
 }
Example #22
0
    private void Start()
    {
        DataMng.AddTable(TableType.StageTable);
        DataMng.AddTable(TableType.MonsterTable);

        m_Hpbar = UIAdd.Get <HPBar>(UIType.HpBarUI);
        m_SeeUi = UIAdd.Get <SeeUI>(UIType.SeeUI);

        m_nCount = m_Map.m_nStartCount;
        m_nRound = 0;
    }
Example #23
0
 void Awake()
 {
     if (hpgit == null)
     {
         DontDestroyOnLoad(gameObject);
         hpgit = this;
     }
     else if (hpgit != this)
     {
         Destroy(gameObject);
     }
 }
Example #24
0
    protected virtual void Awake()
    {
        rigidBody = this.GetComponent <Rigidbody>();
        //inGameMgr = InGameManager.instance;
        //resourceMgr = ResourceManager.instance;
        movingValue = 1.0f;
        image       = this.transform.Find("Image");
        animator    = image.GetComponent <Animator>();
        hpBar       = this.transform.Find("HPBar").GetComponent <HPBar>();

        Debug.Log("Monster");
    }
Example #25
0
 protected override void Start()
 {
     base.Start();
     instanceID         = GetInstanceID();
     anim               = GetComponentInChildren <Animator>();
     agent              = GetComponent <NavMeshAgent>();
     obstacle           = GetComponent <NavMeshObstacle>();
     marker             = GetComponentInChildren <SpriteRenderer>();
     marker.enabled     = false;
     hpbarImage.enabled = false;
     hpBar              = hpbarImage.GetComponent <HPBar>();
 }
Example #26
0
 protected override void Start()
 {
     base.Start();
     instanceID         = GetInstanceID();
     rend               = GetComponentInChildren <Renderer>();
     obstacle           = GetComponent <NavMeshObstacle>();
     marker             = GetComponentInChildren <SpriteRenderer>();
     marker.enabled     = false;
     hpbarImage.enabled = false;
     hpBar              = hpbarImage.GetComponent <HPBar>();
     resoManager        = GameObject.FindGameObjectWithTag("Player").GetComponent <ResourceManager>();
 }
    private void Awake()
    {
        ahb  = GetComponentInChildren <EnemyAttackHitBox>();
        anim = GetComponent <Animator>();
        rb   = GetComponent <Rigidbody2D>();
        bc   = GetComponent <BoxCollider2D>();
        hp   = GetComponentInChildren <HPBar>();

        moveVec       = -Vector2.right;
        currentHealth = health;

        hpBar.SetActive(false);
    }
 private void LoseHP()
 {
     this.db.Life--;
     HPBar.Increment(-1);
     ChangeHpColor();
     if (this.db.Life == 0)
     {
         timer1.Stop();
         Thread tr = new Thread(RunGameOverScreen);
         tr.Start();
         this.Close();
     }
 }
    RectTransform createHpBar(UnitController uc)
    {
        GameObject bar = Instantiate(hpBarPrefab);

        bar.transform.SetParent(hpBarsObj.transform);

        HPBar hpbar = bar.gameObject.GetComponent <HPBar>();

        hpbar.hp        = uc.stats;
        hpbar.following = uc.HpBarPos;
        hpbar.StartUpdating();

        return(bar.GetComponent <RectTransform>());
    }
Example #30
0
    void Start()
    {
        thisEntity = gameObject.GetComponent <Entity>();

        var hpBarObj = Instantiate(HPBarPrefab, HPBarInstancePos.position, Quaternion.identity);

        hpBarObj.transform.parent = this.gameObject.transform;

        hpBar = hpBarObj.GetComponent <HPBar>();

        hpBar.UpdateHPBar(thisEntity.GetHPmax(), thisEntity.GetHPAmount());

        StartCoroutine(startRoutine());
    }
Example #31
0
    public void Init(HPBar hPBar)
    {
        m_hpbar     = hPBar;
        m_vecLookat = transform.localScale;

        m_GuardBoun.center = transform.position;

        m_School = transform.parent.gameObject.GetComponent <School>();
        m_SetHp(m_School.m_Hp);
        m_SetAttack(m_School.Attack);
        m_hpbar.SetMake(gameObject, ref m_SetHpCsObj);
        m_HpCs  = m_SetHpCsObj.GetComponent <ReckoningHp>();
        m_Hpobj = m_HpCs;
    }
Example #32
0
 void Awake()
 {
     hpBar = this.GetComponentInChildren<HPBar> ();
     atbBar = this.GetComponentInChildren<ATBBar>();
     mpBar = this.GetComponentInChildren<MPBar>();
     playerNameText = this.GetComponentInChildren<PlayerNameText> ();
 }
Example #33
0
 // Use this for initialization
 void Start()
 {
     _heroHpBar = GameObject.Find("HeroHPBar").GetComponent<HPBar>();
     _sprite = GetComponent<SpriteRenderer>();
 }
Example #34
0
 void Awake()
 {
     anim = this.GetComponent<Animator>();
     agent = this.GetComponent<NavMeshAgent>();
     hpBar = this.GetComponentInChildren<HPBar>();
     monsterAI = this.GetComponent<MonsterAI>();
     atbBar = this.GetComponentInChildren<ATBBar>();
     state = new BattleState();
     state.setState(BattleState.State.Idle);
     setAnim();
 }