void SetMaterialPreset(Material mat, MaterialPreset preset)
 {
     mat.SetFloat("_Glossiness", preset.Smoothness);
     mat.SetColor("_Emission", preset.Emission);
     mat.SetFloat("_EmissionIntensity", preset.EmissionIntensity);
     mat.SetFloat("_ShadowAttenuation", preset.DiffuseShadowAtt);
     mat.SetFloat("_HighDivision", preset.DiffuseHighDiv);
     mat.SetFloat("_MidDivision", preset.DiffuseMidDiv);
     mat.SetFloat("_LowDivision", preset.DiffuseDarkDiv);
     mat.SetFloat("_SpecDivision", preset.SpecularDiv);
     mat.SetFloat("_SpecIntensity", preset.SpecularIntensity);
     mat.SetFloat("_FresnelIntensity", preset.Fresnel);
     if (preset.SSEnabled)
     {
         mat.EnableKeyword("_SUBSURFACE_SCATTERING");
     }
     else
     {
         mat.DisableKeyword("_SUBSURFACE_SCATTERING");
     }
     mat.SetFloat("_ScatteringWeight", preset.SSWeight);
     mat.SetFloat("_ScatteringSize", preset.SSSize);
     mat.SetFloat("_ScatteringAttenuation", preset.SSForwardAtt);
     if (preset.OutlineEnabled)
     {
         mat.EnableKeyword("_OUTLINE_ENABLED");
     }
     else
     {
         mat.DisableKeyword("_OUTLINE_ENABLED");
     }
     mat.SetColor("_OutlineColor", preset.OutlineColor);
     mat.SetFloat("_OutlineWidth", preset.OutlineWidth);
 }
Exemple #2
0
    private bool OnMouseClickSelectAttackTarget()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit, 100.0f))
            {
                Node node = hit.transform.parent.GetComponent <Node>();
                if (node)
                {
                    node.PointRenderer.SetPropertyBlock(MaterialPreset.GetMaterialPreset(EMaterialPreset.selected));
                    MagicCursor.Instance.MoveTo(node);
                    if (CheckAnotherPoringInTargetNode(node) && node.TileProperty.Type != TileType.Sanctuary && node.steps.Count > 0)
                    {
                        int resultAttackA = UnityEngine.Random.Range(0, 6);
                        int resultAttackB = UnityEngine.Random.Range(0, 6);
                        int resultDefendA = UnityEngine.Random.Range(0, 6);
                        int resultDefendB = UnityEngine.Random.Range(0, 6);

                        // Debug.LogError($"AttackA : {resultAttackA}, DefendA {resultDefendA}");
                        // Debug.LogError($"AttackB : {resultAttackB}, DefendB {resultDefendB}");
                        PhotonNetworkRaiseEvent(EventCode.SelectNodeAttack, new object[] { node.nid, resultAttackA, resultAttackB, resultDefendA, resultDefendB });

                        return(true);
                    }
                }
            }
            return(false);
        }
        else
        {
            return(false);
        }
    }
Exemple #3
0
    private void ReceiveNodeSkillSelected(Node node, BaseSkill skill)
    {
        node.PointRenderer.SetPropertyBlock(MaterialPreset.GetMaterialPreset(EMaterialPreset.selected));
        MagicCursor.Instance.MoveTo(node);
        switch (skill.TargetType)
        {
        case TargetType.Self:
            if (node.TileProperty.Type != TileType.Sanctuary)
            {
                m_cameraController.Show(CameraType.Action);
                ResetNodeColor();
                skill.OnActivate(m_currentPlayer.Poring);
                isSelectedTargetSkill = true;
            }
            break;

        case TargetType.Another:
            if (node.steps.Count > 0 && CheckAnotherPoringInTargetNode(node))
            {
                isSelectedTargetSkill = SkillSelectPoringTarget(skill, node);
            }
            break;

        case TargetType.Tile:
            if (node.steps.Count > 0)
            {
                isSelectedTargetSkill = SkillSelectTile(skill, node);
            }
            break;
        }
    }
Exemple #4
0
 public static Material GetMaterial(MaterialPreset preset)
 {
     Material result;
     if (!Materials.TryGetValue(preset, out result))
     {
         throw new ArgumentException("No such material");
     }
     return result;
 }
Exemple #5
0
    static public MaterialPropertyBlock GetMaterialPreset(EMaterialPreset preset, int presetId = 0)
    {
        for (int i = 0; i < MaterialPreset.GlobalPresetId; i++)
        {
            MaterialPreset mp = MaterialPreset.Data[i];
            if (mp == null)
            {
                continue;
            }
            print("Preset:" + mp.Preset + "/" + preset + ", PresetId:" + mp.PresetId + "/" + presetId);

            if (mp.Preset == preset && mp.PresetId == presetId)
            {
                return(mp.PropertyBlock);
            }
        }
        // print("GetMaterialPreset -> NULL");
        return(null);
    }
