Пример #1
0
    string UpdatePetGlobalDbURL = "http://farnorthentertainment.com/Augotchi_Petglobal.php?"; //be sure to add a ? to your url

    public IEnumerator PostPetGlobal()
    {
        Debug.LogWarning("SerializeField PVD");

        PetVisualData pvd       = PetKeeper.pet.LoadVisuals();
        string        pvdString = JsonUtility.ToJson(pvd);

        pvdString = pvdString.Replace('\"', '¤');

        string post_url = UpdatePetGlobalDbURL +
                          "id=" + SystemInfo.deviceUniqueIdentifier +
                          "&hunger=" + PetKeeper.pet.hunger +
                          "&happiness=" + PetKeeper.pet.happiness +
                          "&health=" + PetKeeper.pet.health +
                          "&markers_currency=" + PetKeeper.pet.markersCurrency +
                          "&markers_food=" + PetKeeper.pet.markersFood +
                          "&markers_crate=" + PetKeeper.pet.markersCrate +
                          "&markers_park=" + 0 +
                          "&markers_revive=" + PetKeeper.pet.markersRevive +
                          "&pet_death_count=" + PetKeeper.pet.petDeathCount +
                          "&petting_count=" + PetKeeper.pet.pettingCount +
                          "&feed_candy_count=" + PetKeeper.pet.candyFed +
                          "&feed_food_count=" + PetKeeper.pet.foodFed +
                          "&feed_vegetable_count=" + PetKeeper.pet.vegetableFed +
                          "&level=" + PetKeeper.pet.level +
                          "&start_app_count=" + PetKeeper.pet.startAppCount +
                          "&start_game_date=" + DateTime.Now.ToString("yyyy-MM-dd") +
                          "&step_counter=" + PetKeeper.pet.stepCounter +
                          "&active_ticks=" + PetKeeper.pet.activeTicks +
                          "&inactive_ticks=" + PetKeeper.pet.inactiveTicks +
                          "&pet_revival_count=" + PetKeeper.pet.petRevivalCount +
                          "&current_alive_ticks=" + PetKeeper.pet.currentAliveTicks +
                          "&longest_alive_ticks=" + PetKeeper.pet.longestAliveTicks +
                          "&pet_name=" + PetKeeper.pet.name +
                          "&pet_visual_data=" + pvdString
        ;

        // Post the URL to the site and create a download object to get the result.
        WWW pg_post = new WWW(post_url);

        yield return(pg_post); // Wait until the download is done

        if (pg_post.error != null)
        {
            Debug.LogWarning("There was an error posting the pet data: " + pg_post.error);
        }
    }
Пример #2
0
    public void Start()
    {
        PetGlobal  pg;
        GameObject petKeeper = GameObject.FindGameObjectWithTag("PetKeeper");

        if (petKeeper == null)
        {
            pg  = new PetGlobal();
            pvd = pg.LoadVisuals();
        }
        else
        {
            pvd = PetKeeper.pet.LoadVisuals();
        }

        apparelUI.pvd = pvd;

        earPicker.transform.GetChild(1).GetComponent <Text>().text = (pvd.earsIndex + 1) + "/" + petFactory.ears.Length;

        eyePicker.transform.GetChild(3).GetComponent <Text>().text = (pvd.eyesIndex + 1) + "/" + petFactory.eyes.Length;
        eyePicker.transform.GetChild(7).GetComponent <Text>().text = (pvd.eyesSizeIndex + 1) + "/" + petFactory.eyes[pvd.eyesIndex].textures.Length;

        tailPicker.transform.GetChild(1).GetComponent <Text>().text     = (pvd.tailIndex + 1) + "/" + petFactory.tails.Length;
        whiskersPicker.transform.GetChild(1).GetComponent <Text>().text = (pvd.whiskersIndex + 1) + "/" + petFactory.whiskers.Length;
        nosePicker.transform.GetChild(1).GetComponent <Text>().text     = (pvd.noseIndex + 1) + "/" + petFactory.noses.Length;

        basePicker.transform.GetChild(2).GetComponent <Text>().text   = (pvd.baseTextureIndex + 1) + "/" + petFactory.baseTextures.Length;
        basePicker.transform.GetChild(5).GetComponent <Text>().text   = (pvd.baseTint + 1) + "/" + PetVisualData.palette.Length;
        basePicker.transform.GetChild(8).GetComponent <Image>().color = PetVisualData.palette[pvd.baseTint];

        overlayPicker.transform.GetChild(2).GetComponent <Text>().text   = (pvd.overlayBlendIndex + 1) + "/" + petFactory.overLayBlends.Length;
        overlayPicker.transform.GetChild(5).GetComponent <Text>().text   = (pvd.overlayTint + 1) + "/" + PetVisualData.palette.Length;
        overlayPicker.transform.GetChild(8).GetComponent <Image>().color = PetVisualData.palette[pvd.overlayTint];
        overlayPicker.transform.GetChild(10).GetComponent <Text>().text  = (pvd.overlayTextureIndex + 1) + "/" + petFactory.baseTextures.Length;

        detailsPicker.transform.GetChild(2).GetComponent <Text>().text   = (pvd.detailsBlendIndex + 1) + "/" + petFactory.detailsBlends.Length;
        detailsPicker.transform.GetChild(5).GetComponent <Text>().text   = (pvd.DetailsTint + 1) + "/" + PetVisualData.palette.Length;
        detailsPicker.transform.GetChild(8).GetComponent <Image>().color = PetVisualData.palette[pvd.DetailsTint];
        detailsPicker.transform.GetChild(9).GetComponent <Text>().text   = (pvd.detailsTextureIndex + 1) + "/" + petFactory.baseTextures.Length;

        stage = 0;

        petFactory.buildPet(pvd);
    }
