public bool CheckCompatibility(WeaponComponentType type)
    {
        foreach (WeaponComponentType wct in compatibleWeaponComponentTypes)
        {
            if (wct.name == type.name)
            {
                return(true);
            }
        }

        return(false);
    }
    public void DropWeaponComponent()
    {
        Debug.Log("weapon component dropped");
        WeaponComponentType componentType = rewardSet.RollForDrop();

        //The only reason why the function above would return null is if the function decided that there would be no weapon components to give at all.
        if (componentType == null)
        {
            gameObject.SetActive(false);
        }
        else
        {
            //If the function has decided to give the player something, then activate, and assign:
            weaponComponentToGive = componentType;
            gameObject.SetActive(true);
        }
    }
    public void ActivateWeaponComponent(WeaponComponentType weaponComponentToActivate)
    {
        if (weaponType.CheckCompatibility(weaponComponentToActivate) == false)
        {
            return;
        }

        Debug.Log(weaponComponentToActivate.name + " will be activated!");

        foreach (WeaponComponent wc in allAvailableWeaponComponents)
        {
            if (wc.weaponComponentType.name == baseType.name)
            {
                continue;
            }

            if (weaponComponentToActivate.name == wc.weaponComponentType.name)
            {
                Debug.Log(weaponComponentToActivate.name + " was activated in " + gameObject.name);
                wc.gameObject.SetActive(true);
            }
        }
    }
Exemplo n.º 4
0
    //All that this editor script does is automatically add new types of weapon component types
    //to the weapon type scriptable object:
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        WeaponComponentActivator inspectedObject = (WeaponComponentActivator)target;

        //Gotta clear out the array in the scriptable object first (just to be safe):
        inspectedObject.weaponType.compatibleWeaponComponentTypes = null;

        //Then make an empty, temporary list for weapon component types:
        List <WeaponComponentType> temp = new List <WeaponComponentType>();

        foreach (Transform t in inspectedObject.transform)
        {
            //Pulls the weapon component from each child in the inspected weapon,
            //and add them to a temporary list of weapon component types:
            WeaponComponent weaponComponent = t.GetComponent <WeaponComponent>();
            if (weaponComponent != null)
            {
                //Use a local for the weaponComponentType to make the code look clean:
                WeaponComponentType weaponComponentType = weaponComponent.weaponComponentType;

                //Makes sure that the component being added is a unique weaponComponent:
                if (temp.Contains(weaponComponentType) == false)
                {
                    temp.Add(weaponComponentType);
                }
            }
            else
            {
                continue;
            }
        }

        //Use that temporary list of weapon component types to fill the array in the weapon type scriptable object
        inspectedObject.weaponType.compatibleWeaponComponentTypes = temp.ToArray();
    }
 public void ActivateModuleInActiveWeapon(WeaponComponentType weaponComponentType)
 {
     Debug.Log("Activated Module: " + weaponComponentType.name);
     WeaponComponentActivator.activeInstance.ActivateWeaponComponent(weaponComponentType);
 }
Exemplo n.º 6
0
 protected virtual bool InitWeaponComponent(WeaponComponentType type)
 {
     SetUpConnectable(ParentConnectorTransform, ChildrenConnectorTransform);
     ComponentType = type;
     return(true);
 }