コード例 #1
0
ファイル: TileGeometry.cs プロジェクト: egorovav/Ja2Project
        //public void AddCube(int aX, int aY, int aZ)
        //{
        //    this.AttachCube(aX, aY, aZ * 2, false);
        //}

        //public void RemoveCube(int aX, int aY, int aZ)
        //{
        //    this.AttachCube(aX, aY, aZ * 2, true);
        //}

        private void AddCubeSide(CubeSide aSide)
        {
            int _index = this.FSides.FindIndex(new Predicate <CubeSide>(x => x.Equals(aSide)));

            if (_index < 0)
            {
                this.FSides.Add(aSide);
            }
            else
            {
                this.FSides.RemoveAt(_index);
            }
        }
コード例 #2
0
ファイル: TileGeometry.cs プロジェクト: egorovav/Ja2Project
        //public CubeSide Join(CubeSide aJoinedSide)
        //{
        //    if (this.FNormal == aJoinedSide.FNormal && this.IsReversed == aJoinedSide.IsReversed)
        //    {
        //        for (int i = 0; i < 4; i++)
        //        {
        //            for (int j = 0; j < 4; j++)
        //            {
        //                if (this.FPoints[i] == aJoinedSide.FPoints[j] &&
        //                   this.FPoints[(i + 1) % 4] == aJoinedSide.FPoints[(j + 3) % 4])
        //                {
        //                    CubeSide _side = new CubeSide(
        //                        this.FPoints[(i + 2) % 4],
        //                        this.FPoints[(i + 3) % 4],
        //                        aJoinedSide.FPoints[(j + 1) % 4],
        //                        aJoinedSide.FPoints[(j + 2) % 4],
        //                        0, this.IsReversed);

        //                    return _side;
        //                }
        //            }
        //        }
        //    }

        //    return null;
        //}

        public override bool Equals(object obj)
        {
            CubeSide _cubeSide = (CubeSide)obj;

            foreach (Point3D _point in _cubeSide.FPoints)
            {
                if (!this.FPoints.Contains(_point))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #3
0
ファイル: TileGeometry.cs プロジェクト: egorovav/Ja2Project
        //public void JoinCubeSides()
        //{
        //    for(int i = 0; i < this.FSides.Count; i++)
        //    {
        //        if (this.FSides[i] == null)
        //            continue;

        //        for(int j = 0; j < this.FSides.Count; j++)
        //        {
        //            if (i == j || this.FSides[j] == null)
        //                continue;

        //            CubeSide _joinedSide = this.FSides[i].Join(this.FSides[j]);
        //            if (_joinedSide != null)
        //            {
        //                this.FSides[j] = _joinedSide;
        //                this.FSides[i] = null;
        //                break;
        //            }
        //        }
        //    }

        //    this.FSides = this.FSides.Where(x => x != null).ToList();
        //}

        public void AttachCube(int aX, int aY, int aZ, bool aIsReverse, int aTileSize, int aTileBottom)
        {
            double _x = aX + this.FTile.XPosRelToBase * aTileSize - this.FCenter.X;
            double _y = aZ + aTileBottom * 2 - this.FCenter.Z;
            double _z = aY + this.FTile.YPosRelToBase * aTileSize - this.FCenter.Y;

            Point3D _xyz    = new Point3D(_x, _y, _z);
            Point3D _x1yz   = new Point3D(_x + 1, _y, _z);
            Point3D _x1y2z  = new Point3D(_x + 1, _y + 2, _z);
            Point3D _xy2z   = new Point3D(_x, _y + 2, _z);
            Point3D _xy2z1  = new Point3D(_x, _y + 2, _z + 1);
            Point3D _xyz1   = new Point3D(_x, _y, _z + 1);
            Point3D _x1yz1  = new Point3D(_x + 1, _y, _z + 1);
            Point3D _x1y2z1 = new Point3D(_x + 1, _y + 2, _z + 1);

            CubeSide _frontSide = new CubeSide(_xyz, _x1yz, _x1y2z, _xy2z, this.PointsCount, aIsReverse);

            this.AddCubeSide(_frontSide);

            CubeSide _leftSide = new CubeSide(_xyz, _xy2z, _xy2z1, _xyz1, this.PointsCount, aIsReverse);

            this.AddCubeSide(_leftSide);

            CubeSide _rightSide = new CubeSide(_x1yz, _x1yz1, _x1y2z1, _x1y2z, this.PointsCount, aIsReverse);

            this.AddCubeSide(_rightSide);

            CubeSide _backSide = new CubeSide(_xyz1, _xy2z1, _x1y2z1, _x1yz1, this.PointsCount, aIsReverse);

            this.AddCubeSide(_backSide);

            CubeSide _bottomSide = new CubeSide(_xyz, _xyz1, _x1yz1, _x1yz, this.PointsCount, aIsReverse);

            this.AddCubeSide(_bottomSide);

            CubeSide _topSide = new CubeSide(_xy2z, _x1y2z, _x1y2z1, _xy2z1, this.PointsCount, aIsReverse);

            this.AddCubeSide(_topSide);
        }