public void PopUp(int damage, Vector2 _position) { PopUpText _text = GCManager.Instantiate(DAMAGE_POPUP_GC_KEY).GetComponentInChildren <PopUpText>(); _text.SetText(damage.ToString()); _text.transform.position = _position; }
IEnumerator NextLevel() { Debug.Log("current level " + current_lv + " " + level_settings[current_lv].name); left_monster = level_settings[current_lv].amount; for (int j = 0; j < level_settings[current_lv].amount; j++) { Vector2 _rand_pos = new Vector2( UnityEngine.Random.Range(levelRange.bounds.min.x, levelRange.bounds.max.x), UnityEngine.Random.Range(levelRange.bounds.min.y, levelRange.bounds.max.y) ); GameObject hint = GCManager.Instantiate(ParticleEffectManager.RED_CIRCLE_HINT_GC_KEY); hint.transform.position = _rand_pos; yield return(new WaitForSeconds(1)); int rand_rate = UnityEngine.Random.Range(0, level_settings[current_lv].all_rate); GameObject _enemy = Instantiate(level_settings[current_lv].set[level_settings[current_lv].GetRateIndex(rand_rate)].enemy_prefab, _rand_pos, Quaternion.identity); current_enemys.Add(_enemy); //TODO: temp //Instancitate_level_data(level_settings[i], _rand_pos); } turn_count_downtext.text = "Turn left " + (level_settings.Length - current_lv - 1).ToString(); //temp }
public void DOBlast(string _key, Vector2 _pos, float _lifeTime) { GameObject _blast = GCManager.Instantiate(_key); _blast.transform.position = _pos; _blast.GetComponent <GC_SelfDestoryItem>()?.Setup(_key); }
void Shoot() { /* * Vector2 _pos = new Vector2( * Random.Range(-20, 20), Random.Range(-20, 20));*/ GameObject _obj = GCManager.Instantiate(_ammo.ammoData.GC_key); _obj.transform.position = transform.position; _obj.GetComponent <Ammo>().vec = new Vector2(0.4f, 0); //_obj.transform.position = _pos; }
private IEnumerator Start() { //wait for hp bar to finish regiester: yield return(new WaitForEndOfFrame()); //Create HP Bar hpbar = GCManager.Instantiate(HPBarControl.HPBAR_GC_KEY).GetComponent <HPBarControl>(); hpbar.SetHitable(this); Hit_event += Hit; maxHP = HP; }
public void Effect(string _gc_key, string _clip_name, Quaternion _rotation = default, Vector3 _position = default) { GameObject _effect = GCManager.Instantiate(_gc_key, _rotation: _rotation, _position: _position); if (_effect != null) { _effect.GetComponent <Animator>().Play(_clip_name); if (_position == default) { _effect.transform.position = _footPosition; } //_effect.transform.rotation = _rotation; Debug.Log(_rotation + " " + _effect.transform.rotation + " "); } }
public void EquipAmmo(AmmoData _ammoData) { //check if the ammo is on scene: GameObject _obj = GCManager.Instantiate(_ammoData.GC_key); if (_obj == null) { //if not => create one new; _obj = Instantiate(_ammoData.ammo_prefab); } Ammo _newAmmo = _obj.GetComponent <Ammo>(); ammo = _newAmmo; //TODO drop current ammo?; }
IEnumerator HealCoro() { WaitForSeconds _oneSec = new WaitForSeconds(0.5f); float _prewait = 1.5f; while (_prewait > 0) { _prewait -= 0.5f; yield return(_oneSec); } while (true) { Animator _effect = GCManager.Instantiate("Heal Effect", _position: _footPosition).GetComponent <Animator>(); _effect.Play("heal"); hitable.Heal(healAmount); yield return(_oneSec); } }
public virtual void Shoot(Vector2 _dir, AmmoData ammoData, LayerMask ammo_target_layer = default) { float _seg = weaponData.shoot_sight_angle / (weaponData.ammo_row_count + 1); //Vector2 _start_vec = Quaternion.AngleAxis(-weaponData.shoot_sight_angle * 0.5f, -transform.right) * _dir; Vector2 _start_vec = _dir.rotate(-weaponData.shoot_sight_angle * Mathf.Deg2Rad * 0.5f); Debug.Log("shoot dir " + _dir + " \nrotated dir " + _start_vec + " seg " + _seg); //multi row shoots (多重射擊) for (int i = 0; i < weaponData.ammo_row_count; i++) { Vector2 _divers_dir = _start_vec.rotate(_seg * Mathf.Deg2Rad); //generate ammo GameObject _obj = GCManager.Instantiate(ammoData.GC_key, prefab: ammoData.ammo_prefab, position: transform.position); if (_obj == null) { Debug.Log("_obj not registered " + ammoData.GC_key); return; } Ammo _ammo = _obj.GetComponent <Ammo>(); //TODO: clean code //_ammo.transform.position = transform.position; //_ammo.dir = _dir; //_ammo.vec = _divers_dir; _ammo.SetUP(transform.position, _divers_dir); _ammo._total_damage = weaponData.damage_multiplier * ammoData.damage; //_ammo.targetLayer = ammo_target_layer; _ammo.SetTargetLayer(ammo_target_layer); _start_vec = _divers_dir; } //return _ammo; }
public override void SetUP(Vector2 _start_pos, Vector2 _vec) { //put hint in dest pos GameObject _hint = GCManager.Instantiate(hint_gc_key); //temp if (targetLayer == (targetLayer | (1 << LayerMask.NameToLayer("Player")))) { base.SetUP(_start_pos, _vec); _hint.transform.position = vec; } else { base.SetUP(_start_pos, CursorControl.instance.cursor_world_position + _vec.normalized * 5f); _hint.transform.position = CursorControl.instance.cursor_world_position; } //base.SetUP(_start_pos, CursorControl.instance.cursor_world_position); //_hint.transform.position = vec; //_hint.transform.position =CursorControl.instance.cursor_world_position; //move to the sky: transform.position = new Vector2(vec.x, vec.y + 50); }