Exemplo n.º 1
0
        public bool Create_Wall(BuildWallConfig wallConfig, Vector3 position)
        {
            if (War.sceneData == null)
            {
                this.ShowNotification(new GUIContent("请先‘选择关卡’或者去‘新建关卡’"));
                return(false);
            }


            int index = GetMaxIndex() + 1;

            UnitData unitData = new UnitData();

            unitData.id         = index;
            unitData.legionId   = 1;
            unitData.unitType   = UnitType.Wall;
            unitData.level      = 0;
            unitData.position   = position;
            unitData.wallConfig = wallConfig;
            unitData.avatarId   = wallConfig.avatarId;


            unitData.we_BuildConfigData             = new WE_BuildConfigData();
            unitData.we_BuildConfigData.buildConfig = wallConfig;

            War.sceneData.wallDict.Add(index, unitData);

            Selection.activeGameObject = War.sceneCreate.GenerationWall(unitData);

            return(true);
        }
Exemplo n.º 2
0
 public void Click_Wall(BuildWallConfig wallConfig)
 {
     if (sOnSelect != null)
     {
         sOnSelect(1, 1, wallConfig, onSelect_parameter);
         sOnSelect          = null;
         onSelect_parameter = null;
     }
     else
     {
         Create_Wall(wallConfig, new Vector3(-22, 0, 17));
     }
 }
        void GUI_Wall()
        {
            EditorGUILayout.BeginVertical(style_box_marginleft);

            foreach (KeyValuePair <int, BuildWallConfig> kvp in War.model.buildWallConfigs)
            {
                BuildWallConfig wallConfig = kvp.Value;

                GUILayout.Space(10);
                EditorGUILayout.BeginHorizontal();

                GUILayout.Label(wallConfig.id + "", style_label_wall_id, GUILayout.Width(50), GUILayout.Height(100));

                AvatarConfig avatarConfig = Goo.avatar.GetConfig(wallConfig.avatarId);
                GameObject   prefab       = null;
                if (avatarConfig != null)
                {
                    prefab = WarRes.GetPrefab(avatarConfig.model);
                }

                if (prefab)
                {
                    SpriteAvatar spriteAvatar = prefab.GetComponent <SpriteAvatar>();
                    Sprite       sprite       = spriteAvatar.avatarData.avatarActions[0].GetSpriteAnimationClip(wallConfig.angle).frames[0];


                    Texture2D tex = null;
                    if (!wall_icon_dict.TryGetValue(sprite, out tex))
                    {
                        tex = new Texture2D((int)sprite.rect.width, (int)sprite.rect.height, TextureFormat.RGBA32, false);

                        Color[] pixels = sprite.texture.GetPixels((int)sprite.rect.xMin, (int)sprite.rect.yMin,
                                                                  (int)sprite.rect.width, (int)sprite.rect.height);
                        tex.SetPixels(pixels);
                        tex.Apply();
                        wall_icon_dict.Add(sprite, tex);
                    }

                    if (GUILayout.Button(tex, GUILayout.Width(100), GUILayout.Height(100)))
                    {
                        Click_Wall(wallConfig);
                    }
                }
                else
                {
                    GUILayout.Button("没有资源", GUILayout.Width(100), GUILayout.Height(100));

                    if (avatarConfig != null)
                    {
                        WarEditor.LoadRes(avatarConfig.model);
                    }
                }


                GUILayout.Label(wallConfig.name, style_label_wall_line, GUILayout.Width(100), GUILayout.Height(100));
                GUILayout.Label(wallConfig.wallType == WallType.Cube ? "立方体" : "球", style_label_wall_line, GUILayout.Width(50), GUILayout.Height(100));
                if (wallConfig.wallType == WallType.Cube)
                {
                    GUILayout.Label("角度:" + wallConfig.angle, style_label_wall_line, GUILayout.Width(100), GUILayout.Height(100));
                    GUILayout.Label("大小:" + wallConfig.size.x + "x" + wallConfig.size.z, style_label_wall_line, GUILayout.Width(100), GUILayout.Height(100));
                }
                else
                {
                    GUILayout.Label("半径:" + wallConfig.radius, style_label_wall_line, GUILayout.Width(100), GUILayout.Height(100));
                }


                EditorGUILayout.EndHorizontal();
                GUILayout.Space(10);
                GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
            }
            EditorGUILayout.EndVertical();
        }