Beispiel #1
0
        private void CreateData()
        {
            CreateDataPopWindow.ShowWin(new Rect(position.x + position.width * .5f - 100, position.y + position.height * .5f - 75, 200, 150), (id) =>
            {
                FlyerData skillData = new FlyerData();
                string fullPath     = $"{m_DataPath}/flyer_{id}.json";
                m_DataDic.Add(fullPath, skillData);
                SelectedDataFullPath = fullPath;
            }, (id) =>
            {
                if (id <= 10000)
                {
                    return(false);
                }

                string fullPath = $"{m_DataPath}/skill_{id}.json";
                foreach (var kvp in m_DataDic)
                {
                    if (Path.GetFileNameWithoutExtension(kvp.Key) == fullPath)
                    {
                        return(false);
                    }
                }
                return(true);
            });
        }
Beispiel #2
0
        protected override TrackGroup GetTrackGroup(out float timeScale)
        {
            timeScale = 1.0f;
            FlyerData flyerData = Context.GetObject <FlyerData>();

            return(flyerData.EndData.Value.Group.Value);
        }
Beispiel #3
0
        private void FindIDAndIndex()
        {
            m_FlyerID     = -1;
            m_ActionIndex = -1;

            if (string.IsNullOrEmpty(SelectedDataFullPath))
            {
                return;
            }

            string fileName     = Path.GetFileNameWithoutExtension(SelectedDataFullPath);
            string skillIDRegex = @"flyer_(?<id>[0-9]+)";
            Match  match        = new Regex(skillIDRegex).Match(fileName);

            if (match.Groups["id"].Success)
            {
                m_FlyerID = int.Parse(match.Groups["id"].Value);
            }
            else
            {
                Debug.LogError("Flyer id is error");
                return;
            }

            FlyerData         data    = m_DataDic[SelectedDataFullPath];
            List <ActionData> actions = new List <ActionData>();

            foreach (var track in data.FlyingData.Group.Tracks)
            {
                actions.AddRange(track.Actions);
            }
            foreach (var track in data.EndData.Group.Tracks)
            {
                actions.AddRange(track.Actions);
            }
            if (actions.Count > 0)
            {
                int    maxActionIndex = (from action in actions select action.Index).ToList().Max();
                string tempStr        = maxActionIndex.ToString();
                maxActionIndex = int.Parse(tempStr.Substring(tempStr.Length - 3, 3));
                if (maxActionIndex + 100 > 999)
                {
                    foreach (var action in actions)
                    {
                        m_ActionIndex++;
                        action.Index = m_FlyerID * 1000 + m_ActionIndex;
                    }
                }
                else
                {
                    m_ActionIndex = maxActionIndex + 1;
                }
            }
        }
    private BulletTriggerCollisionEnter m_TriggerCollisionEnter; //碰撞检测器

    public override void OnInitialize(IBulletAppearanceProperty property)
    {
        m_Property = property;
        m_BulletTf = m_Property.GetTransform();

        CfgEternityProxy cfgEternity = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
        int flyerdataId = m_Property.GetFlyerDataId();

        m_FlyerData = cfgEternity.GetFlyerData(flyerdataId);

        BaseEntity bulletOwerEntity = GameplayManager.Instance.GetEntityManager().GetEntityById <BaseEntity>(m_Property.GetOwnerSpacecaftEntityId());
        BaseEntity targetEnity      = m_Property.IsHaveTarget() ? GameplayManager.Instance.GetEntityManager().GetEntityById <BaseEntity>(m_Property.GetTargetEntityID()) : null;
        Vector3    targetPoint      = m_Property.GetTargetPoint();

        m_TriggerCollisionEnter = m_BulletTf.GetOrAddComponent <BulletTriggerCollisionEnter>();

        m_TriggerCollisionEnter.Init(bulletOwerEntity,                       //子弹拥有者Enity
                                     m_Property.GetOwner(),                  //子弹Enity
                                     m_FlyerData.BaseData.Value.IsRigibody,  //碰撞后单位是否继续飞 ,刚体爆炸,非刚体继续飞
                                     m_Property.IsHaveTarget(),              //是否指定了目标
                                     targetEnity,                            //指定的飞向的目标
                                     targetPoint,                            //指定的飞向的点
                                     m_FlyerData.BaseData.Value.FactionType, //碰撞后的阵营判断
                                     TriggerToEnitity);                      //碰撞后的回调函数


        string assetPath = m_FlyerData.BaseData.Value.ApperanceAddress;

        if (!string.IsNullOrEmpty(assetPath))
        {
            AssetUtil.InstanceAssetAsync(assetPath,
                                         (pathOrAddress, returnObject, userData) =>
            {
                if (returnObject != null)
                {
                    GameObject pObj = (GameObject)returnObject;
                    OnLoadModel(pObj);
                }
                else
                {
                    Debug.LogError(string.Format("资源加载成功,但返回null,  pathOrAddress = {0}", pathOrAddress));
                }
            });
        }
    }
Beispiel #5
0
        private void SaveData()
        {
            if (string.IsNullOrEmpty(SelectedDataFullPath))
            {
                return;
            }

            FlyerData data = m_DataDic[SelectedDataFullPath];

            foreach (var track in data.FlyingData.Group.Tracks)
            {
                track.Actions.Sort((item1, item2) => { return(item1.FireTime.CompareTo(item2.FireTime)); });
            }
            foreach (var track in data.EndData.Group.Tracks)
            {
                track.Actions.Sort((item1, item2) => { return(item1.FireTime.CompareTo(item2.FireTime)); });
            }

            string json = JsonDataWriter.WriteObjectToJson(data);

            File.WriteAllText(SelectedDataFullPath, json);
        }
Beispiel #6
0
        private void LoadData()
        {
            m_DataDic.Clear();

            DirectoryInfo dInfo = new DirectoryInfo(m_DataPath);

            if (dInfo.Exists)
            {
                FileInfo[] fileInfos = dInfo.GetFiles("*.json");
                if (fileInfos != null && fileInfos.Length > 0)
                {
                    foreach (var fi in fileInfos)
                    {
                        StreamReader sr      = fi.OpenText();
                        string       content = sr.ReadToEnd();
                        sr.Close();

                        FlyerData flyerData = JsonDataReader.ReadObjectFromJson <FlyerData>(content);
                        m_DataDic.Add(fi.FullName, flyerData);
                    }
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// 其他上下文需要携带的数据
        /// </summary>
        private void ContextAddOtherObject()
        {
            FlyerData flyerData = m_CfgEternityProxy.GetFlyerData(m_FlyerProprety.GetFlyerDataId());

            m_Context.AddObject <FlyerData>(flyerData);
        }