Exemple #6
0
    void Awake()
    {
        if (MaterialPreset.Instance == null)
        {
            MaterialPreset.Instance = this;
            MaterialPreset.Data     = new MaterialPreset[1024];
            MaterialPreset.Instance = new GameObject("MaterialPresetMaster", typeof(MaterialPreset)).GetComponent <MaterialPreset>();
            DontDestroyOnLoad(Instance.gameObject);
            return;
        }
        if (name == "MaterialPresetMaster")
        {
            print(this + " is MaterialPresetMaster"); return;
        }

        PropertyBlock = new MaterialPropertyBlock();
        Apply();

        MaterialPreset.Data[GlobalPresetId] = this;
        pid = GlobalPresetId++;
    }
Exemple #7
0
        } //Init

        void OnGUI()
        {
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, true);

            if (GUILayout.Button("Save"))
                Globals.WritePresetList();

            if (GUILayout.Button("Add New Preset"))
            {
                MaterialPreset f = new MaterialPreset();
                f.name = "New Preset";

                Globals.materialPresetList.materialPresets.Add(f);
            } //if

            if (GUILayout.Button("Create Preset from Selected Mesh"))
            {
                GameObject gameObject = Selection.activeGameObject;

                if (gameObject != null)
                {
                    SkinnedMeshRenderer skinnedMeshRenderer = gameObject.GetComponent<SkinnedMeshRenderer>();

                    if (skinnedMeshRenderer != null)
                    {
                        Material material = skinnedMeshRenderer.sharedMaterial;
                        Shader shader = material.shader;

                        MaterialPreset materialPreset = new MaterialPreset();
                        materialPreset.name = gameObject.name + " Material";
                        materialPreset.type = shader.name.Substring(shader.name.IndexOf('/') + 1);

                        int propertyCount = ShaderUtil.GetPropertyCount(shader);

                        for (int i = 0; i < propertyCount; i++)
                        {
                            if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.Vector)
                            {
                                MaterialPreset.MaterialPresetParameter materialPresetParameter = new MaterialPreset.MaterialPresetParameter();
                                materialPresetParameter.name = ShaderUtil.GetPropertyName(shader, i);
                                materialPresetParameter.values = material.GetVector(materialPresetParameter.name);

                                materialPreset.materialParameters.Add(materialPresetParameter);
                            } //if
                        } //for

                        Globals.materialPresetList.materialPresets.Add(materialPreset);
                    } //if
                } //if
                else
                    Debug.Log("No objects selected.");
            } //if

            if (GUILayout.Button("Apply Preset to Selected Mesh"))
                ApplyMaterialToMesh();

            string[] matNames = new string[Globals.materialPresetList.materialPresets.Count];

            for (int i = 0; i < Globals.materialPresetList.materialPresets.Count; i++)
                matNames[i] = Globals.materialPresetList.materialPresets[i].name;

            selected = EditorGUILayout.Popup(selected, matNames);

            EditorGUILayout.LabelField(Globals.materialPresetList.materialPresets[selected].name, EditorStyles.boldLabel);
            GUILayout.BeginHorizontal();
            Globals.materialPresetList.materialPresets[selected].name = EditorGUILayout.TextField("Preset Name", Globals.materialPresetList.materialPresets[selected].name);
            if (GUILayout.Button("Remove"))
            {
                Globals.materialPresetList.materialPresets.Remove(Globals.materialPresetList.materialPresets[selected]);
                selected = 0;
            } //if
            GUILayout.EndHorizontal();

            Globals.materialPresetList.materialPresets[selected].type = EditorGUILayout.TextField("Shader Name", Globals.materialPresetList.materialPresets[selected].type);

            if (GUILayout.Button("Add New Parameter"))
                Globals.materialPresetList.materialPresets[selected].materialParameters.Add(new MaterialPreset.MaterialPresetParameter());

            for (int i = 0; i < Globals.materialPresetList.materialPresets[selected].materialParameters.Count; i++)
            {
                EditorGUILayout.LabelField(Globals.materialPresetList.materialPresets[selected].materialParameters[i].name, EditorStyles.boldLabel);
                GUILayout.BeginHorizontal();
                Globals.materialPresetList.materialPresets[selected].materialParameters[i].name = EditorGUILayout.TextField("Parameter Name", Globals.materialPresetList.materialPresets[selected].materialParameters[i].name);
                if (GUILayout.Button("Remove"))
                {
                    Globals.materialPresetList.materialPresets[selected].materialParameters.Remove(Globals.materialPresetList.materialPresets[selected].materialParameters[i]);
                    break;
                } //if
                GUILayout.EndHorizontal();

                Globals.materialPresetList.materialPresets[selected].materialParameters[i].values = EditorGUILayout.Vector4Field("Values", Globals.materialPresetList.materialPresets[selected].materialParameters[i].values);
            } //for

            EditorGUILayout.EndScrollView();
        } //OnGUI
    public override void UpdateGameMode()
    {
        switch (state)
        {
        case DokaponGameState.focus:
            if (currentPoring == null)
            {
                return;
            }
            float distance = Vector3.Distance(currentPoring.transform.position, currentCamera.transform.position);            //print(distance);
            if (distance < 11.2f)
            {
                state         = DokaponGameState.roll;
                m_timeForRoll = TimeForRoll;

                // panelRoll.SetRoll(6);
            }
            break;

        case DokaponGameState.roll:
            m_timeForRoll -= Time.deltaTime;

            if (m_timeForRoll < 0)
            {
                Roll();
            }
            break;

        case DokaponGameState.plan:
            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit hit;
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit, 100.0f))
                {
                    Node node = hit.transform.parent.GetComponent <Node>();
                    if (node)
                    {
                        Debug.Log("You selected the " + node.nid);
                        SFX.PlayClip(resource.sound[0]).GetComponent <AudioSource>().time = 0.3f;
                        node.PointRenderer.SetPropertyBlock(MaterialPreset.GetMaterialPreset(EMaterialPreset.selected));

                        if (node.steps.Count > 0)
                        {
                            MagicCursor.Instance.MoveTo(node);
                            Route.Clear();
                            // PathToNode(node);
                            // foreach (Node n in PathToNode(node)) {
                            //  s += n.nid + ", ";
                            // }
                            RouteToNode(node);
                            // foreach (List)
                            //print(GetNodeString(PathToNode(node)));
                            // print(s);
                            foreach (List <Node> r in Route)
                            {
                                print(GetNodeString(r));
                            }
                        }
                    }
                }
            }
            break;
        }
    }
