예제 #1
0
    public static void SaveCloudPlayer(string cloudData)
    {
        LoadPlayer();
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/player.fun";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        PlayerData data = JsonConvert.DeserializeObject <PlayerData>(cloudData);

        try
        {
            if (data.level != 0)
            {
                formatter.Serialize(stream, data);
            }
        }
        catch (SerializationException e)
        {
            Debugging.LogError("유저 클라우드 데이터 저장에 실패 > " + e.Message);
            throw;
        }
        finally
        {
            stream.Close();
            Debugging.LogSystem(data.name + " 의 클라우드 데이터 성공");;
        }
    }
예제 #2
0
    public static void SetObtainMoney(int id)
    {
        Item obtainMoney = items.Find(item => item.id == id || item.id.Equals(id));

        if (obtainMoney != null)
        {
            // 수정
            if (obtainMoney.id > 9000 && obtainMoney.id < 9010)
            {
                SaveSystem.AddUserCrystal(obtainMoney.count);
            }
            // 에너지
            else if (obtainMoney.id > 9010 && obtainMoney.id < 9020)
            {
                SaveSystem.AddUserEnergy(obtainMoney.count);
            }
            // 주문서
            else if (obtainMoney.id > 9020 && obtainMoney.id < 9030)
            {
                SetObtainItem(8001, obtainMoney.count);
            }
            SaveSystem.SavePlayer();
        }
        else
        {
            Debugging.LogError("획득할 재화를 찾지못함 >> " + id);
        }
    }
예제 #3
0
    private void GetSkills(string[] skillsName, int[] skillsLevel)
    {
        List <int> listSkills      = new List <int>();
        List <int> listSkillsLevel = new List <int>();

        for (int i = 0; i < skillsName.Length; i++)
        {
            if (string.IsNullOrEmpty(skillsName[i]) == false)
            {
                int skillID = DataManager.FindSkillID(skillsName[i]);
                if (skillID > 0)
                {
                    listSkills.Add(skillID);
                    if (skillsLevel[i] <= 0)
                    {
                        listSkillsLevel.Add(1);
                        Debugging.LogError("Function:GeneralInfo; skillsLevel :" + skillsLevel[i]);
                    }
                    else
                    {
                        listSkillsLevel.Add(skillsLevel[i]);
                    }
                }
                else
                {
                    Debugging.LogError("Function:GeneralInfo; skill name:" + skillsName[i]);
                }
            }
        }

        Skill      = listSkills.ToArray();
        SkillLevel = listSkillsLevel.ToArray();
    }
예제 #4
0
    public static void SavePlayer()
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/player.fun";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        PlayerData data = new PlayerData();

        try
        {
            if (data.level != 0)
            {
                formatter.Serialize(stream, data);
            }
        }
        catch (SerializationException e)
        {
            Debugging.LogError("유저 데이터 저장에 실패 > " + e.Message);
            throw;
        }
        finally
        {
            stream.Close();
        }
        Debugging.LogSystem("File is saved in Successfully.");
    }
예제 #5
0
    private void GetWiseSkills(string[] wiseName, int[] wiseLevel)
    {
        List <int> listWise      = new List <int>();
        List <int> listWiseLevel = new List <int>();

        for (int i = 0; i < wiseName.Length; i++)
        {
            if (string.IsNullOrEmpty(wiseName[i]) == false)
            {
                int wiseID = DataManager.FindWiseSkillID(wiseName[i]);
                if (wiseID > 0)
                {
                    listWise.Add(wiseID);
                    if (wiseLevel[i] <= 0)
                    {
                        listWiseLevel.Add(1);
                        Debugging.LogError("Function:GeneralInfo; skillsLevel :" + wiseLevel[i]);
                    }
                    else
                    {
                        listWiseLevel.Add(wiseLevel[i]);
                    }
                }
                else
                {
                    Debugging.LogError("Function:GeneralInfo; skill name:" + wiseName[i]);
                }
            }
        }

        WiseSkill      = listWise.ToArray();
        WiseSkillLevel = listWiseLevel.ToArray();
    }
