Exemplo n.º 1
0
    private void Create(int layer, Action onSuccess = null)
    {
        if (layer < 0 || Points.ContainsKey(layer))
        {
            onSuccess?.Invoke();
            return;
        }

        if (layer > Module_Awake.instance.PrecentLayer(CurrentType))
        {
            onSuccess?.Invoke();
            return;
        }

        var rInfos = moduleAwake.GetInfosOnLayer(CurrentType, layer);

        if (rInfos.Count <= 0)
        {
            onSuccess?.Invoke();
            return;
        }
        var assets = new List <string>();

        assets.Add("awake_point");
        Level.PrepareAssets(assets, (b) =>
        {
            if (!b)
            {
                onSuccess?.Invoke();
                return;
            }

            var list = new List <AwakeController>();
            foreach (var info in rInfos)
            {
                var go = SceneObject.Create <SceneObject>(info.ID.ToString(), "awake_point", Vector3.zero, Vector3.zero);
                Util.SetLayer(go.gameObject, awakeLayer);
                var controller = go.GetComponentDefault <AwakeController>();
                controller.Init(info);
                list.Add(controller);
            }

            var layerController = LayerGameObject(layer);
            layerController.LayoutPoint(list);
            layerController.DrawLine(this);

            //每次重新生成层后需要把上一层连线重绘,因为上一层会有一条线连到这一层
            if (Points.ContainsKey(layer + 1))
            {
                Points[layer + 1].DrawLine(this);
            }

            onSuccess?.Invoke();
        });
    }
Exemplo n.º 2
0
    public void RefreshState()
    {
        state = Module_Awake.instance.CheckAwakeState(info);
        if (state == 0 || state == 2)
        {
            transform.localScale = Vector3.one * 1.5f;
            if (layerController)
            {
                layerController.Watch(this);
            }

            PlayLineAnim();
        }
        else
        {
            transform.localScale = Vector3.one * 1.5f;
        }

        if (text)
        {
            if (state == 0)
            {
                text.transform.parent.SafeSetActive(true);
                text.text = info.NameString;
            }
            else
            {
                text.transform.parent.SafeSetActive(false);
                text.text = string.Empty;
            }
        }

        if (state == 0)
        {
            if (!specialEffect)
            {
                var effName = "eff_xinghun_w_1";
                var assets  = new System.Collections.Generic.List <string>();
                assets.Add(effName);
                Level.PrepareAssets(assets, (b) =>
                {
                    if (!b)
                    {
                        return;
                    }
                    specialEffect = SceneObject.Create <SceneObject>(effName, effName);
                    specialEffect.transform.SetParent(transform);
                    specialEffect.transform.localPosition = Vector3.zero;
                    specialEffect.transform.localScale    = Vector3.one;
                });
            }
        }
        else if (specialEffect)
        {
            specialEffect.Destroy();
        }


        if (state < 0)
        {
            if (effect != null)
            {
                if (effect.name.Equals(info.unlockEffect))
                {
                    return;
                }
                effect.Destroy();
            }

            var assets = new System.Collections.Generic.List <string>();
            assets.Add(info.unlockEffect);
            Level.PrepareAssets(assets, (b) =>
            {
                if (!b)
                {
                    return;
                }
                effect = SceneObject.Create <SceneObject>(info.unlockEffect, info.unlockEffect);

                if (effect)
                {
                    effect.transform.SetParent(transform);
                    effect.transform.localPosition = Vector3.zero;
                    effect.transform.localScale    = Vector3.one;
                }
            });
        }
        else if (state >= 0)
        {
            if (effect != null)
            {
                if (effect.name.Equals(info.lockEffect))
                {
                    return;
                }
                effect.Destroy();
            }
            var assets = new System.Collections.Generic.List <string>();
            assets.Add(info.lockEffect);
            Level.PrepareAssets(assets, (b) =>
            {
                if (!b)
                {
                    return;
                }
                effect = SceneObject.Create <SceneObject>(info.lockEffect, info.lockEffect);

                if (effect)
                {
                    effect.transform.SetParent(transform);
                    effect.transform.localPosition = Vector3.zero;
                    effect.transform.localScale    = Vector3.one;
                }
            });
        }
    }