Esempio n. 1
0
    /**
     * <summary>
     * On change button clicked
     * </summary>
     *
     * <returns>
     * void
     * </returns>
     */
    protected override void OnChangeButtonClicked()
    {
        GameObject helicopterGameObject = UnitsManager.ActiveUnit;
        Helicopter helicopter           = helicopterGameObject.GetComponent <Helicopter>();

        // Remove / destroy the old weapon
        helicopter.RemoveWeapon();

        // Get the new reference weapon
        GameObject   selectedWeaponItemUI = WeaponItemsManager.SelectedWeaponItemUI;
        WeaponItemUI weaponItemUI         = selectedWeaponItemUI.GetComponent <WeaponItemUI>();
        GameObject   referenceWeapon      = weaponItemUI.GetReferencePrefab();

        // Add / create a new weapon
        // Creating a new weapon by the reference and set its parent to the helicopter
        helicopter.CreateAndSetWeaponPart(referenceWeapon);
    }