示例#1
0
    static public void LoadHandler(LoadedData data)
    {
        JsonData jsonData = JsonMapper.ToObject(data.Value.ToString());

        if (!jsonData.IsArray)
        {
            return;
        }
        for (int index = 0; index < jsonData.Count; index++)
        {
            JsonData element = jsonData[index];
            PropsPO  po      = new PropsPO(element);
            PropsData.Instance.m_dictionary.Add(po.Id, po);
        }
    }
示例#2
0
    private float GenProp(PropsPO po, float startPrecent)
    {
        int   num           = Random.Range(po.MinNumber, po.MaxNumber);
        bool  left          = UnityEngine.Random.Range(0, 2) == 0;
        float curPrecent    = startPrecent;
        float pathLength    = PathManager.Instance.PathInfo1.PathLength;
        float offsetPrecent = 0;


        for (int i = 0; i < num; ++i)
        {
            PointInfo info = new PointInfo();

            info.name           = po.Name;
            info.type           = (PropType)po.Type;
            info.LocatePercent  = curPrecent;
            info.score          = po.Score;
            info.Assaultable    = po.IsEnermy == 1 ? true : false;
            info.used           = false;
            info.BornVolumeName = po.BornVolumeName;
            info.DieVolumeName  = po.DieVolumeName;
            info.DamageValue    = po.Damage;
            info.DamagePlane    = po.DamagePlane;
            info.BornEffect     = po.BornEffect;
            info.DieEffect      = po.DieEffect;

            if (info.type == PropType.Wall)
            {
                info.isMidle = true;
                type         = 0;
            }
            else
            {
                info.isMidle = false;
            }

            Vector3 nextPos = Vector3.zero;

            // 下
            if (type == 0)
            {
                info.pos = PathManager.Instance.PathInfo1.GetPos(curPrecent);
                nextPos  = PathManager.Instance.PathInfo1.GetPos(curPrecent + Step);
            }
            // 上
            else if (type == 1)
            {
                info.pos = PathManager.Instance.PathInfo1.GetPos(curPrecent) + (PathManager.Instance.PathInfo1.GetUpPos(curPrecent) - PathManager.Instance.PathInfo1.GetPos(curPrecent)).normalized * 3;
                nextPos  = PathManager.Instance.PathInfo1.GetPos(curPrecent + Step) + (PathManager.Instance.PathInfo1.GetUpPos(curPrecent + Step) - PathManager.Instance.PathInfo1.GetPos(curPrecent + Step)).normalized * 3;
            }
            // 中
            else
            {
                info.pos = (2 * PathManager.Instance.PathInfo1.GetPos(curPrecent) + (PathManager.Instance.PathInfo1.GetUpPos(curPrecent) - PathManager.Instance.PathInfo1.GetPos(curPrecent)).normalized * 3) * 0.5f;
                nextPos  = (2 * PathManager.Instance.PathInfo1.GetPos(curPrecent + Step) + (PathManager.Instance.PathInfo1.GetUpPos(curPrecent + Step) - PathManager.Instance.PathInfo1.GetPos(curPrecent + Step)).normalized * 3) * 0.5f;
            }

            if (info.pos != nextPos)
            {
                if (info.pos != nextPos)
                {
                    info.nexPos = nextPos;
                }
            }

            if (left)
            {
                info.isLeft = true;
            }
            else
            {
                info.isLeft = false;
            }

            offsetPrecent = po.Offset / pathLength;
            curPrecent   += offsetPrecent;

            PosInfoList.Add(info);
        }

        ++type;
        type %= 3;

        return(offsetPrecent * num);
    }
示例#3
0
    /// <summary>
    /// 初始化,配置路径字段
    /// </summary>
    public void Init()
    {
        Count     = 0;
        _curIndex = 0;
        PosInfoList.Clear();

        float pathLength = PathManager.Instance.PathInfo1.PathLength;
        //int pointCount      = (int)(pathLength / GenPropStep);
        //float stepPrecent   = GenPropStep / pathLength;
        int   pointCount   = (int)(pathLength / GenPropStep);
        float beginPrecent = BeginSpace / pathLength;
        float endPrecent   = 1 - EndSpace / pathLength;
        float curPrecent   = beginPrecent;

        int   lastID      = -1;
        float lastPrecent = 0;

        for (int n = 0; n < pointCount; ++n)
        {
            float rand = Random.Range(0f, 100f);

            bool loop = true;
            while (loop)
            {
                for (int i = StartID; i <= EndID; ++i)
                {
                    PropsPO po = PropsData.Instance.GetPropsPO(i);

                    if ((PropType)po.Type == PropType.Coin)
                    {
                        CoinPo = po;
                    }
                    if ((PropType)po.Type == PropType.Diamond)
                    {
                        DiamondPo = po;
                    }

                    if (rand >= po.MinPrecent && rand < po.MaxPrecent)
                    {
                        if (lastID == i)
                        {
                            rand = Random.Range(0f, 100f);
                            break;
                        }

                        if (rand >= 68 && (curPrecent - lastPrecent) < 0.01f)
                        {
                            rand = Random.Range(0f, 68);
                            break;
                        }

                        curPrecent += GenProp(po, curPrecent);

                        if (rand >= 68)
                        {
                            lastPrecent = curPrecent;
                        }

                        lastID = i;
                        loop   = false;
                        if (curPrecent >= endPrecent)
                        {
                            EventDispatcher.TriggerEvent(EventDefine.Event_PathInfo_Has_Init);
                            return;
                        }
                        break;
                    }
                }
            }
        }
    }