public void Initialize(Transform centerPos, int id)
    {
        CenterPos = centerPos;

        Data = DataManager.Instance.JellyHeroDataDic[id];
        Anim.SetTrigger("Run");
    }
        public JellySimulation(SceneManager sceneManager, ShaderProvider shaderProvider)
        {
            _sceneManager   = sceneManager;
            _shaderProvider = shaderProvider;

            ControlFrame         = new Node(new Transform(Vector3.Zero, Quaternion.Identity /* Quaternion.FromEulerAngles(1.0f, 1.0f, 0.0f)*/, Vector3.One), "controlFrame");
            ControlFrameRenderer = new LineRenderer(shaderProvider.DefaultShader);
            var jellyControlFrame = new JellyControlFrame(ControlFrameRenderer, 1.0);

            ControlFrame.AttachComponents(ControlFrameRenderer, jellyControlFrame);

            Jelly = new Node(new Transform(Vector3.Zero, Quaternion.Identity, Vector3.One), "jelly");

            var boundingBoxRenderer = new LineRenderer(shaderProvider.DefaultShader);
            var jellyBoundingBox    = new JellyBoundingBox(boundingBoxRenderer, 5.0);

            var jellyData = new JellyData();

            JellyRenderer   = new DynamicPatchRenderer(shaderProvider.SurfaceShaderBezier, new Mesh(VertexLayout.Type.Position), jellyData);
            JellyController = new JellyController(jellyControlFrame);

            WireframeRenderer = new LineRenderer(shaderProvider.DefaultShader);
            var jellyCPVisualizer = new JellyControlPointVisualizer(WireframeRenderer);

            Jelly.AttachComponents(jellyData, JellyRenderer, JellyController, boundingBoxRenderer, jellyBoundingBox,
                                   WireframeRenderer, jellyCPVisualizer);


            _sceneManager.CurrentScene.AttachChild(Jelly);
            _sceneManager.CurrentScene.AttachChild(ControlFrame);

            var meshData  = MeshLoader.LoadObj("monkey2.obj");
            var monkey    = new Node(new Transform(Vector3.Zero, Quaternion.Identity, Vector3.One), "monkey");
            var jellyMesh = new JellyMesh(jellyData, meshData.positions, meshData.normals);

            JellyMeshRenderer = new DynamicMeshRenderer(shaderProvider.PhongShader, meshData.mesh);

            monkey.AttachComponents(JellyMeshRenderer, jellyMesh);
            _sceneManager.CurrentScene.AttachChild(monkey);
        }
Example #3
0
    public IEnumerator LoadingData()
    {
        if (LoadingDataXmlList.Count <= 0)
        {
            LoadingDataXmlList.Add(new KeyValuePair <string, string>("Jelly", "Datas"));
            LoadingDataXmlList.Add(new KeyValuePair <string, string>("Stage", "Datas"));
            LoadingDataXmlList.Add(new KeyValuePair <string, string>("Item", "Datas"));
            LoadingDataXmlList.Add(new KeyValuePair <string, string>("StagePreset", "Datas"));
            LoadingDataXmlList.Add(new KeyValuePair <string, string>("Background", "Datas"));
        }

        for (int i = 0; i < LoadingDataXmlList.Count; i++)
        {
            string      xmlName = LoadingDataXmlList[i].Key;
            XmlNodeList list    = GetXmlNodeList(LoadingDataXmlList[i].Key, LoadingDataXmlList[i].Value);


            if (xmlName == "Jelly")
            {
                foreach (XmlNode node in list)
                {
                    foreach (XmlNode child in node.ChildNodes)
                    {
                        var data = new JellyData(child);
                        JellyHeroDataDic.Add(data.id, data);
                    }
                }
            }
            else if (xmlName == "Stage")
            {
                foreach (XmlNode node in list)
                {
                    foreach (XmlNode child in node.ChildNodes)
                    {
                        var data = new StageData(child);
                        StageDataList.Add(data);
                    }
                }
            }
            else if (xmlName == "Item")
            {
                foreach (XmlNode node in list)
                {
                    foreach (XmlNode child in node.ChildNodes)
                    {
                        var data = new ItemData(child);
                        ItemDataDic.Add(data.itemtype, data);
                    }
                }
            }
            else if (xmlName == "StagePreset")
            {
                foreach (XmlNode node in list)
                {
                    foreach (XmlNode child in node.ChildNodes)
                    {
                        var data = new StagePresetData(child);
                        StagePresetDataDic.Add(data.id, data);
                    }
                }
            }

            else if (xmlName == "Background")
            {
                foreach (XmlNode node in list)
                {
                    foreach (XmlNode child in node.ChildNodes)
                    {
                        var data = new BackgroundData(child);
                        BackgroundDataDic.Add(data.id, data);
                    }
                }
            }

            yield return(null);
        }
    }