Пример #3
0
    public bool Load()
    {
        if (File.Exists(Application.persistentDataPath + "/AugotchiSave.gd"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/AugotchiSave.gd", FileMode.Open);
            PetGlobal       pg   = (PetGlobal)bf.Deserialize(file);

            hunger    = pg.hunger;
            happiness = pg.happiness;
            health    = pg.health;

            candy      = pg.candy;
            food       = pg.food;
            vegetables = pg.vegetables;

            currency          = pg.currency;
            buildingMaterials = pg.buildingMaterials;

            saveTimeStamp = pg.saveTimeStamp;

            lastPettingTimeStamp = pg.lastPettingTimeStamp;

            markerSet = pg.markerSet;

            petVisualData = pg.petVisualData;

            petUnlocksData = pg.petUnlocksData;
            if (petUnlocksData.unlockedHats.Length < PetUnlocksData.hatCounts.Length)
            {
                int[] expandedArray = new int[PetUnlocksData.hatCounts.Length];
                for (int i = 0; i < petUnlocksData.unlockedHats.Length; i++)
                {
                    expandedArray[i] = petUnlocksData.unlockedHats[i];
                }
                petUnlocksData.unlockedHats = expandedArray;
            }

            if (petUnlocksData.unlockedFaces.Length < PetUnlocksData.faceCounts.Length)
            {
                int[] expandedArray = new int[PetUnlocksData.faceCounts.Length];
                for (int i = 0; i < petUnlocksData.unlockedFaces.Length; i++)
                {
                    expandedArray[i] = petUnlocksData.unlockedFaces[i];
                }
                petUnlocksData.unlockedFaces = expandedArray;
            }

            isDead         = pg.isDead;
            reviveProgress = pg.reviveProgress;

            xp    = pg.xp;
            level = pg.level;

            if (level == 0)
            {
                level = 1;
            }

            markersCurrency = pg.markersCurrency;
            markersFood     = pg.markersFood;
            markersCrate    = pg.markersCrate;
            markersRevive   = pg.markersRevive;

            petDeathCount   = pg.petDeathCount;
            petRevivalCount = pg.petRevivalCount;

            pettingCount = pg.pettingCount;
            candyFed     = pg.candyFed;
            foodFed      = pg.foodFed;
            vegetableFed = pg.vegetableFed;

            startAppCount = pg.startAppCount;

            stepCounter = pg.stepCounter;

            activeTicks   = pg.activeTicks;
            inactiveTicks = pg.inactiveTicks;

            currentAliveTicks = pg.currentAliveTicks;
            longestAliveTicks = pg.longestAliveTicks;

            name = pg.name;

            strength     = pg.strength;
            intelligence = pg.intelligence;
            agility      = pg.agility;

            isDungeoneering       = pg.isDungeoneering;
            activeDungeon         = pg.activeDungeon;
            dungeonStartTimestamp = pg.dungeonStartTimestamp;

            if (pg.inventory != null)
            {
                this.inventory = new Inventory(
                    pg.inventory.seedCounts == null ? new int[0] : pg.inventory.seedCounts,
                    pg.inventory.produceCounts == null ? new int[0] : pg.inventory.produceCounts,
                    pg.inventory.gardenDecorCounts == null ? new int[0] : pg.inventory.gardenDecorCounts,
                    pg.inventory.uniqueCounts == null ? new int[0] : pg.inventory.uniqueCounts
                    );
            }
            else
            {
                this.inventory = new Inventory();
            }

            this.questLog = pg.questLog == null ? new List <Quest>() : pg.questLog;

            foreach (Quest q in questLog)
            {
                q.initQuestListener();
            }

            this.Base = pg.Base;

            if (pg.Base.baseGardenDecors == null)
            {
                this.Base.baseGardenDecors = new List <BaseGardenDecor>();
            }

            file.Close();

            TestPetToDatabase.postData = true;

            degenerateTick();

            return(true);
        }
        else
        {
            hunger    = 75;
            health    = 75;
            happiness = 75;

            level = 1;

            Save(false);

            return(false);
        }
    }
Пример #4
0
    public PetGlobal(
        float hunger,
        float happiness,
        float health,
        int candy,
        int food,
        int vegetables,
        long saveTimeStamp,
        long lastPettingTimeStamp,
        int currency,
        int buildingMaterials,
        Marker.MarkerType[] markerSet,
        PetVisualData petVisualData,
        PetUnlocksData petUnlocksData,
        bool isDead,
        int reviveProgress,
        int xp,
        int level,
        int markersCurrency,
        int markersFood,
        int markersCrate,
        int markersRevive,
        int petDeathCount,
        int pettingCount,
        int candyFed,
        int foodFed,
        int vegetableFed,
        int startAppCount,
        int stepCounter,
        int activeTicks,
        int inactiveTicks,
        int petRevivalCount,
        int currentAliveTicks,
        int longestAliveTicks,
        string name,
        Inventory inventory,
        List <Quest> questLog,
        Base Base,
        float strength,
        float intelligence,
        float agility,
        bool isDungeoneering,
        Dungeon activeDungeon,
        long dungeonStartTimestamp
        )
    {
        this.hunger    = hunger;
        this.happiness = happiness;
        this.health    = health;

        this.candy      = candy;
        this.food       = food;
        this.vegetables = vegetables;

        this.currency          = currency;
        this.buildingMaterials = buildingMaterials;

        this.lastPettingTimeStamp = lastPettingTimeStamp;

        this.saveTimeStamp = saveTimeStamp;

        this.markerSet = markerSet;
        this.markerRelativeDistances = markerRelativeDistances;

        this.petVisualData  = petVisualData;
        this.petUnlocksData = petUnlocksData;

        this.isDead         = isDead;
        this.reviveProgress = reviveProgress;

        this.xp    = xp;
        this.level = level;

        this.markersCurrency = markersCurrency;
        this.markersFood     = markersFood;
        this.markersCrate    = markersCrate;
        this.markersRevive   = markersRevive;

        this.petDeathCount = petDeathCount;

        this.pettingCount = pettingCount;

        this.candyFed     = candyFed;
        this.foodFed      = foodFed;
        this.vegetableFed = vegetableFed;

        this.startAppCount = startAppCount;

        this.stepCounter   = stepCounter;
        this.activeTicks   = activeTicks;
        this.inactiveTicks = inactiveTicks;

        this.petRevivalCount = petRevivalCount;

        this.currentAliveTicks = currentAliveTicks;
        this.longestAliveTicks = longestAliveTicks;

        this.name = name;

        this.inventory = inventory;
        this.questLog  = questLog;

        this.Base = Base;

        this.strength     = strength;
        this.intelligence = intelligence;
        this.agility      = agility;

        this.isDungeoneering       = isDungeoneering;
        this.activeDungeon         = activeDungeon;
        this.dungeonStartTimestamp = dungeonStartTimestamp;
    }
Пример #5
0
    public void SaveVisuals(PetVisualData petVisualData)
    {
        if (File.Exists(Application.persistentDataPath + "/AugotchiSave.gd"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/AugotchiSave.gd", FileMode.Open);
            PetGlobal       pg   = (PetGlobal)bf.Deserialize(file);

            hunger    = pg.hunger;
            happiness = pg.happiness;
            health    = pg.health;

            candy      = pg.candy;
            food       = pg.food;
            vegetables = pg.vegetables;

            currency          = pg.currency;
            buildingMaterials = pg.buildingMaterials;

            saveTimeStamp = pg.saveTimeStamp;

            lastPettingTimeStamp = pg.lastPettingTimeStamp;

            markerSet = pg.markerSet;

            petUnlocksData = pg.petUnlocksData;

            isDead         = pg.isDead;
            reviveProgress = pg.reviveProgress;

            xp    = pg.xp;
            level = pg.level;

            markersCurrency = pg.markersCurrency;
            markersFood     = pg.markersFood;
            markersCrate    = pg.markersCrate;
            markersRevive   = pg.markersRevive;

            petDeathCount   = pg.petDeathCount;
            petRevivalCount = pg.petRevivalCount;

            pettingCount = pg.pettingCount;
            candyFed     = pg.candyFed;
            foodFed      = pg.foodFed;
            vegetableFed = pg.vegetableFed;

            startAppCount = pg.startAppCount;

            stepCounter = pg.stepCounter;

            activeTicks   = pg.activeTicks;
            inactiveTicks = pg.inactiveTicks;

            currentAliveTicks = pg.currentAliveTicks;
            longestAliveTicks = pg.longestAliveTicks;

            name = pg.name;

            file.Close();

            this.petVisualData = petVisualData;

            Save(true);
        }
        else
        {
            hunger    = 75;
            happiness = 50;
            health    = 50;

            level = 1;

            this.petVisualData = petVisualData;

            Save(false);
        }
    }
Пример #6
0
    public void buildPet(PetVisualData petVisualData)
    {
        earsRenderer.sharedMesh = ears[petVisualData.earsIndex];
        tailRenderer.sharedMesh = tails[petVisualData.tailIndex];

        Material baseMat = baseRenderer.materials[0];

        baseMat.SetTexture("_MainTex", baseTextures[petVisualData.baseTextureIndex]);
        baseMat.SetTexture("_OffTex", baseTextures[petVisualData.overlayTextureIndex]);
        baseMat.SetTexture("_MiscTex", baseTextures[petVisualData.detailsTextureIndex]);

        baseMat.SetTexture("_MapTex", baseBlends[0]);
        baseMat.SetTexture("_MapTex2", overLayBlends[petVisualData.overlayBlendIndex]);
        baseMat.SetTexture("_MapTex3", detailsBlends[petVisualData.detailsBlendIndex]);

        baseMat.SetColor("_Color", PetVisualData.palette[petVisualData.baseTint]);
        baseMat.SetColor("_Color2", PetVisualData.palette[petVisualData.overlayTint]);
        baseMat.SetColor("_Color3", PetVisualData.palette[petVisualData.DetailsTint]);

        /*baseMat.SetColor("_Color", PetVisualData.palette[0]);
         * baseMat.SetColor("_Color2", PetVisualData.palette[7]);
         * baseMat.SetColor("_Color3", PetVisualData.palette[14]);*/

        Material eyesMat = baseRenderer.materials[3];

        eyesMat.SetTexture("_MainTex", eyes[petVisualData.eyesIndex].textures[petVisualData.eyesSizeIndex]);

        Material noseMat = baseRenderer.materials[1];

        noseMat.SetTexture("_MainTex", noses[petVisualData.noseIndex]);

        Material whiskerMat = baseRenderer.materials[2];

        whiskerMat.SetTexture("_MainTex", whiskers[petVisualData.whiskersIndex]);
        whiskerMat.SetColor("_Color", PetVisualData.palette[petVisualData.DetailsTint]);

        Material[] mats = new Material[] { baseMat, noseMat, whiskerMat, eyesMat };
        baseRenderer.materials = mats;

        Material[] peripheryMats = new Material[] { baseMat };
        earsRenderer.materials = peripheryMats;
        tailRenderer.materials = peripheryMats;

        foreach (Transform t in hatParent)
        {
            Destroy(t.gameObject);
        }

        try
        {
            GameObject hat = (GameObject)Instantiate(hats[petVisualData.hatIndex].gameObjects[petVisualData.hatVariation]);
            hat.transform.SetParent(hatParent, false);
        }
        catch (IndexOutOfRangeException e)
        {
            petVisualData.hatIndex     = 0;
            petVisualData.hatVariation = 0;
        }

        foreach (Transform t in faceParent)
        {
            Destroy(t.gameObject);
        }

        try
        {
            GameObject face = (GameObject)Instantiate(faces[petVisualData.faceIndex].gameObjects[petVisualData.faceVariations]);
            face.transform.SetParent(faceParent, false);
        }catch (IndexOutOfRangeException e)
        {
            petVisualData.faceIndex      = 0;
            petVisualData.faceVariations = 0;
        }
    }