﻿<?xml version="1.0" encoding="utf-8" ?>
<c2eventsheet>
    <!--All the 'name' attributes are ignored by Construct 2 - they are there for readability only.-->
    <name>GameDataManager</name>
    <events>
        <event-block sid="4873743678709722">
            <conditions>
                <condition id="-2" name="On start of layout" sid="6952416133328881" type="System" />
            </conditions>
            <actions>
                <action disabled="1" id="3" name="Clear storage" sid="3524967130979551" type="gameData" />
            </actions>
        </event-block>
        <comment>When gameData exist on the localStorage we load it on the correspondant dictionnary.</comment>
        <event-block sid="2867409826547406">
            <conditions>
                <condition id="1" name="On item get" sid="3103465157011323" type="gameData">
                    <param id="0" name="Key">&quot;gameData_&quot;&amp;LOCAL_STORAGE_ID</param>
                </condition>
            </conditions>
            <actions />
            <sub-events>
                <event-block sid="5761613882423946">
                    <conditions>
                        <condition id="12" name="Compare value" sid="4700820954206698" type="gameData">
                            <param id="0" name="Comparison">1</param>
                            <param id="1" name="Value">&quot;&quot;</param>
                        </condition>
                    </conditions>
                    <actions>
                        <action id="4" name="Load" sid="7318867536429206" type="gameDataDic">
                            <param id="0" name="JSON">gameData.ItemValue</param>
                        </action>
                    </actions>
                </event-block>
                <event-block sid="4800743724965566">
                    <conditions />
                    <actions>
                        <action id="-16" name="Wait" sid="9287306292334354" type="System">
                            <param id="0" name="Seconds">0</param>
                        </action>
                        <action id="-42" name="Signal" sid="6968119049276641" type="System">
                            <param id="0" name="Tag">&quot;gameDataLoaded&quot;</param>
                        </action>
                    </actions>
                </event-block>
            </sub-events>
        </event-block>
        <comment>Description: Initialize the game data.</comment>
        <event-block sid="4298991607482496">
            <conditions>
                <condition id="0" name="On function" sid="1989597000674597" type="Function">
                    <param id="0" name="Name">&quot;initGameData&quot;</param>
                </condition>
            </conditions>
            <actions>
                <action id="0" name="Add key" sid="87680341112233" type="gameDataDic">
                    <param id="0" name="Key">&quot;musicEnabled&quot;</param>
                    <param id="1" name="Value">1</param>
                </action>
                <action id="0" name="Add key" sid="1070243012943542" type="gameDataDic">
                    <param id="0" name="Key">&quot;soundEnabled&quot;</param>
                    <param id="1" name="Value">1</param>
                </action>
                <action id="0" name="Add key" sid="1228850915876723" type="gameDataDic">
                    <param id="0" name="Key">&quot;bestScore&quot;</param>
                    <param id="1" name="Value">0</param>
                </action>
            </actions>
        </event-block>
        <comment>Description: Save the content of gameDataDic into localStorage.</comment>
        <event-block sid="9304522369495028">
            <conditions>
                <condition id="0" name="On function" sid="7015713211927436" type="Function">
                    <param id="0" name="Name">&quot;saveGameData&quot;</param>
                </condition>
            </conditions>
            <actions>
                <action id="0" name="Set item" sid="6659778907568524" type="gameData">
                    <param id="0" name="Key">&quot;gameData_&quot;&amp;LOCAL_STORAGE_ID</param>
                    <param id="1" name="Value">gameDataDic.AsJSON</param>
                </action>
            </actions>
        </event-block>
        <event-block sid="5238058033945359">
            <conditions>
                <condition id="0" name="On function" sid="371624148283151" type="Function">
                    <param id="0" name="Name">&quot;loadGameData&quot;</param>
                </condition>
            </conditions>
            <actions />
            <sub-events>
                <event-block sid="4494747766327084">
                    <conditions>
                        <condition id="4" name="Is empty" sid="5128363661533587" type="gameDataDic" />
                    </conditions>
                    <actions>
                        <action id="0" name="Call function" sid="9816178947957945" type="Function">
                            <param id="0" name="Name">&quot;initGameData&quot;</param>
                            <param id="1" name="Parameter {n}"></param>
                        </action>
                        <action disabled="1" id="-16" name="Wait" sid="4130977728310737" type="System">
                            <param id="0" name="Seconds">0</param>
                        </action>
                        <action id="1" name="Get item" sid="4689889314894191" type="gameData">
                            <param id="0" name="Key">&quot;gameData_&quot;&amp;LOCAL_STORAGE_ID</param>
                        </action>
                    </actions>
                </event-block>
                <event-block sid="427675631807136">
                    <conditions>
                        <condition id="-22" name="Else" sid="4134540241213197" type="System" />
                    </conditions>
                    <actions>
                        <action id="-16" name="Wait" sid="7029934086561604" type="System">
                            <param id="0" name="Seconds">0</param>
                        </action>
                        <action id="-42" name="Signal" sid="9946956857541124" type="System">
                            <param id="0" name="Tag">&quot;gameDataLoaded&quot;</param>
                        </action>
                    </actions>
                </event-block>
            </sub-events>
        </event-block>
    </events>
</c2eventsheet>