예제 #6
0
    /// <summary>
    /// 切换状态
    /// </summary>
    public virtual void ChangeState(string stateName)
    {
        if (!ContainsState(stateName))
        {
            Debugging.LogError("Function:ChangeState, no this state! " + stateName);
            return;
        }

        IState state = m_listState[stateName];

        if (m_currentState != null && !m_currentState.IfCanChangeToState(state))
        {
            return;
        }

        m_oldState     = m_currentState;
        m_currentState = state;

        if (m_oldState != null)
        {
            m_oldState.OnExit();
        }

        m_currentState.OnEnter();
    }
예제 #7
0
    public static int FindForceID(string name)
    {
        if (string.IsNullOrEmpty(name))
        {
            return(0);
        }

        int force = 0;

        string[] forceArr = name.Split(' ');

        for (int i = 0; i < forceArr.Length; i++)
        {
            IEnumerator enumerator = XMLManager.Force.Data.Values.GetEnumerator();
            while (enumerator.MoveNext())
            {
                XMLDataForce data = (XMLDataForce)enumerator.Current;
                if (data.ShortName == forceArr[i])
                {
                    force |= data.ID;
                }
            }
        }

        if (force == 0)
        {
            Debugging.LogError("Function:FindForceID; name = " + name);
        }

        return(force);
    }
예제 #8
0
    public void Remove(T obj)
    {
        if (m_propertyType != PropertyType.ListValueType)
        {
            Debugging.LogError("Function:Remove, PropertyType Error! Current type is" + m_propertyType.ToString());
            return;
        }

        if (m_listValue == null)
        {
            Debugging.LogError("Function:Remove, Array is empty!");
            return;
        }

        int index = m_listValue.IndexOf(obj);

        if (index < 0 || index >= m_listValue.Count)
        {
            Debugging.LogError("Function:Remove, index input ERROR!");
            return;
        }

        PropertyChangeEventArgs msg = new PropertyChangeEventArgs(PropertyChangeType.REMOVE, m_listValue[index], null, index);

        m_listValue.RemoveAt(index);

        TriggerChangeEvent(msg);
    }
예제 #9
0
    static int LogError(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        string arg0 = LuaScriptMgr.GetLuaString(L, 1);

        Debugging.LogError(arg0);
        return(0);
    }
예제 #10
0
    private void CreateCity()
    {
        IEnumerator enumerator = GamePublic.Instance.DataManager.Citys.Values.GetEnumerator();

        while (enumerator.MoveNext())
        {
            CityInfo cityInfo = (CityInfo)enumerator.Current;

            string cityPath = "";
            if (cityInfo.Level == 0)
            {
                cityPath = XMLManager.ResourcePath.GetInfoByName("City01").Path;
            }
            else
            {
                cityPath = XMLManager.ResourcePath.GetInfoByName("City03").Path;
            }

            GameObject go = Utility.CreateSceneObject("City" + cityInfo.ID, cityPath);
            if (GamePublic.Instance.CityPoint.ContainsKey(cityInfo.ID))
            {
                go.transform.localPosition = GamePublic.Instance.CityPoint[cityInfo.ID];
            }
            else
            {
                Debugging.LogError("Function:CreateCity; cityID : " + cityInfo.ID);
            }

            if (cityInfo.KingID == 0)
            {
                continue;
            }

            GameObject flag = new GameObject("Flag");
            Utility.SetObjectChild(go, flag);
            if (cityInfo.Level == 0)
            {
                flag.transform.localPosition = GlobalConfig.FlagOffset1;
            }
            else
            {
                flag.transform.localPosition = GlobalConfig.FlagOffset3;
            }
            AnimationComponent ac = flag.AddComponent <AnimationComponent>();

            if (cityInfo.KingID == -1)
            {
                ac.PlayAnimation(GlobalConfig.TroopFlag);
            }
            else
            {
                XMLDataKings kingData = XMLManager.Kings.GetInfoById(cityInfo.KingID);
                ac.PlayAnimation(kingData.FlagAnim);
            }
        }
    }
