Ejemplo n.º 1
0
            /// <summary>
            /// 저장하기
            /// </summary>
            /// <param name="data"></param>
            public void Save(GameData saveData)
            {
                BinaryFormatter bf   = new BinaryFormatter();
                FileStream      file = File.Create(dataPath);

                ////데이터 저장
                //GameData data = new GameData();

                data.sceneName = saveData.sceneName;
                //캐릭터
                data.hp       = saveData.hp;
                data.maxHp    = saveData.maxHp;
                data.speed    = saveData.speed;
                data.isLive   = saveData.isLive;
                data.isFire   = saveData.isFire;
                data.isReload = saveData.isReload;
                data.isStop   = saveData.isStop;

                //Debug.Log("weaponeLength " + data.weaponeData.Length);

                //무기
                data.weaponeList.Clear(); //리스트를 한번 정리해준다
                for (int i = 0; i < saveData.weaponeList.Count; i++)
                {
                    //Debug.Log("saveData : " + saveData.weaponeData[i].id);
                    //Debug.Log("data : " + data.weaponeData[i].id);

                    WeaponeData weapone = new WeaponeData();

                    weapone.id           = saveData.weaponeList[i].id;
                    weapone.weaponeName  = saveData.weaponeList[i].weaponeName;
                    weapone.weaponeState = saveData.weaponeList[i].weaponeState;
                    weapone.nLevel       = saveData.weaponeList[i].nLevel;
                    weapone.nMaxLevel    = saveData.weaponeList[i].nMaxLevel;
                    weapone.m_fMinDmg    = saveData.weaponeList[i].m_fMinDmg;
                    weapone.m_MaxDmg     = saveData.weaponeList[i].m_MaxDmg;
                    weapone.m_nMag       = saveData.weaponeList[i].m_nMag;
                    weapone.m_nCurBullet = saveData.weaponeList[i].m_nCurBullet;

                    data.weaponeList.Add(weapone);
                    //weapone = null;
                }

                //아이템
                data.nGrenadeCount      = saveData.nGrenadeCount;
                data.nRecoveryCount     = saveData.nRecoveryCount;
                data.nMaxGrenadeCount   = saveData.nMaxGrenadeCount;
                data.nMaxRecorveryCount = saveData.nMaxRecorveryCount;
                data.grenadeLevel       = saveData.grenadeLevel;
                data.recoveryLevel      = saveData.recoveryLevel;
                data.greadeDMG          = saveData.greadeDMG;
                data.recoveryHP         = saveData.recoveryHP;

                data.nUpgradePoint = saveData.nUpgradePoint;

                bf.Serialize(file, data);
                file.Close();

                //data = null;
            }
Ejemplo n.º 2
0
            /// <summary>
            /// 게임 로드
            /// </summary>
            public void LoadGameData()
            {
                GameData loadData = dataManager.Load();

                data.sceneName = loadData.sceneName;
                //캐릭터
                data.hp       = loadData.hp;
                data.maxHp    = loadData.maxHp;
                data.speed    = loadData.speed;
                data.isLive   = loadData.isLive;
                data.isFire   = loadData.isFire;
                data.isReload = loadData.isReload;
                data.isStop   = loadData.isStop;

                //무기
                //Debug.Log("Weapone List : " + loadData.weaponeList.Count);
                for (int i = 0; i < loadData.weaponeList.Count; i++)
                {
                    WeaponeData weaponeData = new WeaponeData();

                    weaponeData.id           = loadData.weaponeList[i].id;
                    weaponeData.weaponeName  = loadData.weaponeList[i].weaponeName;
                    weaponeData.weaponeState = loadData.weaponeList[i].weaponeState;
                    weaponeData.nLevel       = loadData.weaponeList[i].nLevel;
                    weaponeData.nMaxLevel    = loadData.weaponeList[i].nMaxLevel;
                    weaponeData.m_fMinDmg    = loadData.weaponeList[i].m_fMinDmg;
                    weaponeData.m_MaxDmg     = loadData.weaponeList[i].m_MaxDmg;
                    weaponeData.m_nMag       = loadData.weaponeList[i].m_nMag;
                    weaponeData.m_nCurBullet = loadData.weaponeList[i].m_nCurBullet;


                    data.weaponeList.Add(weaponeData);
                    weaponeData = null;
                    // Debug.Log("load : " + loadData.weaponeData[i].id);
                    // Debug.Log("data : " + data.weaponeData[i].id);
                }

                //아이템
                data.nGrenadeCount      = loadData.nGrenadeCount;
                data.nRecoveryCount     = loadData.nRecoveryCount;
                data.nMaxGrenadeCount   = loadData.nMaxGrenadeCount;
                data.nMaxRecorveryCount = loadData.nMaxRecorveryCount;
                data.grenadeLevel       = loadData.grenadeLevel;
                data.recoveryLevel      = loadData.recoveryLevel;
                data.greadeDMG          = loadData.greadeDMG;
                data.recoveryHP         = loadData.recoveryHP;

                data.nUpgradePoint = loadData.nUpgradePoint;

                //loadData = null;
            }
