#Assets into custom cs script as preset for weapon damage or effects

1 messages · Page 1 of 1 (latest)

woeful python
#

Here's what i have so far, i want to be able to create a Sword asset in my project files that i can then put into the Sword Effect Manager script, like how the SpriteRenderer let's you select an image and load it in

#

SwordEffect.cs

using System.Collections.Generic;
using UnityEngine;

public class SwordEffect : MonoBehaviour
{
    //Variables
    public string bladeName;
    public float speedMulti;
    public float damageMulti;
    //public image bladeSprite;
}
#

SwordEffectManager.cd

using System.Linq; // stringArray.Contains
using System.Collections.Generic;
using UnityEngine;

public class SwordEffectManager : MonoBehaviour
{
    //Variables
    public List<string> statusEffectNames;
    public List<SwordEffect> statusEffects;
    
    // Start is called before the first frame update
    void Start()
    {
        reloadSwordEffects();
        
    }
    public void CheckWordEffect(string word){
        if(statusEffectNames.Contains(word)){
            Debug.Log("VALID WORD FOUND");
        } else{
            Debug.Log("nope!");
        }
    }
    

    public void reloadSwordEffects(){
        foreach (SwordEffect effect in statusEffects)
        {
           statusEffectNames.Add(effect.bladeName);
           Debug.Log("Loaded Blade Type: '" + effect.bladeName + "'");
        }
        Debug.Log("#=# Loaded All Blades #=#");
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
#

Sword.cs

using System.Collections.Generic;
using UnityEngine;

public class Sword : MonoBehaviour
{
    //Variables
    //this will be on the player, when they atack, it will get the multipliers/data from the effect via here
    public SwordEffectManager sem;
    
    
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}```
#

SwordLetterManager.cs

using System.Linq; // stringArray.Contains
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SwordLetterManager : MonoBehaviour
{
    //Variables
    public InputField[] letters;
    public string word;

    public SwordEffectManager playerSEM;
    
    
    // Start is called before the first frame update
    void Start()
    {
        
    }

    public void updateWord(){
        word = "";
        foreach (InputField letter in letters)
        {
            word = word + letter.text.ToString();
        }
        Debug.Log("word has been updated, is now: " + word);

        playerSEM.CheckWordEffect(word);
    }


    
    // Update is called once per frame
    void Update()
    {
        
    }
}
#

If possible, it would be great to be able to make them via the rightClick>Create menu as well if that's a thing i can do