예제 #11
0
    public void PlayAnimation(string animName)
    {
        if (string.IsNullOrEmpty(animName))
        {
            return;
        }

        if (!XMLManager.Animations.Data.ContainsKey(animName))
        {
            return;
        }

        m_listSprite = new List <Sprite>();
        m_animData   = XMLManager.Animations.GetInfoByName(animName);

        TextAsset ta = ResourcesManager.Instance.Load <TextAsset>(animName);

        if (ta == null)
        {
            Debugging.LogError("PlayAnimation: animName = " + animName);
            return;
        }

        string[] spritePaths = ta.text.Trim().Split('\n');
        for (int i = 0; i < spritePaths.Length; i++)
        {
            string path   = spritePaths[i].Trim();
            Sprite sprite = ResourcesManager.Instance.Load <Sprite>(path);
            if (sprite == null)
            {
                m_listSprite.Clear();
                Debugging.LogError("PlayAnimation: animName = " + animName + ", spritePath = " + path);
                continue;
            }
            m_listSprite.Add(sprite);
        }
        if (m_listSprite.Count == 0)
        {
            Debugging.LogError("PlayAnimation: animName = " + animName);
            return;
        }

        this.animName       = animName;
        this.isPlaying      = true;
        this.isPause        = false;
        m_animCompleteEvent = null;
        m_timeTick          = 0;
        this.animIndex      = 0;

        if (m_spriteRenderer == null)
        {
            m_spriteRenderer = gameObject.AddComponent <SpriteRenderer>();
        }

        m_spriteRenderer.sprite = m_listSprite[animIndex];
    }
예제 #12
0
    public bool Contains(T value)
    {
        if (m_propertyType != PropertyType.ListValueType)
        {
            Debugging.LogError("Function:Contains, PropertyType Error! Current type is" + m_propertyType.ToString());
            return(false);
        }

        return(m_listValue.Contains(value));
    }
예제 #13
0
    public int IndexOf(T value)
    {
        if (m_propertyType != PropertyType.ListValueType)
        {
            Debugging.LogError("Function:IndexOf, PropertyType Error! Current type is" + m_propertyType.ToString());
            return(-1);
        }

        return(m_listValue.IndexOf(value));
    }
예제 #14
0
 public static void SaveHeros(List <GameObject> heros)
 {
     if (heros != null)
     {
         HeroDatabase.SaveAllUser(GetHerosData(heros));
     }
     else
     {
         Debugging.LogError("저장할 영웅들을 찾지못함");
     }
 }
예제 #15
0
 public StageInfo GetStageInfo()
 {
     if (stageInfo != null)
     {
         return(stageInfo);
     }
     else
     {
         Debugging.LogError("스테이지 정보를 가져올 수 없습니다.");
         return(null);
     }
 }
예제 #16
0
    public void LoadXML(string XmlName)
    {
        XmlDocument xmlDoc = new XmlDocument();

        m_xmlName = XmlName;
        TextAsset textAsset = (TextAsset)ResourcesManager.Instance.Load(XmlName);

        if (textAsset == null)
        {
            Debugging.LogError("xml file is not exist! File:" + XmlName);
            return;
        }
        try
        {
            xmlDoc.LoadXml(textAsset.text.ToString().Trim());
        }
        catch (XmlException e)
        {
            Debugging.LogError("Function:XMLLoader,File:" + XmlName + ",message:" + e.Message);
            return;
        }

        m_data = new Dictionary <object, object>();

        if (xmlDoc != null)
        {
            XmlNode     root = xmlDoc.DocumentElement;
            XmlNodeList list = root.ChildNodes;
            if (list != null && list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    XmlNode node = list[i];
                    if (node.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }
                    XmlElement element = (XmlElement)node;

                    object id;
                    var    info = ParseXmlParamsValue(typeof(T), element, out id);
                    if (m_data.ContainsKey(id))
                    {
                        Debugging.LogError("XMLLoader: " + XmlName + ",重复ID:" + id);
                        continue;
                    }

                    m_data.Add(id, info);
                }
            }
        }
    }
