Example #1
0
 public void LoadHoleData(HoleData data, int holeNumber)
 {
     this.holeData = data;
     this.number = holeNumber;
     this.score.text = "";
     this.par.text = data.Par.ToString();
     this.hole.text = holeNumber.ToString();
 }
    public void SetHoleInfo(int holeNumber, int par, GolfBall ball, Cup cup)
    {
        currentHole = holeNumber;
        this.ball   = ball;
        cup.onBallEnterCup.AddListener(ShowScoreCard);

        holeData[holeNumber] = new HoleData(par);
    }
Example #3
0
 public void OnDigMineSuccess(stHoleDataHomeUserCmd_S cmd)
 {
     if (cmd.is_vip)
     {
         vipHole = cmd.hole;
     }
     else
     {
         normalHole = cmd.hole;
     }
     MineState = HomeMineState.Mining;
     RefreshUIByHoleData(cmd.hole);
 }
Example #4
0
    public LongDrive()
    {
        conditional = (p, s, t, g) =>
        {
            HoleData hole = g.GetHoleBag().GetCurrentHoleData();

            bool longDrive = s == 1 && g.GetBall().DistanceFromTee() > 320f;
            if (hole.GetFir() && longDrive)
            {
                return(new Tuple <string, int>("Long Drive", 2));
            }
            else
            {
                return(null);
            }
        };
    }
Example #5
0
    public Fir()
    {
        conditional = (p, s, t, g) =>
        {
            HoleData hole = g.GetHoleBag().GetCurrentHoleData();

            bool fir = s == 1 && t == MaterialType.FAIRWAY;
            if (!hole.GetFir() && fir)
            {
                hole.SetFir();
                return(new Tuple <string, int>("FIR", 5));
            }
            else
            {
                return(null);
            }
        };
    }
Example #6
0
 void RefreshUIByHoleData(HoleData data)
 {
     if (data != null)
     {
         StoneID      = (uint)data.mine_base_id;
         ComPassID    = (uint)data.item;
         GainStoneNum = (uint)data.mine_num;
         MineLeftTime = (uint)data.cost_time;
         DigBeginTime = (uint)data.dig_begin;
         DigFactor    = (uint)data.dig_num;
         RobbedNum    = (uint)data.robbed_num;
         RobbedTimes  = (uint)data.be_rob_num;
         if (mineUI != null)
         {
             mineUI.RefreshUI();
         }
     }
 }
Example #7
0
 void RefreshMineData(MineData data)
 {
     mineData = data;
     if (normalHole == null)
     {
         normalHole = data.normal_hole;
     }
     if (vipHole == null)
     {
         vipHole = data.vip_hole;
     }
     if (IsMineVIP)
     {
         RefreshUIByHoleData(vipHole);
     }
     else
     {
         RefreshUIByHoleData(normalHole);
     }
 }
Example #8
0
    public override void Tick()
    {
        Mode shotMode = game.GetShotMode().GetShotMode();

        // Hit the damn thing
        game.GetBall().Strike(shotMode, game.GetBag().GetClub(), game.GetPowerbar().GetPower(), game.GetPowerbar().GetAccuracy());
        game.GetShotMode().Strike();

        PlayStrikeSound();

        HoleData hole = game.GetHoleBag().GetCurrentHoleData();

        hole.IncrementStrokes();
        if (game.GetBag().IsPutter())
        {
            hole.IncrementPutts();
        }

        game.SetState(new RunningState(game));
    }