Exemple #9
0
 /// <summary>
 /// Converts a FoxKit material preset to a FoxLib material preset.
 /// </summary>
 /// <param name="foxKitMaterialPreset">The FoxKit material preset.</param>
 /// <returns>The FoxLib material preset.</returns>
 private static FoxLib.MaterialParamBinary.MaterialPreset foxKitToFoxLib(MaterialPreset foxKitMaterialPreset)
 {
     FoxLib.MaterialParamBinary.MaterialPreset foxLibMaterialPreset = new FoxLib.MaterialParamBinary.MaterialPreset(foxKitMaterialPreset.F0, foxKitMaterialPreset.RoughnessThreshold, foxKitMaterialPreset.ReflectionDependDiffuse, foxKitMaterialPreset.AnisotropicRoughness, Utils.FoxUtils.UnityColorToFoxColorRGB(foxKitMaterialPreset.SpecularColor), foxKitMaterialPreset.Translucency);
     return(foxLibMaterialPreset);
 }
Exemple #10
0
    private void ReceiveNodeSelected(Node node, int attackA, int attackB, int defendA, int defendB)
    {
        if (node)
        {
            // Debug.Log("You selected the " + node.nid);
            // SFX.PlayClip(resource.sound[0]).GetComponent<AudioSource>().time = 0.3f;
            node.PointRenderer.SetPropertyBlock(MaterialPreset.GetMaterialPreset(EMaterialPreset.selected));
            MagicCursor.Instance.MoveTo(node);
            if (node == m_currentPlayer.Poring.Node && CheckAnotherPoringInTargetNode(node) && node.TileProperty.Type != TileType.Sanctuary)
            {
                List <Poring> porings = node.porings.FindAll(poring => poring != m_currentPlayer.Poring);
                m_currentPlayer.Poring.Target = porings[Random.Range(0, porings.Count - 1)];

                m_currentPlayer.Poring.AttackResultIndex = attackA;
                m_currentPlayer.Poring.DefendResultIndex = defendA;

                m_currentPlayer.Poring.Target.AttackResultIndex = attackB;
                m_currentPlayer.Poring.Target.DefendResultIndex = defendB;

                m_cameraController.Show(CameraType.Action);
                isSelectedNode = true;
                ResetNodeColor();
                CurrentGameState = eStateGameMode.Encounter;
            }
            else if (node.steps.Count > 0 && (CheckAnotherPoringInTargetNode(node) || node.steps.Find(step => step == m_step) == m_step))
            {
                MagicCursor.Instance.MoveTo(node);

                if (CheckAnotherPoringInTargetNode(node) && node.TileProperty.Type != TileType.Sanctuary)
                {
                    List <Poring> porings = node.porings.FindAll(poring => poring != m_currentPlayer.Poring);
                    m_currentPlayer.Poring.Target = porings[Random.Range(0, porings.Count - 1)];

                    m_currentPlayer.Poring.AttackResultIndex = attackA;
                    m_currentPlayer.Poring.DefendResultIndex = defendA;

                    m_currentPlayer.Poring.Target.AttackResultIndex = attackB;
                    m_currentPlayer.Poring.Target.DefendResultIndex = defendB;

                    RouteList.Clear();
                    FindRouteNode(m_step, 0, m_currentPlayer.Poring.Node, m_currentPlayer.Poring.PrevNode);

                    RouteList = FindTargetRoute(RouteList, node);
                }
                else if (node.steps.Find(step => step == m_step) == m_step)
                {
                    m_currentPlayer.Poring.Target = null;

                    RouteList.Clear();
                    RouteToNode(node);
                }

                int indexRoute = Random.Range(0, RouteList.Count - 1);

                // TODO send result route to rendar path with UI
                m_currentPlayer.Poring.Behavior.SetupJumpToNodeTarget(RouteList[indexRoute]);

                m_cameraController.Show(CameraType.Action);
                isSelectedNode = true;
                ResetNodeColor();
            }
        }
    }