예제 #17
0
    // Use this for initialization
    void Start()
    {
        XMLDataLuaControlView info = XMLManager.LuaControlView.GetInfoByName(name);

        if (info != null)
        {
            GamePublic.Instance.LuaManager.CallLuaFunction("LuaFunctionHelper.CallFunction", info.LuaName, "Initialize", gameObject);
        }
        else
        {
            Debugging.LogError("Function: LuaControlView. LuaModule is not Find! name = " + name);
        }
    }
예제 #18
0
    public void SetFace(GameObject sprite)
    {
        UnityEngine.UI.Image image = sprite.GetComponent <UnityEngine.UI.Image>();
        if (image == null)
        {
            Debugging.LogError("Function:SetFace; sr == null");
            return;
        }

        string facePath = GlobalConfig.PathShapeFace + Face;

        image.sprite = ResourcesManager.Instance.Load <Sprite>(facePath);
    }
예제 #19
0
 public T GetInfoById(int id)
 {
     if (m_data.ContainsKey(id))
     {
         return((T)m_data[id]);
     }
     else
     {
         string error = string.Format("The key is not found,name={0}, key={1}", m_xmlName, id);
         Debugging.LogError(error);
         return(null);
     }
 }
예제 #20
0
 public T GetInfoByName(string name)
 {
     if (m_data.ContainsKey(name))
     {
         return((T)m_data[name]);
     }
     else
     {
         string error = string.Format("The key is not found,name={0}, key={1}", m_xmlName, name);
         Debugging.LogError(error);
         return(null);
     }
 }
예제 #21
0
    public void Add(T arrayValue)
    {
        if (m_propertyType != PropertyType.ListValueType)
        {
            Debugging.LogError("Function:Add, PropertyType Error! Current type is" + m_propertyType.ToString());
            return;
        }

        PropertyChangeEventArgs msg = new PropertyChangeEventArgs(PropertyChangeType.ADD, null, arrayValue, this.Count);

        m_listValue.Add(arrayValue);

        TriggerChangeEvent(msg);
    }
예제 #22
0
    /// <summary>
    /// 从对象池里取一个物体出来
    /// </summary>
    public virtual GameObject GetObject()
    {
        if (PoolObjectCount == 0)
        {
            Debugging.LogError("The pool is null;");
            return(null);
        }

        int index = -1;

        //把没有用过的物体存在一个列表里
        List <int> listIndex = new List <int>();

        //寻找没有正在使用的物体
        for (int i = 0; i < m_listState.Count; i++)
        {
            if (m_listState[i] == false)
            {
                listIndex.Add(i);
            }
        }

        //如果没有找到则新创建一个
        if (listIndex.Count == 0)
        {
            if (PoolObjectCount < m_maxObjCount)
            {
                index = CreateOneObject();
            }
            else
            {
                //如果物体数量超过了最大数,则随机返回一个
                index = Random.Range(0, PoolObjectCount);
            }
        }
        else
        {
            //从列表里面随机挑一个出来
            index = listIndex[Random.Range(0, listIndex.Count)];
        }

        m_listState[index] = true;

        GameObject go = m_listObject[index];

        go.SetActive(true);

        return(go);
    }
예제 #23
0
    public static void SaveHero(Hero heroPrefab)
    {
        HeroData heroData = userHeros.Find(hero => hero.id == heroPrefab.id || hero.id.Equals(heroPrefab.id));

        if (heroData != null)
        {
            heroData.level = heroPrefab.status.level;
            heroData.exp   = heroPrefab.status.exp;
            HeroDatabase.SaveUser(heroPrefab.id);
        }
        else
        {
            Debugging.LogError("세팅할 영웅을 찾지못함 >> " + heroPrefab.id);
        }
    }
