public void InitPartOfBodyUI(PartOfBodyModel model, PartOfBodyController bodyController = null)
        {
            this.model = model;

            this.nodeControllers = new List <PartOfBodyNodeController>();

            // 初始化关节点
            for (int y = 0; y < model.height; y++)
            {
                for (int x = 0; x < model.weight; x++)
                {
                    PartOfBodyNodeController nodeController = Instantiate(this.PartOfBodyNodePrefab, this.transform).GetComponent <PartOfBodyNodeController>();

                    nodeController.model = model.GetPartOfBodyNodeModel(x, y);

                    nodeController.InitNodeUI();

                    this.nodeControllers.Add(nodeController);
                }
            }

            // 关节点连接
            if (model.type != PartOfBodyType.Body)
            {
                if (bodyController != null)
                {
                    this.transform.localPosition += this.CalculatePartOfBodyPosition(bodyController);
                }
                else
                {
                    Debug.LogError("InitPartOfBodyUI Error : bodyModel is null!");
                }
            }
        }
Exemple #2
0
        private void GenerateSomePartOfBody(PartOfBodyType type, int w, int h, Vector2 joinPoint)
        {
            // 生成modle
            PartOfBodyModel bodyModel = new PartOfBodyModel();

            bodyModel.type  = type;
            bodyModel.grade = this.grade;
            bodyModel.level = this.level;

            bodyModel.weight = w;
            bodyModel.height = h;

            if (type == PartOfBodyType.Body)
            {
                bodyModel.SetBodyJoinPoint(PartOfBodyType.LetfArm, new Vector2(0, 0.8f));
                bodyModel.SetBodyJoinPoint(PartOfBodyType.RightArm, new Vector2(1f, 0.8f));
                bodyModel.SetBodyJoinPoint(PartOfBodyType.LeftLeg, new Vector2(0.2f, 0f));
                bodyModel.SetBodyJoinPoint(PartOfBodyType.RightLeg, new Vector2(0.8f, 0f));
                bodyModel.SetBodyJoinPoint(PartOfBodyType.Head, new Vector2(0.5f, 1f));
            }
            else
            {
                bodyModel.joinPoint = joinPoint;
            }

            bodyModel.maxHP = 100;
            bodyModel.curHP = 100;

            bodyModel.InitPartOfBodyNodeModels();

            PartOfBodyController bodyPartOfBodyController = Instantiate(this.PartOfBodyPrefab, this.PartOfBodyRoot.transform).GetComponent <PartOfBodyController>();

            this.partOfBodyControllers.Add(bodyPartOfBodyController);

            bodyPartOfBodyController.InitPartOfBodyUI(bodyModel, this.partOfBodyControllers[0]);
        }