void PickUpAmmo(PickupRespawn pickup) { int extraAmmo = pickup.GetComponent <AmmoPickup> ().Value; Base_Weapon ammoWeapon = currentWeapon; // if lemon -- refill secondary : if weapon is full, return, else fill. if (currentWeapon.HasUnlimitedAmmo) { ammoWeapon = (currentWeapon == primaryWeapon ? secondaryWeapon : primaryWeapon); } if (ammoWeapon.IsFull) { return; } ammoWeapon.AddAmmo(extraAmmo); if (playerUI != null) { playerUI.UpdateAmmoCounter(currentWeapon.Ammo, currentWeapon.MaxAmmo); } pickup.StartRespawnTimer(); }
void PickUpWeapon(PickupRespawn pickup) { if (currentWeapon == primaryWeapon) { primaryWeapon = null; } else { secondaryWeapon = null; } Destroy(currentWeapon); currentWeapon = null; { GameObject temp = Instantiate(pickup.GetComponent <PickupGun> ().gun, transform); currentWeapon = temp.GetComponent <Base_Weapon> (); } if (primaryWeapon == null) { primaryWeapon = currentWeapon; } else { secondaryWeapon = currentWeapon; } currentWeapon.GetComponent <PlayerTag>().SetId(GetPlayerTag().Id); currentWeapon.GetComponent <PlayerTag>().SetTeam(GetPlayerTag().Team); UpdateAmmoUI(currentWeapon.Ammo, currentWeapon.MaxAmmo, !currentWeapon.HasUnlimitedAmmo); pickup.StartRespawnTimer(); }
public void Init_Weapon() { Base_Weapon _Weapon = weapon.GetComponent <Base_Weapon>(); if (_Weapon is Weapon_Sword) { range = 0.5f; attack_range = new Vector2(3.5f, 1.5f); cm.SetAttackUI(0); } if (_Weapon is Weapon_Spear) { range = 0.5f; attack_range = new Vector2(5f, 0.5f); cm.SetAttackUI(1); //projectile.transform.GetChild(0).GetComponent<SpriteRenderer>().sprite = Resources.Load(weapon.spritePath, typeof(Sprite)) as Sprite; } if (_Weapon is Weapon_Bow) { range = 0.1f; attack_range = new Vector2(2f, 1f); cm.SetAttackUI(2); } power = _Weapon.power; }
public void Attack() //근접 공격 함수 { Base_Weapon _weapon = weapon.GetComponent <Base_Weapon>(); if (IsAttackDelay() == false) { return; } Debug.Log(_weapon.m_title + " 공격!"); d_weapon = _weapon.delay; SoundManager soundManager = FindObjectOfType <SoundManager>(); string soundStr = checkWeaponSound(_weapon); soundManager.Play(soundStr + "attack"); Collider2D[] collider2Ds = Physics2D.OverlapBoxAll(attack_pos.position, attack_range, 0); for (int i = 0; i < collider2Ds.Length; i++) { if (collider2Ds[i].tag == "Monster") { //Debug.Log("Monster Hit!"); GameObject obj = collider2Ds[i].gameObject; //Monster 데미지 처리 if (obj.GetComponent <MonsterParent>().myMonsterInfo.monsterState != MonsterState.DEAD) { obj.GetComponent <MonsterParent>().MonsterHitWeapon(power); soundManager.Play(soundStr + "hit"); FindObjectOfType <ParticleSupplier>().SetParticle(obj.gameObject.transform.position, "enemy_hit"); } } } }
public Weapon_Bow GetWeapon_Bow(SpawnCode weaponCode, GameObject _child) { if (!unlock.CheckCode(weaponCode)) { return(null); } Base_Weapon dump = _child.GetComponent <Base_Weapon>(); if (dump != null) { Destroy(dump); } Weapon_Bow tmp; switch (weaponCode) { case SpawnCode.W201: tmp = _child.AddComponent <Bow_Default>(); break; case SpawnCode.W202: tmp = _child.AddComponent <Bow_NoMoney>(); break; case SpawnCode.W203: tmp = _child.AddComponent <Bow_Dryed>(); break; case SpawnCode.W204: tmp = _child.AddComponent <Bow_Long>(); break; case SpawnCode.W205: tmp = _child.AddComponent <Bow_Apollo>(); break; default: return(null); } //여기에 라우터로 장비 바꿨다는 포스트 날려야함 return(tmp); }
void Awake() { playerUI = GetComponent <PlayerUI> (); primaryWeapon = GetComponent <Base_Weapon> (); secondaryWeapon = GetComponentInChildren <Base_Weapon> (); currentWeapon = primaryWeapon; if (playerUI != null) { playerUI.ShowAmmo(!currentWeapon.HasUnlimitedAmmo); playerUI.UpdateAmmoCounter(currentWeapon.Ammo, currentWeapon.MaxAmmo); } }
private string checkWeaponSound(Base_Weapon weapon) { if (weapon is Weapon_Sword) { return("sword_"); } else if (weapon is Weapon_Spear) { return("spear_"); } else if (weapon is Weapon_Bow) { return("bow_"); } else { return("error"); } }
public void Attack(float angle, Vector2 dir) //원거리 공격 함수 { Base_Weapon _weapon = weapon.GetComponent <Base_Weapon>(); if (IsAttackDelay() == false) { return; } Debug.Log(_weapon.m_title + " 공격!"); d_weapon = _weapon.delay; SoundManager soundManager = FindObjectOfType <SoundManager>(); string soundStr = checkWeaponSound(_weapon); soundManager.Play(soundStr + "attack"); GameObject obj = Instantiate(projectile, attack_pos.position, Quaternion.Euler(0f, 0f, angle)); Arrow ar = obj.GetComponent <Arrow>(); ar.power = _weapon.power; ar.spritePath = _weapon.m_spritePath; Rigidbody2D rid = obj.GetComponent <Rigidbody2D>(); if (_weapon is Weapon_Spear) { rid.bodyType = RigidbodyType2D.Kinematic; rid.velocity = dir * ((Weapon_Spear)_weapon).speed; ar.destroyDelay = 1.0f; } else if (_weapon is Weapon_Bow) { dir += new Vector2(0f, 0.2f); rid.bodyType = RigidbodyType2D.Dynamic; rid.velocity = dir * ((Weapon_Bow)_weapon).speed; } }
protected override void Start() { base.Start(); brainWeapon = GetComponent <Base_Weapon> (); }
public void ClosetBoardSetting() // 선택된 장비 { int index; if (lastClickSlot == 0) { index = closetSlide1Script.index; } else if (lastClickSlot == 1) { index = closetSlide2Script.index; } else { index = closetSlide3Script.index; } //선택된 장비 가져오기 //리스트에서 현재 선택된 장비의 인덱스 찾아 저장해두고 UI 출력 if (lastClickSlot == 0) { for (int i = 0; i < list_weapon.Count; i++) { if (list_weapon[i].m_code == ps.weapon.GetComponent <Base_Weapon>().m_code) { useItemIndex[0] = i; Base_Weapon bw = list_weapon[i]; //closetSlide1Script.closetSlotImageArray = new RectTransform[list_weapon.Count]; //itemImage.sprite = itemNameText.text = bw.m_title; itemValueText1.text = "공격력 : " + bw.power.ToString(); //itemValueText2.text = //itemValueText3.text = //itemValueText4.text = itemSlider.value = bw.dualbility / 100.0f; itemDurability.text = bw.dualbility.ToString(); closetSlide1Script.closetSlotImageArray[i + 2].GetChild(1).GetComponent <Image>().enabled = true; } nowitemNameText.text = list_weapon[index].m_title; nowitemValueText1.text = "공격력 : " + list_weapon[index].power.ToString(); nowitemSlider.value = list_weapon[index].dualbility / 100.0f; nowitemDurability.text = list_weapon[index].dualbility.ToString(); nowitemdescription.text = list_weapon[index].m_description; } } else if (lastClickSlot == 1) { for (int i = 0; i < list_amulet.Count; i++) { //Debug.Log("착용 무기 : " + ps.armor.GetComponent<Armor_Amulet>().m_title); //Debug.Log("현재 인덱스 무기 : " + list_amulet[i].m_title); if (list_amulet[i].m_code == ps.armor.GetComponent <Armor_Amulet>().m_code) { useItemIndex[1] = i; Base_Armor amulet = list_amulet[i]; //closetSlide1Script.closetSlotImageArray = new RectTransform[list_weapon.Count]; //itemImage.sprite = itemNameText.text = amulet.m_title; itemValueText1.text = amulet.value.ToString(); //itemValueText2.text = //itemValueText3.text = //itemValueText4.text = itemSlider.value = amulet.dualbility / 100.0f; itemDurability.text = amulet.dualbility.ToString(); closetSlide2Script.closetSlotImageArray[i + 2].GetChild(1).GetComponent <Image>().enabled = true; } nowitemNameText.text = list_amulet[index].m_title; nowitemValueText1.text = list_amulet[index].value.ToString(); nowitemSlider.value = list_amulet[index].dualbility / 100.0f; nowitemDurability.text = list_amulet[index].dualbility.ToString(); nowitemdescription.text = list_amulet[index].m_description; } } else { for (int i = 0; i < list_stone.Count; i++) { if (list_stone[i].m_code == ps.armor.GetComponent <Armor_Stone>().m_code) { useItemIndex[2] = i; Base_Armor stone = list_stone[i]; //closetSlide1Script.closetSlotImageArray = new RectTransform[list_weapon.Count]; //itemImage.sprite = itemNameText.text = stone.m_title; nowitemValueText1.text = stone.value.ToString(); //itemValueText2.text = //itemValueText3.text = //itemValueText4.text = itemSlider.value = stone.dualbility / 100.0f; itemDurability.text = stone.dualbility.ToString(); closetSlide3Script.closetSlotImageArray[i + 2].GetChild(1).GetComponent <Image>().enabled = true; } } nowitemNameText.text = list_stone[index].m_title; nowitemValueText1.text = list_stone[index].value.ToString(); nowitemSlider.value = list_stone[index].dualbility / 100.0f; nowitemDurability.text = list_stone[index].dualbility.ToString(); nowitemdescription.text = list_stone[index].m_description; } }
public void SetSender(Base_Weapon weapon) { sender = weapon; }