Example #1
0
 public void RemoveHat(SaveHat hat)
 {
     if (hat.saveFileId == currentlyLoadedSaveFile)
     {
         wearingHat = false;
     }
 }
Example #2
0
    public static void BuildFlair(SaveHat curHat)
    {
        SaveHatListEntry curData = GetSaveFile(curHat.saveFileId);

        if (curData != null)
        {
            BuildFlair(curHat, curData);
        }
    }
Example #3
0
 public bool WearHat(SaveHat hat)
 {
     if (!wearingHat || hat.saveFileId == currentlyLoadedSaveFile)
     {
         currentlyLoadedSaveFile = hat.saveFileId;
         wearingHat = true;
         return(true);
     }
     return(false);
 }
Example #4
0
    internal static void AddFlair(SaveHat saveHat, HatFlair flair)
    {
        SaveHatListEntry curData = null;

        if (!saveData.saveHats.ContainsKey(saveHat.saveFileId))
        {
            Debug.LogError("Invalid save file ID: " + saveHat.saveFileId, saveHat);
            return;
        }
        curData = saveData.saveHats[saveHat.saveFileId];
        curData.flair.Add(new SaveHatFlairEntry(saveHat.gameObject, flair));
        Debug.Log("Added flair " + flair.FlairId + " to hat " + saveHat.saveFileId);
        Save();
    }
Example #5
0
 public static void BuildFlair(SaveHat curHat, SaveHatListEntry curData)
 {
     if (curHat.flairLoaded)
     {
         return;
     }
     curHat.flairLoaded = true;
     foreach (var entry in curData.flair)
     {
         HatFlair newFlair = ConstructFlair(curHat.transform, entry);
         newFlair.GetComponent <Sticky>().AttachToBody(curHat.GetComponent <Rigidbody>());
         Debug.Log("Restored flair " + newFlair.FlairId + " to hat " + curHat.saveFileId);
     }
 }
Example #6
0
    internal static void RemoveFlair(SaveHat saveHat, HatFlair flair)
    {
        SaveHatListEntry curData = null;

        if (!saveData.saveHats.ContainsKey(saveHat.saveFileId))
        {
            Debug.LogError("Invalid save file ID: " + saveHat.saveFileId, saveHat);
            return;
        }
        curData = saveData.saveHats[saveHat.saveFileId];
        var removedCount = curData.flair.RemoveAll(new FlairIdSearch(flair.FlairId).Matches);

        Debug.Log("Removed flair " + flair.FlairId + " from hat " + saveHat.saveFileId + "; removedCount=" + removedCount);
        Save();
    }
Example #7
0
    private void BuildHats()
    {
        int   hatId       = 100 * shelfIndex;
        float shelfWidth  = GetComponent <Collider>().bounds.extents.z * 2;
        float spacePerHat = shelfWidth / hatCount;
        float yPos        = GetComponent <Collider>().bounds.extents.y;

        for (int i = 0; i < hatCount; i++)
        {
            // If the player is already wearing the hat we're about to build, don't build it
            if (LevelManager.Instance.wearingHat && LevelManager.Instance.currentlyLoadedSaveFile == hatId + i)
            {
                continue;
            }
            SaveHatListEntry curData = null;
            if (saveData.saveHats.ContainsKey(hatId + i))
            {
                curData = saveData.saveHats[hatId + i];
            }
            if (curData == null)
            {
                curData = new SaveHatListEntry();
                float hue   = lowHueRange + (((highHueRange - lowHueRange) / hatCount) * i);
                Color color = Color.HSVToRGB(hue, 1f, 1f);
                curData.r     = color.r;
                curData.g     = color.g;
                curData.b     = color.b;
                curData.flair = new List <SaveHatFlairEntry>();
                curData.coins = 2;
                saveData.saveHats[hatId + i] = curData;
                Debug.Log("Creating new hat. hue=" + hue + ", id=" + (hatId + i));
            }
            Vector3 position = new Vector3(0, yPos, spacePerHat / 2 + spacePerHat * i - (shelfWidth / 2));
            SaveHat curHat   = (SaveHat)Instantiate(hatPrefab, position + transform.position, Quaternion.Euler(0, -160, 0));
            //Debug.Log("Instantiated hat", curHat);
            curHat.SetColor(new Color(curData.r, curData.g, curData.b));
            curHat.saveFileId = hatId + i;
            BuildFlair(curHat, curData);
        }
    }