Exemple #11
0
    private void OnEvent(EventData photonEvent)
    {
        object[] data = (object[])photonEvent.CustomData;
        switch (photonEvent.Code)
        {
        // Move
        case (byte)EventCode.BeginRollMove:
            BeginRollMove((int)data[0], (int)data[1]);
            break;

        case (byte)EventCode.SelectNodeMove:
            ReceiveNodeSelected(GetNodeByNodeId((int)data[0]), (int)data[1], (int)data[2], (int)data[3], (int)data[4]);
            break;

        // Attack
        case (byte)EventCode.SelectNodeAttack:
            Node node = GetNodeByNodeId((int)data[0]);
            if (!IsMineTurn())
            {
                node.PointRenderer.SetPropertyBlock(MaterialPreset.GetMaterialPreset(EMaterialPreset.selected));
                MagicCursor.Instance.MoveTo(node);
            }
            ReceiveNodeAttackTarget(node, (int)data[1], (int)data[2], (int)data[3], (int)data[4]);
            break;

        case (byte)EventCode.HighlightNodeAttack:
            CheckHasTargetInRange((int)data[0]);
            DisplayNodeHeatByAttackRange();
            if (IsMineTurn())
            {
                StartCoroutine(WaitForSelectTarget());
            }
            break;

        // Use skill
        case (byte)EventCode.SelectNodeSkill:
            ReceiveNodeSkillSelected(GetNodeByNodeId((int)data[0]), GetSkillOfPoring((string)data[1], (int)data[2]));
            break;

        case (byte)EventCode.HighlightNodeSkill:
            BaseSkill skill = GetSkillOfPoring((string)data[0], (int)data[1]);
            ParseSelectableNode(skill);
            DisplayNodeHeatBySkill(skill);
            if (IsMineTurn())
            {
                StartCoroutine(WaitForSelectTarget(skill));
            }
            break;

        // Roll end
        case (byte)EventCode.RollEnd:
            Poring poring = m_player[(int)data[2]];
            OnRollEnd((int)data[0], (DiceType)((int)data[1]), poring);
            break;

        // On click cancel
        case (byte)EventCode.OnClickCancel:
            ResetNodeColor();
            break;

        case (byte)EventCode.SkipToEndTurn:
            CameraController.Instance.Show(CameraType.Default);
            CurrentGameState = eStateGameMode.EndTurn;
            break;
        }
    }
Exemple #12
0
 public Wall(double xstart, double ystart, double xend, double yend, MaterialPreset preset)
     : this(new Point(xstart, ystart), new Point(xend, yend), preset)
 {
 }
Exemple #13
0
 public Wall(Point start, Point end, MaterialPreset preset)
     : base(start, end)
 {
     MatPreset = preset;
     WallMaterial = Materials[preset];
 }
Exemple #14
0
 public Wall(double xstart, double ystart, double xend, double yend, Material material)
     : base(xstart, ystart, xend, yend)
 {
     WallMaterial = material;
     MatPreset = MaterialPreset.None;
 }
