Beispiel #1
0
    protected void CheckCollider(uint curFrame)
    {
        //指定目标 不需要判断 在运动结束 调用
        if (_colliderInfo.ColliderType == CollBase.ColType.TARGET)
        {
            return;
        }

        for (int i = 0; i < _targetList.Count; i++)
        {
            //碰撞结束 (碰撞次数已满)
            bool isCollider = ZTCollider.CheckCollision(_targetList[i].Collider, _collider);
            if (isCollider)
            {
                if (_colliderDic.ContainsKey(_targetList[i].BattleId))
                {
                    if (_colliderInfo.Interval > 0 && (curFrame - _colliderDic[_targetList[i].BattleId]) > _colliderInfo.Interval)
                    {
                        DoColliderAction(_targetList[i]);
                        _colliderDic[_targetList[i].BattleId] = curFrame;
                    }
                }
                else
                {
                    DoColliderAction(_targetList[i]);
                    _colliderDic[_targetList[i].BattleId] = curFrame;
                }

                if (ColliderDestroy)
                {
                    Complete();
                }
            }
        }
    }
Beispiel #2
0
    private static void CreateElement(Transform go, int offsetX, int offsetY)
    {
        if (go == null)
        {
            return;
        }
        for (int index = 0; index < go.childCount; index++)
        {
            Transform element = go.GetChild(index);
            if (element.name.Contains("Ele_"))
            {
                Transform colliderRoots = element.Find("ColliderRoot");
                if (colliderRoots == null)
                {
                    continue;
                }
                List <KeyValuePair <string, CollRectange> > goInCludeRects = GetGoIncludeBlocks(element, offsetX, offsetY);
                for (int rootIndex = 0; rootIndex < colliderRoots.childCount; rootIndex++)
                {
                    Transform root  = colliderRoots.GetChild(rootIndex);
                    string[]  datas = root.name.Split('_');
                    if (!Enum.IsDefined(typeof(eMapBlockType), datas[0]))
                    {
                        continue;
                    }
                    eMapBlockType blockType = (eMapBlockType)Enum.Parse(typeof(eMapBlockType), datas[0]);
                    if ((int)fileData != (int)blockType && fileData != MapByteDataType.All)
                    {
                        continue;
                    }

                    string              blockParam        = datas.Length > 1 ? datas[1] : "";
                    Renderer[]          colliderRenderers = root.GetComponentsInChildren <Renderer>(true);
                    List <CollRectange> colliderRectList  = new List <CollRectange>();
                    for (int colliderIndex = 0; colliderIndex < colliderRenderers.Length; colliderIndex++)
                    {
                        Renderer     tempRenderer = colliderRenderers[colliderIndex];
                        CollRectange tempColl     = new CollRectange(tempRenderer.transform.position.x,
                                                                     tempRenderer.transform.position.z, tempRenderer.transform.eulerAngles.y,
                                                                     Mathf.Abs(tempRenderer.transform.lossyScale.x),
                                                                     Mathf.Abs(tempRenderer.transform.lossyScale.z));
                        colliderRectList.Add(tempColl);
                    }
                    for (int blockIndex = goInCludeRects.Count - 1; blockIndex >= 0; blockIndex--)
                    {
                        for (int colliderIndex = 0; colliderIndex < colliderRectList.Count; colliderIndex++)
                        {
                            if (ZTCollider.CheckCollision(goInCludeRects[blockIndex].Value, colliderRectList[colliderIndex]))
                            {
                                if (blockType == eMapBlockType.Height)
                                {
                                    blockParam = Mathf.Abs(colliderRenderers[colliderIndex].bounds.size.y) + "";
                                }
                                AddColliderToDic(goInCludeRects[blockIndex].Key, blockType, blockParam);
                                //goInCludeRects.RemoveAt(blockIndex);
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                CreateElement(element, offsetX, offsetY);
            }
        }
    }