コード例 #1
0
ファイル: PetFactory.cs プロジェクト: DigohD/Augotchi
    private void filterUnlockedFaces(PetUnlocksData pud)
    {
        GameObjectList[] unlockedFaces  = new GameObjectList[faces.Length];
        ArrayList        extractedFaces = new ArrayList();

        unlockedFaces[0] = faces[0];

        for (int i = 1; i < faces.Length; i++)
        {
            unlockedFaces[i] = new GameObjectList();
            extractedFaces.Clear();

            for (int j = 0; j < faces[i].gameObjects.Length; j++)
            {
                if (pud.isFaceUnlocked(i, j))
                {
                    extractedFaces.Add(faces[i].gameObjects[j]);
                }
            }

            unlockedFaces[i].gameObjects = new GameObject[extractedFaces.Count];
            for (int k = 0; k < extractedFaces.Count; k++)
            {
                unlockedFaces[i].gameObjects[k] = (GameObject)extractedFaces[k];
            }
        }

        unlockedFaces = unlockedFaces.Where(fl => fl.gameObjects.Length > 0).ToArray();

        faces = unlockedFaces;
    }
コード例 #2
0
ファイル: PetFactory.cs プロジェクト: DigohD/Augotchi
    private void filterUnlockedHats(PetUnlocksData pud)
    {
        GameObjectList[] unlockedHats  = new GameObjectList[hats.Length];
        ArrayList        extractedHats = new ArrayList();

        unlockedHats[0] = hats[0];

        for (int i = 1; i < hats.Length; i++)
        {
            unlockedHats[i] = new GameObjectList();
            extractedHats.Clear();

            for (int j = 0; j < hats[i].gameObjects.Length; j++)
            {
                if (pud.isHatUnlocked(i, j))
                {
                    extractedHats.Add(hats[i].gameObjects[j]);
                }
            }

            unlockedHats[i].gameObjects = new GameObject[extractedHats.Count];
            for (int k = 0; k < extractedHats.Count; k++)
            {
                unlockedHats[i].gameObjects[k] = (GameObject)extractedHats[k];
            }
        }

        unlockedHats = unlockedHats.Where(hl => hl.gameObjects.Length > 0).ToArray();

        hats = unlockedHats;
    }
コード例 #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 void Save(bool ignoreTime)
    {
        if (!ignoreTime)
        {
            saveTimeStamp = System.DateTime.Now.Ticks;
        }

        if (petUnlocksData == null)
        {
            petUnlocksData = new PetUnlocksData();
        }

        if (Base == null)
        {
            Base = new Base();
        }

        if (inventory == null)
        {
            inventory = new Inventory();
        }

        if (questLog == null)
        {
            questLog = new List <Quest>();
        }

        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/AugotchiSave.gd");

        bf.Serialize(file,
                     new PetGlobal(
                         hunger,
                         happiness,
                         health,
                         candy,
                         food,
                         vegetables,
                         saveTimeStamp,
                         lastPettingTimeStamp,
                         currency,
                         buildingMaterials,
                         markerSet,
                         petVisualData,
                         petUnlocksData,
                         isDead,
                         reviveProgress,
                         xp,
                         level,
                         markersCurrency,
                         markersFood,
                         markersCrate,
                         markersRevive,
                         petDeathCount,
                         pettingCount,
                         candyFed,
                         foodFed,
                         vegetableFed,
                         startAppCount,
                         stepCounter,
                         activeTicks,
                         inactiveTicks,
                         petRevivalCount,
                         currentAliveTicks,
                         longestAliveTicks,
                         name,
                         inventory,
                         questLog,
                         Base,
                         strength,
                         intelligence,
                         agility,
                         isDungeoneering,
                         activeDungeon,
                         dungeonStartTimestamp
                         ));
        file.Close();

        TestPetToDatabase.postData = true;

        PetNotificationHandeler.PlanNotification(this);
    }
コード例 #5
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;
    }
コード例 #6
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);
        }
    }
コード例 #7
0
ファイル: PetFactory.cs プロジェクト: DigohD/Augotchi
 private void filterUnlocks(PetUnlocksData pud)
 {
     filterUnlockedHats(pud);
     filterUnlockedFaces(pud);
 }