Exemple #15
0
 public Wall(Point start, Point end, Material material)
     : base(start, end)
 {
     WallMaterial = material;
     MatPreset = MaterialPreset.None;
 }
    private void CreateMaterial()
    {
        int clrTexIndex = -1;
        int nrmTexIndex = -1;
        int parTexIndex = -1;
        int emiTexIndex = -1;

        if (TextureParameterValues == null)
        {
            return;
        }

        for (int i = 0; i < TextureParameterValues.Length; i++)
        {
            switch (TextureParameterValues[i].ParameterName)
            {
            case "ColorTexture":
                clrTexIndex = i;
                break;

            case "NomalTexture":
                nrmTexIndex = i;
                break;

            case "ParameterTexture":
                parTexIndex = i;
                break;

            case "EmissionTexture":
                emiTexIndex = i;
                break;
            }
        }

        string shaderName = nrmTexIndex == -1 ? "Custom/AnimeNoNormal" : "Custom/Anime";

        var mat = new Material(Shader.Find(shaderName));

        context.AddObjectToAsset(Path.GetFileNameWithoutExtension(context.assetPath), mat);

        if (clrTexIndex != -1)
        {
            Texture2D clrTex =
                AssetDatabase.LoadAssetAtPath <Texture2D>(
                    GetFileNameFromParameterValue(TextureParameterValues[clrTexIndex].ParameterValue));

            mat.SetTexture("_MainTex", clrTex);
        }

        if (nrmTexIndex != -1)
        {
            string                  nrmTexPath  = GetFileNameFromParameterValue(TextureParameterValues[nrmTexIndex].ParameterValue);
            TextureImporter         nrmImporter = (TextureImporter)GetAtPath(nrmTexPath);
            TextureImporterSettings tis         = new TextureImporterSettings();
            nrmImporter.ReadTextureSettings(tis);
            tis.textureType = TextureImporterType.NormalMap;
            nrmImporter.SetTextureSettings(tis);

            Texture2D nrmTex =
                AssetDatabase.LoadAssetAtPath <Texture2D>(nrmTexPath);

            mat.SetTexture("_BumpMap", nrmTex);
        }

        if (parTexIndex != -1)
        {
            string                  parTexPath  = GetFileNameFromParameterValue(TextureParameterValues[parTexIndex].ParameterValue);
            TextureImporter         parImporter = (TextureImporter)GetAtPath(parTexPath);
            TextureImporterSettings tis         = new TextureImporterSettings();
            parImporter.ReadTextureSettings(tis);
            tis.sRGBTexture = false;
            parImporter.SetTextureSettings(tis);

            Texture2D parTex =
                AssetDatabase.LoadAssetAtPath <Texture2D>(parTexPath);

            mat.EnableKeyword("_PARAMETER_TEXTURE");
            mat.SetTexture("_ParTex", parTex);
        }

        if (emiTexIndex != -1)
        {
            Texture2D emiTex =
                AssetDatabase.LoadAssetAtPath <Texture2D>(
                    GetFileNameFromParameterValue(TextureParameterValues[emiTexIndex].ParameterValue));

            mat.SetTexture("_EmissionMap", emiTex);
            mat.SetColor("_Emission", Color.white);
            mat.SetFloat("_EmissionIntensity", 1.0f);
        }

        mat.DisableKeyword("_SUBSURFACE_SCATTERING");
        mat.EnableKeyword("_OUTLINE_ENABLED");

        string filename = Path.GetFileNameWithoutExtension(context.assetPath);

        if (filename == null)
        {
            return;
        }
        filename = filename.ToLower();

        MaterialPreset preset = body;

        if (filename.Contains("body"))
        {
            preset = filename.Contains("skin") ? skin : body;
        }
        else if (filename.Contains("acc"))
        {
            preset = emiTexIndex != -1 ? acc_emit : acc;
        }
        else if (filename.Contains("hair"))
        {
            if (filename.Contains("hairparts"))
            {
                preset = emiTexIndex != -1 ? hairParts_emit : hairParts;
            }
            else
            {
                preset = emiTexIndex != -1 ? hair_emit : hair;
            }
        }
        else if (filename.Contains("wing"))
        {
            preset = wing;
        }
        else if (filename.Contains("face"))
        {
            if (filename.Contains("mayu"))
            {
                preset = face_mayu_r0;
            }
            else if (filename.Contains("r0"))
            {
                preset = filename.Contains("r0t0") ? face_r0t0 : face_mayu_r0;
            }
            else
            {
                preset = skin;
            }
        }

        SetMaterialPreset(mat, preset);
    }