예제 #24
0
    public void Clear()
    {
        if (m_propertyType == PropertyType.SingleValueType)
        {
            Debugging.LogError("Function:Clear, PropertyType Error! Current type is" + m_propertyType.ToString());
            return;
        }

        if (m_propertyType == PropertyType.ListValueType)
        {
            for (int i = Count - 1; i >= 0; i--)
            {
                RemoveAt(i);
            }
        }
    }
예제 #25
0
    /// <summary>
    /// 创建新物体
    /// </summary>
    public virtual int CreateOneObject()
    {
        if (m_createObjectFunc == null)
        {
            Debugging.LogError("The m_createObjectFunc is null");
            return(0);
        }

        GameObject go = m_createObjectFunc();

        go.SetActive(false);

        m_listObject.Add(go);
        m_listState.Add(false);

        return(PoolObjectCount - 1);
    }
예제 #26
0
    public static void SetObtainHero(int id)
    {
        HeroData obtainHero = heros.Find(h => h.id == id || h.id.Equals(id));

        if (obtainHero != null)
        {
            HeroDatabase.AddUser(id);
            userHeros.Add(obtainHero);
            SkillSystem.SetObtainSkill(obtainHero.skill);
            MissionSystem.AddClearPoint(MissionSystem.ClearType.CollectHero);
            Debugging.Log(id + " 영웅 획득 성공!");
        }
        else
        {
            Debugging.LogError("획득할 영웅을 찾지못함 >> " + id);
        }
    }
예제 #27
0
    public void AddGeneral(int generalID)
    {
        GeneralInfo general = GamePublic.Instance.DataManager.GetGeneralInfo(generalID);

        if (general.KingID != KingID)
        {
            Debugging.LogError("Function:AddGeneral; KingID:" + KingID + ", general.KingID:" + general.KingID);
            return;
        }

        if (Generals.Contains(generalID))
        {
            return;
        }

        general.CityID = ID;
        Generals.Add(generalID);
    }
예제 #28
0
    public T this[int index]
    {
        get
        {
            if (m_propertyType != PropertyType.ListValueType)
            {
                Debugging.LogError("Function:GetArrayValue, PropertyType Error! Current type is" + m_propertyType.ToString());
                return(default(T));
            }

            if (m_listValue == null || (index < 0) || (index >= m_listValue.Count))
            {
                Debugging.LogError("Function:GetArrayValue, ArgumentOutOfRangeException!");
                return(default(T));
            }

            return(m_listValue[index]);
        }
        set
        {
            if (m_propertyType != PropertyType.ListValueType)
            {
                Debugging.LogError("Function:SetArrayValue, PropertyType Error! Current type is" + m_propertyType.ToString());
            }

            if (m_listValue == null)
            {
                Debugging.LogError("Function:SetArrayValue, array is empty!");
                return;
            }

            if (index < 0 || index >= m_listValue.Count)
            {
                Debugging.LogError("Function:SetArrayValue, ArgumentOutOfRangeException!");
                return;
            }

            PropertyChangeEventArgs msg = new PropertyChangeEventArgs(PropertyChangeType.UPDATE, m_listValue[index], value, index);

            m_listValue[index] = value;

            TriggerChangeEvent(msg);
        }
    }
예제 #29
0
    /// <summary>
    /// 归还一个物体给对象池
    /// </summary>
    public virtual void GiveBackObject(GameObject go)
    {
        if (PoolObjectCount > m_minObjCount)
        {
            DestroyOneObject(go);
        }
        else
        {
            int index = m_listObject.IndexOf(go);
            if (index < 0)
            {
                Debugging.LogError("The object is not in the list");
                return;
            }

            go.SetActive(false);
            m_listState[index] = false;
        }
    }
예제 #30
0
    /// <summary>
    /// 销毁一个物体
    /// </summary>
    public virtual void DestroyOneObject(GameObject go)
    {
        if (go == null)
        {
            Debugging.LogError("The object is null");
            return;
        }

        int index = m_listObject.IndexOf(go);

        if (index < 0)
        {
            Debugging.LogError("The object is not in the list");
            return;
        }

        m_listObject.Remove(go);
        m_listState.RemoveAt(index);
        GameObject.Destroy(go);
    }