Ejemplo n.º 3
0
            void LoadWeaponeXml()
            {
                TextAsset   textAsset = (TextAsset)Resources.Load(weaponeFile);
                XmlDocument xmlDoc    = new XmlDocument();

                xmlDoc.LoadXml(textAsset.text);

                //   Debug.Log("textAsset.text : " + textAsset.text);

                XmlNodeList all_node = xmlDoc.SelectNodes("dataroot/Weapone");

                foreach (XmlNode node in all_node)
                {
                    data = new WeaponeData();

                    data.Id           = Int32.Parse(node.SelectSingleNode("ID").InnerText);
                    data.WeaponeState = Int32.Parse(node.SelectSingleNode("State").InnerText);

                    data.ItemIconPath = node.SelectSingleNode("IconLocal").InnerText;
                    data.WeaponeName  = node.SelectSingleNode("WeaponeName").InnerText;


                    data.FMinDmgF = Int32.Parse(node.SelectSingleNode("MinRangeF").InnerText);
                    data.FMinDmgE = Int32.Parse(node.SelectSingleNode("MinRangeE").InnerText);

                    data.FMaxDmgF = Int32.Parse(node.SelectSingleNode("MaxRangeF").InnerText);
                    data.FMaxDmgE = Int32.Parse(node.SelectSingleNode("MaxRangeE").InnerText);
                    //피격 데미지는 발사 할떄 랜덤으로 결정된다
                    //여기서는 범위만 만들어 준다

                    //info.nDamage = UnityEngine.Random.Range(info.nMinDmg, info.nMaxDmg);
                    data.NMag       = Int32.Parse(node.SelectSingleNode("Magazine").InnerText);
                    data.NCurBullet = Int32.Parse(node.SelectSingleNode("CurrMagazine").InnerText);

                    //data.nMaxBullet = Int32.Parse(node.SelectSingleNode("MaxBullet").InnerText);
                    //data.nCount = Int32.Parse(node.SelectSingleNode("Count").InnerText);
                    //data.nPrice = Int32.Parse(node.SelectSingleNode("Price").InnerText);
                    //data.nUpgrade = Int32.Parse(node.SelectSingleNode("UpgradePoint").InnerText);


                    WeaponeList.Add(data);

                    data = null;
                }
            }
Ejemplo n.º 4
0
            /// <summary>
            /// 플레이어 총 무기 정보
            /// </summary>
            /// <param name="weaponeData"></param>
            public void GunWeaponeInfo(WeaponeData weaponeData)
            {
                StringBuilder sb = new StringBuilder();

                sb.Append(weaponeData.WeaponeName);
                sb.Append("\n");

                sb.Append("공격력  ");
                sb.Append(weaponeData.NMinDmg);
                sb.Append(" / ");
                sb.Append(weaponeData.NMaxDmg);
                sb.Append("\n");

                sb.Append("탄  ");
                sb.Append(weaponeData.NBullet);
                sb.Append(" / ");
                sb.Append(weaponeData.NMaxMag);
                sb.Append("\n");

                sb.Append("탄 속도  ");
                sb.Append(weaponeData.FBulletSpeed);
                sb.Append("\n");

                //속성 관련 추가
                sb.Append("폭발 속성  ");
                sb.Append(weaponeData.IsExplosion);
                sb.Append("  ");
                sb.Append("(범위  ");
                sb.Append(weaponeData.FExplosionArea.ToString("N2"));
                sb.Append(")");

                sb.Append("\n");
                sb.Append("기절 속성  ");
                sb.Append(weaponeData.IsStun);
                sb.Append("  ");
                sb.Append("(확률  ");
                sb.Append(weaponeData.FStunPer.ToString("N2"));
                sb.Append(")");
                sb.Append("\n");


                GunInfoText.text = sb.ToString();
            }
Ejemplo n.º 5
0
            /// <summary>
            /// 데이터 저장
            /// </summary>
            public void SaveGameData(PlayerCtrl player, WeaponeManager weaponeData,
                                     ItemManager itemData, string stageName)
            {
                data.sceneName = stageName;
                //캐릭터
                data.hp       = player.Hp;
                data.maxHp    = player.MaxHp;
                data.speed    = player.Speed;
                data.isLive   = player.IsLive;
                data.isFire   = player.IsFire;
                data.isReload = player.IsReload;
                data.isStop   = player.IsStop;

                //무기
                int length = weaponeData.WeaponePos.Length;

                data.weaponeList.Clear(); //리스트 정리

                //Debug.Log("Weapone List : " + weaponeData.WeaponePos.Length);

                for (int i = 0; i < length; i++)
                {
                    WeaponeCtrl weapone     = weaponeData.WeaponePos[i].GetComponentInChildren <WeaponeCtrl>();
                    WeaponeData weaponeList = new WeaponeData();

                    //Debug.Log("weapone Info : " + weaponeData.WeaponePos[i].GetComponentInChildren<WeaponeCtrl>().name);

                    weaponeList.id           = weapone.Id;
                    weaponeList.weaponeName  = weapone.WeaponeName;
                    weaponeList.weaponeState = weapone.WeaponeState;
                    weaponeList.nLevel       = weapone.NLevel;
                    weaponeList.nMaxLevel    = weapone.NMaxLevel;
                    weaponeList.m_fMinDmg    = weapone.FMinDmg;
                    weaponeList.m_MaxDmg     = weapone.MaxDmg;
                    weaponeList.m_nMag       = weapone.NMag;
                    weaponeList.m_nCurBullet = weapone.NCurBullet;

                    data.weaponeList.Add(weaponeList);

                    //Debug.Log("Weapone Data : " + data.weaponeList[i].weaponeName);
                    //weaponeList = null;
                }

                //아이템
                ItemManager item = player.GetComponent <ItemManager>();

                data.nGrenadeCount      = item.NGrenadeCount;
                data.nRecoveryCount     = item.NRecoveryCount;
                data.nMaxGrenadeCount   = item.NMaxGrenadeCount;
                data.nMaxRecorveryCount = item.NMaxRecorveryCount;
                data.grenadeLevel       = item.GrenadeLevel;
                data.recoveryLevel      = item.RecoveryLevel;
                data.greadeDMG          = item.GreadeDMG;
                data.recoveryHP         = item.RecoveryHP;

                data.nUpgradePoint = item.NUpgradePoint;


                dataManager.Save(data);

                item = null;
            }