Vector3 GetDiagonal3Symetry()
    {
        Vector3 Origin  = new Vector3(0, 0, -MapLuaParser.GetMapSizeY() / 10f);
        Vector3 Origin2 = new Vector3(MapLuaParser.GetMapSizeY() / 10f, 0, 0);
        Vector3 Point   = new Vector3(BrushPos.x, 0, BrushPos.z);

        Vector3 PointOfMirror = ClosestPointToLine(Origin, Origin2, Point);
        Vector3 FinalDir      = PointOfMirror - Point;

        FinalDir.y = 0;
        FinalDir.Normalize();
        float   FinalDist   = Vector3.Distance(PointOfMirror, Point);
        Vector3 MirroredPos = PointOfMirror + FinalDir * FinalDist;

        MirroredPos.y = BrushPos.y;



        Origin  = new Vector3(0, 0, 0);
        Origin2 = new Vector3(MapLuaParser.GetMapSizeY() / 10f, 0, -MapLuaParser.GetMapSizeY() / 10f);
        Point   = new Vector3(MirroredPos.x, 0, MirroredPos.z);

        PointOfMirror = ClosestPointToLine(Origin, Origin2, Point);
        FinalDir      = PointOfMirror - Point;
        FinalDir.y    = 0;
        FinalDir.Normalize();
        FinalDist     = Vector3.Distance(PointOfMirror, Point);
        MirroredPos   = PointOfMirror + FinalDir * FinalDist;
        MirroredPos.y = BrushPos.y;

        return(MirroredPos);
    }
示例#2
0
        bool UpdateBrushPosition(bool Forced = false, bool Size = true, bool Position = true)
        {
            //Debug.Log(Vector3.Distance(MouseBeginClick, Input.mousePosition));
            if (Forced || Vector3.Distance(MouseBeginClick, Input.mousePosition) > 1)
            {
            }
            else
            {
                return(false);
            }

            float SizeXprop      = MapLuaParser.GetMapSizeX() / 512f;
            float SizeZprop      = MapLuaParser.GetMapSizeY() / 512f;
            float BrushSizeValue = BrushSize.value;

            if (BrushSizeValue < 0.2f)
            {
                BrushSizeValue = 0.2f;
            }

            if (Size)
            {
                TerrainMaterial.SetFloat("_BrushSize", BrushSizeValue / ((SizeXprop + SizeZprop) / 2f));
            }


            MouseBeginClick = Input.mousePosition;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Position && Physics.Raycast(ray, out hit, 2000, TerrainMask))
            {
                BrushPos = hit.point;
                if (SnapToGround.isOn && BrushSize.value < 1.5f)
                {
                    //BrushPos = Vector3.Lerp(ScmapEditor.SnapToSmallGridCenter(BrushPos), BrushPos, (BrushSize.value - 0.2f) / 1.5f);
                    BrushPos = ScmapEditor.SnapToSmallGrid(BrushPos + new Vector3(0.025f, 0, -0.025f));
                }

                BrushPos.y = ScmapEditor.Current.Teren.SampleHeight(BrushPos);

                Vector3 tempCoord = ScmapEditor.Current.Teren.gameObject.transform.InverseTransformPoint(BrushPos);
                Vector3 coord     = Vector3.zero;
                float   SizeX     = (int)((BrushSizeValue / SizeXprop) * 100) * 0.01f;
                float   SizeZ     = (int)((BrushSizeValue / SizeZprop) * 100) * 0.01f;
                coord.x = (tempCoord.x - SizeX * MapLuaParser.GetMapSizeX() * 0.0001f) / ScmapEditor.Current.Teren.terrainData.size.x;
                coord.z = (tempCoord.z - SizeZ * MapLuaParser.GetMapSizeY() * 0.0001f) / ScmapEditor.Current.Teren.terrainData.size.z;

                TerrainMaterial.SetFloat("_BrushUvX", coord.x);
                TerrainMaterial.SetFloat("_BrushUvY", coord.z);

                return(true);
            }
            return(false);
        }
示例#3
0
    public void UpdateArmys()
    {
        Clean();


        if (MapLuaParser.Current.ScenarioLuaFile.Data.Configurations.Length == 0 || MapLuaParser.Current.ScenarioLuaFile.Data.Configurations[0].Teams.Length == 0)
        {
            return;
        }

        var AllArmies = MapLuaParser.Current.ScenarioLuaFile.Data.Configurations[0].Teams[0].Armys;

        for (int a = 0; a < AllArmies.Count; a++)
        {
            MapLua.SaveLua.Marker ArmyMarker = MapLua.SaveLua.GetMarker(AllArmies[a].Name);

            if (ArmyMarker != null && ArmyMarker.MarkerObj != null && ArmyMarker.MarkerType == MapLua.SaveLua.Marker.MarkerTypes.BlankMarker)
            {
                GameObject NewBut = Instantiate(ArmyButtonPrefab) as GameObject;
                NewBut.transform.SetParent(Pivot);
                ArmyButtons.Add(NewBut.GetComponent <ArmyMinimapButton>());
                ArmyButtons[a].Controler  = this;
                ArmyButtons[a].InstanceId = a;
                ArmyButtons[a].ArmyId     = a;
                ArmyButtons[a].ArmyTeam   = 0;
                //ArmyInfo.GetArmyId(MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m].Name, out ArmyButtons[i].ArmyId, out ArmyButtons[i].ArmyTeam);

                //ArmyButtons[i].Name.text = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m].Name.ToString();
                ArmyButtons[a].Name.text = (a + 1).ToString();

                Vector3 IconPos = ArmyMarker.MarkerObj.transform.localPosition;
                IconPos.y = IconPos.z;
                IconPos.z = 0;

                IconPos.x /= MapLuaParser.GetMapSizeX() / 10f;
                IconPos.y /= MapLuaParser.GetMapSizeY() / 10f;

                IconPos.x *= ImageSize;
                IconPos.y *= ImageSize;

                NewBut.GetComponent <RectTransform>().localPosition = IconPos;
            }
        }


        UpdateAutoteam();
    }