Beispiel #1
0
    private void BuildClassWeapon(WeaponItem wItem, MechManager mechManager, SectionManager sectionManager, int secIndex, int subIndex, int classIndex)
    {
        if (wItem == null)
        {
            return;
        }

        /* Create the Wep */
        GameObject newWeapon = Object.Instantiate(wItem.prefab);

        newWeapon.transform.parent           = sectionManager.GetSectionLinksByIndex(secIndex, classIndex)[subIndex];
        newWeapon.transform.localPosition    = Vector3.zero;
        newWeapon.transform.localEulerAngles = Vector3.zero;

        /* Add the weapons to the MechManager on the mech encapsulating object */
        mechManager.GetWeaponObjByIndex(secIndex).Add(newWeapon);

        /* Add the ref to the parent section to the weapon's script */
        newWeapon.GetComponent <WeaponExecutable>().sectionParent = sectionManager.GetSectionByIndex(secIndex);
        newWeapon.GetComponent <WeaponExecutable>().mechManager   = mechManager;

        // Move into modify???
        /* Create an executable for the weapon and add it to MechManager ref */
        mechManager.GetExecutableByIndex(secIndex).Add(newWeapon.GetComponent <WeaponExecutable>());
    }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        mechManager    = GetComponent <MechManager>();
        mechController = GetComponent <MechController>();

        weaponGroups.Add(new WeaponGroup());
        weaponGroups.Add(new WeaponGroup());
        weaponGroups.Add(new WeaponGroup());

        for (int secIndex = (int)SectionIndex.leftArm; secIndex < (int)SectionIndex.rightShoulder; secIndex++)
        {
            weaponExecutables.AddRange(mechManager.GetExecutableByIndex(secIndex));
        }

        for (int i = 0; i < weaponExecutables.Count; i++)
        {
            weaponExecutables[i].refSystem = this;
            weaponGroups[(int)weaponExecutables[i].weaponItemRef.weaponClass].mappedWeapons.Add(weaponExecutables[i]);
        }
    }