Example #9
0
        //creates a hole
        private void create_hole(double PointOnGraphic_X, double PointOnGraphic_Y, double PointOnGraphic_Z, SolidEdgeGeometry.Face selected_face,
                                 int[] face_norm, string selected_face_normal)
        {
            // var selected_face = pGraphicDispatch as SolidEdgeGeometry.Face;
            PartDocument _doc = _application.ActiveDocument as PartDocument;

            RefPlanes refPlanes = null;
            RefPlane  refPlane  = null;

            refPlanes = _doc.RefPlanes;
            //Adding parallel refplane to the selected face
            refPlane = refPlanes.AddParallelByDistance(selected_face, 0.0, ReferenceElementConstants.igNormalSide, false, false, true, false);



            //Running windows form application
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.Run(new Form1());

            MessageBox.Show("Cancel Hole Dimension?");
            Form1 form1 = new Form1();

            //Hole diameter from user input
            double cc = form1.Hole_dia;

            while (cc < 0.0)
            {
                MessageBox.Show("Enter valid dimension");
                System.Windows.Forms.Application.EnableVisualStyles();
                System.Windows.Forms.Application.Run(new Form1());
                Form1  form2 = new Form1();
                double dd    = form2.Hole_dia;
                MessageBox.Show("Cancel diamension?");
                if (cc == dd)
                {
                    MessageBox.Show("invalid argument");
                    dd = 0.0;
                }
                cc = dd;
            }

            ProfileSets        profileSets        = null;
            ProfileSet         profileSet         = null;
            Profiles           profiles           = null;
            Profile            profile            = null;
            Models             models             = null;
            HoleDataCollection holeDataCollection = null;
            HoleData           holeData           = null;
            Holes2d            holes2D            = null;
            Holes   holes   = null;
            Sketchs sketchs = null;
            Sketch  sketch  = null;


            Array ref_dir = new double[3] as Array;

            //getting the unit vector of the reference direction
            refPlane.GetReferenceDirection(ref ref_dir);
            var Ref_dirX = ref_dir as double[];

            Array root_point = new double[3] as Array;

            refPlane.GetRootPoint(ref root_point);
            var Root_point = root_point as double[];

            //calculating the cross-product between ref_dir and normal vector
            double[] Ref_dirY = new double[3]
            {
                Ref_dirX[2] * face_norm[1] - Ref_dirX[1] * face_norm[2],
                Ref_dirX[0] * face_norm[2] - Ref_dirX[2] * face_norm[0],
                Ref_dirX[1] * face_norm[0] - Ref_dirX[0] * face_norm[1]
            };

            double Xcenter = -0.06; //local coordinates
            double Ycenter = -0.06;

            //calculating global coordinates from local coordinates
            double[] X_bar = new double[3]
            {
                Xcenter *Ref_dirX[0] + Ycenter * Ref_dirY[0] + Root_point[0],
                     Xcenter *Ref_dirX[1] + Ycenter * Ref_dirY[1] + Root_point[1],
                     Xcenter *Ref_dirX[2] + Ycenter * Ref_dirY[2] + Root_point[2]
            };

            //Calculating the angle between vectors root_point and global
            double[] OX = new double[3]
            {
                PointOnGraphic_X - Root_point[0],
                PointOnGraphic_Y - Root_point[1],
                PointOnGraphic_Z - Root_point[2]
            };

            //calculating the modulus of vector OX
            double OX_Mod = Math.Sqrt(Math.Pow(OX[0], 2) + Math.Pow(OX[1], 2) + Math.Pow(OX[2], 2));

            //calculating the modulus of vector Ref_dirX
            double Ref_dirX_Mod = Math.Sqrt(Math.Pow(Ref_dirX[0], 2) + Math.Pow(Ref_dirX[1], 2) + Math.Pow(Ref_dirX[2], 2));

            //calculating the modulus of the vector ReF_dirY
            double Ref_dirY_Mod = Math.Sqrt(Math.Pow(Ref_dirY[0], 2) + Math.Pow(Ref_dirY[1], 2) + Math.Pow(Ref_dirY[2], 2));

            //calculating the dot product between vector OX and Ref_dirY
            double dotY = (OX[0] * Ref_dirY[0]) + (OX[1] * Ref_dirY[1]) + (OX[2] * Ref_dirY[2]);

            //calculating the dot product between vector OX and Ref_dirX
            double dotX = (OX[0] * Ref_dirX[0]) + (OX[1] * Ref_dirX[1]) + (OX[2] * Ref_dirX[2]);

            //calculating the angle between vector OX and Ref_dirY
            double angleY = Math.Acos(dotY / (OX_Mod * Ref_dirY_Mod));

            //calculating the angle between vector OX and Ref_dirX
            double angleX = Math.Acos(dotX / (OX_Mod * Ref_dirX_Mod));

            double X_dir = 0.0;
            double Y_dir = 0.0;


            if (angleY > Math.PI / 2)
            {
                X_dir = OX_Mod * Math.Cos(-angleX);

                Y_dir = OX_Mod * Math.Sin(-angleX);
            }
            else
            {
                X_dir = OX_Mod * Math.Cos(angleX);
                Y_dir = OX_Mod * Math.Sin(angleX);
            }

            if (OX_Mod == 0.0)
            {
                X_dir = 0.0;
                Y_dir = 0.0;
            }

            if (cc > 0.0)
            {
                sketchs = _doc.Sketches;
                sketch  = sketchs.Add();

                holeDataCollection = _doc.HoleDataCollection;

                //Defining hole properties
                holeData = holeDataCollection.Add(
                    HoleType: SolidEdgePart.FeaturePropertyConstants.igRegularHole,
                    HoleDiameter: cc / 1000);

                profileSets = _doc.ProfileSets;
                profileSet  = profileSets.Add();
                //profiles = profileSet.Profiles;
                profiles = sketch.Profiles;

                profile = profiles.Add(refPlane);
                holes2D = profile.Holes2d;

                var dd = holes2D.Add(X_dir, Y_dir);


                profile.End(ProfileValidationType.igProfileClosed);

                // dd.Move(X_dir, Y_dir, 0.0, 0.0);
                //_application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewLookatFace);

                //getting the hole collection and creating a simple hole
                Model model = _doc.Models.Item(1);
                holes = model.Holes;
                holes.AddThroughNext(
                    Profile: profile,
                    ProfilePlaneSide: SolidEdgePart.FeaturePropertyConstants.igBoth,
                    Data: holeData);
            }
        }
Example #10
0
 public void AddHole(HoleData holeData)
 {
     holesPlayed.Add(holeData);
 }