/// <inheritdoc cref="BowWeaponItem"/> public override void Attack() { if (Projectile == null || !CanAttack) { return; } var projectile = MonoUtil.Load(Projectile); projectile.transform.position = Util.GetCharacterTransform().position; projectile.transform.right = Util.GetDirectionTowardsCursor(projectile.transform); // Updates texture for dagger try { projectile.transform.GetChild(0).GetChild(0).GetComponent <SpriteRenderer>().sprite = Info.Prefabs[0].transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; } catch (Exception) { // ignored } SetCollDown(); MonoUtil.Remove(projectile, 6); Durability -= EquipableData.DurabilityReducer; }
/// <inheritdoc cref="SimpleItem"/> public override void Use() { base.Use(); var particle = MonoUtil.Load(Info.Prefabs[0]); var parent = GameObject.FindGameObjectWithTag("Player"); particle.transform.parent = parent.transform; particle.transform.localPosition = Vector3.zero; }
/// <summary> /// Loads object into game world when mounted /// </summary> /// <returns>Whether or not item was successfully mounted</returns> protected override bool OnMount() { if (Info.Prefabs.Length > 1) { _cachedInstance = MonoUtil.Load(Info.Prefabs[1]); _cachedInstance.transform.parent = Camera.main.transform; _cachedInstance.GetComponent <InstantiableWeaponController>().Item = this; _cachedInstance.transform.localPosition = new Vector3(0, 0, _cachedInstance.transform.localPosition.z); } return(base.OnMount()); }
/// <summary> /// Adds visual effect onto player when used /// TODO: Better effect fetcher /// </summary> protected virtual void LoadEffect() { var effectName = "healing"; if (PotionInfo.EffectAmount.Magic > 0) { effectName = "healing_mp"; } var effectPrefab = Resources.Load <GameObject>($"Prefabs/Player/Effects/prefab_player_effect_{effectName}"); var effect = MonoUtil.Load(effectPrefab); effect.transform.position = Util.GetCharacterTransform().position; effect.transform.parent = Camera.main.transform; MonoUtil.Remove(effect, 3); }
/// <summary> /// Initiates projectile towards mouse /// </summary> public override void Attack() { if (Projectile == null || !CanAttack) { return; } var projectile = MonoUtil.Load(Projectile); projectile.transform.position = Util.GetCharacterTransform().position; projectile.transform.right = Util.GetDirectionTowardsCursor(projectile.transform); MonoUtil.Remove(projectile, 12); SetCollDown(); base.Attack(); }
/// <inheritdoc cref="WeaponItem"/> public override void Attack() { if (AttackPrefab == null || !CanAttack) { return; } // Loads attack animation var attack = MonoUtil.Load(AttackPrefab); attack.transform.position = Util.GetCharacterTransform().position; attack.transform.right = Util.GetDirectionTowardsCursor(attack.transform); attack.transform.parent = Camera.main.transform; // Moves character toward mouse direction var character = Util.GetCharacter; character.GetComponent <Rigidbody2D>().AddForce(Util.GetDirectionTowardsCursor(character.transform) * 50); if (!_usedDefault) { return; } // Updates texture of sword for default attack try { attack.transform.GetChild(0).GetChild(0).GetComponent <SpriteRenderer>().sprite = Info.Prefabs[0].transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; } catch (Exception) { // Ignored } SetCollDown(); base.Attack(); }