Пример #1
0
    static public void UnlockPart(ShipPart.eShipPartType type, int num)
    {
        if (!inited)
        {
            Debug.LogWarning("ShipCustomizationPanel.UnlockPart(" + type + ", " + num + ") - "
                             + "inited = false!");
            return;
        }

        if (TOGGLE_DICT.ContainsKey(type))
        {
            if (TOGGLE_DICT[type].Length > num)
            {
                TOGGLE_DICT[type][num].UnlockPart();
            }
            else
            {
                Debug.LogWarning("ShipCustomizationPanel.UnlockPart(" + type + ", " + num + ") - "
                                 + "num is out of bounds.");
            }
        }
        else
        {
            Debug.LogWarning("ShipCustomizationPanel.UnlockPart(" + type + ", " + num + ") - "
                             + "Unexpected type.");
        }
    }
    bool SetPartNS(ShipPart.eShipPartType type, int num)
    {
        // Ensure that this is asking for an extant ship part
        if (!ShipPartsDictionary.DICT.ContainsKey(type))
        {
            Debug.LogError("ShipCustomization:SetPartNS - ShipPartsDictionary.DICT does not contain type: " + type);
            return(false);
        }
        if (!currPartsDict.ContainsKey(type))
        {
            Debug.LogError("ShipCustomization:SetPartNS - currPartsDict does not contain type: " + type);
            return(false);
        }

        if (num < 0 || ShipPartsDictionary.DICT[type].partInfos.Length <= num)
        {
            Debug.LogError("ShipCustomization:SetPartNS - Attempt to choose nonextant " + type + ": " + num);
            return(false);
        }

        // Now we know that this is a valid type and part num...
        // Pull the information from the current part in that place
        Transform  currTrans    = currPartsDict[type];
        Vector3    lPos         = currTrans.localPosition;
        Quaternion lRot         = currTrans.localRotation;
        Transform  parentTransf = currTrans.parent;

        // Generate a new part and position it correctly
        Transform newTransf = Instantiate <GameObject>(ShipPartsDictionary.DICT[type].partInfos[num].prefab).transform;

        newTransf.SetParent(parentTransf);
        newTransf.localPosition = lPos;
        newTransf.localRotation = lRot;

        // Replace the currTrans with the newTrans in the currPartsDict
        currPartsDict[type] = newTransf;

        // Destroy the old one
        Destroy(currTrans.gameObject);

        // Save the game
        SaveGameManager.Save();

        return(true);
    }
Пример #3
0
 static public void SelectPart(ShipPart.eShipPartType type, int num)
 {
     if (TOGGLE_DICT.ContainsKey(type))
     {
         if (TOGGLE_DICT[type].Length > num)
         {
             TOGGLE_DICT[type][num].isOn = true;
         }
         else
         {
             Debug.LogWarning("ShipCustomizationPanel.SelectPart(" + type + ", " + num + ") - "
                              + "num is out of bounds.");
         }
     }
     else
     {
         Debug.LogWarning("ShipCustomizationPanel.SelectPart(" + type + ", " + num + ") - "
                          + " Unexpected type!");
     }
 }
Пример #4
0
    static public int GetSelectedPart(ShipPart.eShipPartType type)
    {
        if (TOGGLE_DICT.ContainsKey(type))
        {
            foreach (ShipPartToggle spt in TOGGLE_DICT[type])
            {
                if (spt.isOn)
                {
                    return(spt.partNum);
                }
            }
        }
        else
        {
            Debug.LogWarning("ShipCustomizationPanel.GetSelectedPart(" + type + ") - "
                             + " Unexpected type!");
        }

        // Returns 0 because that is the default if nothing is selected.
        return(0);
    }
Пример #5
0
 public static bool SetPart(ShipPart.eShipPartType type, int num)
 {
     return(S.SetPartNS(type, num));
 }