コード例 #1
0
        private void LocationAddToTripButton_Click(object sender, RoutedEventArgs e)
        {
            LOCATION location = LocationListComboBox.SelectedItem as LOCATION;

            if (location == null)
            {
                MessageBox.Show("Bạn chưa chọn địa điểm dừng"); return;
            }
            string cost = LocationCostTextBox.Text;

            if (cost == null)
            {
                MessageBox.Show("Bạn chưa nhập Chi phí"); return;
            }
            if (!cost.All(char.IsDigit))
            {
                MessageBox.Show("Chi phí là Số ( vd: 10000)"); return;
            }
            if (AddNewTripViewModel.Instance.AddTrip.TRIP_LOCATION.Where(item => item.LOCATION_ID == location.LOCATION_ID).ToList().Count != 0) //TODO
            {
                MessageBox.Show("Đã có điểm dừng này !"); return;
            }
            AddNewTripViewModel.Instance.AddTrip.TRIP_LOCATION.Add(new TRIP_LOCATION {
                LOCATION_ID = location.LOCATION_ID, COSTS = Convert.ToDouble(cost), LOCATION = location
            });
            LocationAddedListView.Items.Refresh();

            TotalCostTextBox.Text = (Convert.ToInt32(TotalCostTextBox.Text) + Convert.ToInt32(cost)).ToString();
            AddNewTripViewModel.Instance.AddTrip.TOTALCOSTS = Convert.ToDouble(TotalCostTextBox.Text);
        }
コード例 #2
0
        public async Task <ActionResult> Create([Bind(Include = "ID_LOCATION,LOCATION_NAME,CATEGORY,DETAIL,PICTURE,S_DATE,E_DATE,ADDRESS,FACILITY,PRICE,AREA,PROMOTE_L_ID")] LOCATION lOCATION)
        {
            if (ModelState.IsValid)
            {
                lOCATION.ID_LOCATION = (short)(db.LOCATIONs.Count() + 1);

                lOCATION.Owner_location = Session["username"].ToString();
                var owner_lo = db.MEMBERs.Where(a => a.USERNAME.Equals(lOCATION.Owner_location)).FirstOrDefault();
                lOCATION.MEMBERs.Add(owner_lo);

                string[] date = lOCATION.S_DATE.Split('-');
                lOCATION.S_DATE       = date[1] + '/' + date[0] + '/' + date[2];
                lOCATION.TIME_START_L = Convert.ToDateTime(lOCATION.S_DATE);

                string[] date1 = lOCATION.E_DATE.Split('-');
                lOCATION.E_DATE     = date1[1] + '/' + date1[0] + '/' + date1[2];
                lOCATION.TIME_END_L = Convert.ToDateTime(lOCATION.E_DATE);


                db.LOCATIONs.Add(lOCATION);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.PROMOTE_L_ID = new SelectList(db.PROMOTE_L, "PROMOTE_ID", "PROMOTE_ID", lOCATION.PROMOTE_L_ID);
            return(View(lOCATION));
        }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        LOCATION newLocation = LOCATION.NA;

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            newLocation = locationMap[currentLocation].GetLocationLeft();
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            newLocation = locationMap[currentLocation].GetLocationRight();
        }
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            newLocation = locationMap[currentLocation].GetLocationUp();
        }
        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            newLocation = locationMap[currentLocation].GetLocationDown();
        }

        if (newLocation != LOCATION.NA)
        {
            locationMap[currentLocation].DisablePointer();
            currentLocation = newLocation;
            locationMap[currentLocation].EnablePointer();
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            locationMap[currentLocation].Mark();
        }
    }
コード例 #4
0
        private void EditLocationButton_Click(object sender, RoutedEventArgs e)
        {
            Button   editLocationButton = sender as Button;
            LOCATION editLocation       = editLocationButton.Tag as LOCATION;

            HomeScreen.GetHomeScreenInstance().GetDialogs("LocationAddDialog", editLocation, "Xem/Chỉnh sửa điểm dừng");
        }
コード例 #5
0
 public static string InsertStore(string userid, string longitude, string latitude, string storeName, string phone, string street_number, string route, string city, string state, string postal_code, string country, string price, string website, string description)
 {
     try
     {
         if (string.IsNullOrEmpty(longitude) || string.IsNullOrEmpty(latitude) || string.IsNullOrEmpty(street_number) || string.IsNullOrEmpty(route) || string.IsNullOrEmpty(city) || string.IsNullOrEmpty(state) || string.IsNullOrEmpty(postal_code) || string.IsNullOrEmpty(country))
         {
             return Strings.StoreAlert_Location;
         }
         if (string.IsNullOrEmpty(storeName) || string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(price))
         {
             return Strings.StoreAlert_Info;
         }
         LOCATION location = mydb.LOCATIONs.SingleOrDefault(l => l.LATITUDE == Convert.ToDouble(latitude) && l.LONGITUDE == Convert.ToDouble(longitude));
         if (location == null)
         {
             location = new LOCATION() { LONGITUDE = Convert.ToDouble(longitude), LATITUDE = Convert.ToDouble(latitude) };
             mydb.LOCATIONs.InsertOnSubmit(location);
         }
         ADDRESS address = mydb.ADDRESSes.SingleOrDefault(a => a.ADDRESS_LINE1 == street_number + " " + route && a.CITY == city && a.STATE_PROVINCE_REGION == state && a.POSTAL_CODE == postal_code && a.COUNTRY == country);
         if (address == null)
         {
             address = new ADDRESS() { ADDRESS_LINE1 = street_number + " " + route, CITY = city, STATE_PROVINCE_REGION = state, POSTAL_CODE = postal_code, COUNTRY = country };
             mydb.ADDRESSes.InsertOnSubmit(address);
         }
         STORE store = new STORE() { NAME = storeName, DESCRIPTION = description, PHONE = phone, WEBSITE = website, OWNER = userid, PRICE_LEVEL = Convert.ToInt32(price) };
         store.LOCATION = location;
         store.ADDRESS = address;
         mydb.SubmitChanges();
         return Strings.StoreAlert_Success;
     }
     catch (Exception e)
     {
         return e.Message;
     }
 }
コード例 #6
0
    protected void gvUSERINFO_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label lblAgent_LocationID   = (Label)e.Row.FindControl("lblAgent_LocationID");
            Label lblAgent_LocationName = (Label)e.Row.FindControl("lblAgent_LocationName");
            if (ddlUserType.SelectedItem.Value.ToString() == "Agent")
            {
                AGENT aGENT = new AGENT();
                aGENT = AGENTManager.GetAGENTByID(int.Parse(lblAgent_LocationID.Text));

                if (aGENT != null)
                {
                    lblAgent_LocationName.Text = aGENT.AGENTNAME.ToString();
                }
            }
            else
            {
                LOCATION lOCATION = new LOCATION();
                lOCATION = LOCATIONManager.GetLOCATIONByID(int.Parse(lblAgent_LocationID.Text));
                if (lOCATION != null)
                {
                    lblAgent_LocationName.Text = lOCATION.BRANCH.ToString();
                }
            }
        }
    }
コード例 #7
0
    protected void gvTRANS_RowDataBound(Object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label lblReceiver = (Label)e.Row.FindControl("lblReceiver");
            Label lblLocation = (Label)e.Row.FindControl("lblLocation");

            Label lblRECEIVERID = (Label)e.Row.FindControl("lblRECEIVERID");
            Label lblLOCATIONID = (Label)e.Row.FindControl("lblLOCATIONID");

            RECEIVER rECEIVER = new RECEIVER();
            rECEIVER = RECEIVERManager.GetRECEIVERByID(int.Parse(lblRECEIVERID.Text));

            if (rECEIVER != null)
            {
                lblReceiver.Text = rECEIVER.RECEIVERFNAME.ToString();
            }

            LOCATION lOCATION = new LOCATION();
            lOCATION = LOCATIONManager.GetLOCATIONByID(int.Parse(lblLOCATIONID.Text));

            if (lOCATION != null)
            {
                lblLocation.Text = lOCATION.BRANCH.ToString();
            }
        }
    }
コード例 #8
0
        /// <summary>
        /// Overlays a bitmap onto another bitmap.
        /// </summary>
        /// <param name="bitmap">the base bit map that will have the overlay applied to it</param>
        /// <param name="overlay">the bitmap that will be overlayed (the top layer)</param>
        /// <param name="location">the location where the overlay should be placed.</param>
        public static void OverlayBitmap(Bitmap bitmap, Bitmap overlay, LOCATION location)
        {
            Graphics g = Graphics.FromImage(bitmap);

            Rectangle bitmapRectangle;

            if (location == LOCATION.TOP_LEFT)
            {
                bitmapRectangle = new Rectangle(0, 0, overlay.Width, overlay.Height);
            }
            else if (location == LOCATION.BOTTOM_LEFT)
            {
                bitmapRectangle = new Rectangle(0, bitmap.Height - overlay.Height, overlay.Width, overlay.Height);
            }
            else if (location == LOCATION.TOP_RIGHT)
            {
                bitmapRectangle = new Rectangle(bitmap.Width - overlay.Width, 0, overlay.Width, overlay.Height);
            }
            else if (location == LOCATION.BOTTOM_RIGHT)
            {
                bitmapRectangle = new Rectangle(bitmap.Width - overlay.Width, bitmap.Height - overlay.Height, overlay.Width, overlay.Height);
            }
            else
            {
                Debug.Fail("Unsupported location: " + location);
                bitmapRectangle = new Rectangle(0, 0, overlay.Width, overlay.Height);
            }

            g.DrawImageUnscaled(overlay,
                                bitmapRectangle.Left,
                                bitmapRectangle.Top);
        }
コード例 #9
0
 public RentFilmViewModel(LOCATION location, PERSONNESFILM realisateur, char type, String message)
 {
     this.location    = location;
     this.type        = type;
     this.message     = message;
     this.realisateur = realisateur;
 }
コード例 #10
0
    protected void gvFoodTransactionItemRelation_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label lblfID      = (Label)e.Row.FindControl("lblfID");
            Label lblFoodItem = (Label)e.Row.FindControl("lblFoodItem");

            Label lblfRATE    = (Label)e.Row.FindControl("lblfRATE");
            Label lblfQTY     = (Label)e.Row.FindControl("lblfQTY");
            Label lblSubTotal = (Label)e.Row.FindControl("lblSubTotal");
            Label lblTOTALAMT = (Label)e.Row.FindControl("lblTOTALAMT");


            Label lblCUSTID     = (Label)e.Row.FindControl("lblCUSTID");
            Label lblLOCATIONID = (Label)e.Row.FindControl("lblLOCATIONID");
            Label lblRECEIVERID = (Label)e.Row.FindControl("lblRECEIVERID");

            Label lblCUSTFname     = (Label)e.Row.FindControl("lblCUSTFname");
            Label lblLOCATIONName  = (Label)e.Row.FindControl("lblLOCATIONName");
            Label lblRECEIVERFname = (Label)e.Row.FindControl("lblRECEIVERFname");

            FOODITEM_MASTER foodItems = new FOODITEM_MASTER();
            foodItems = FOODITEM_MASTERManager.GetFOODITEM_MASTERByID(int.Parse(lblfID.Text));

            if (Items != null)
            {
                lblFoodItem.Text = foodItems.ITEMNAME.ToString();
            }



            //lblSubTotal.Text = (decimal.Parse(lblfRATE.Text) * int.Parse(lblfQTY.Text)).ToString();

            CUSTOMER cUSTOMER = new CUSTOMER();
            cUSTOMER = CUSTOMERManager.GetCUSTOMERByID(int.Parse(lblCUSTID.Text));
            if (cUSTOMER != null)
            {
                lblCUSTFname.Text = cUSTOMER.CUSTFNAME.ToString();
            }

            LOCATION lOCATION = new LOCATION();
            lOCATION = LOCATIONManager.GetLOCATIONByID(int.Parse(lblLOCATIONID.Text));

            if (lOCATION != null)
            {
                lblLOCATIONName.Text = lOCATION.BRANCH.ToString();
            }

            RECEIVER rECEIVER = new RECEIVER();
            rECEIVER = RECEIVERManager.GetRECEIVERByID(int.Parse(lblRECEIVERID.Text));

            if (rECEIVER != null)
            {
                lblRECEIVERFname.Text = rECEIVER.RECEIVERFNAME.ToString();
            }

            lblTOTALAMT.Text = lblTOTALAMT.Text;
        }
    }
コード例 #11
0
ファイル: Payment.aspx.cs プロジェクト: anam/koromstar
    protected void loadLocationInfo()
    {
        LOCATION lOCATION = new LOCATION();

        lOCATION       = LOCATIONManager.GetLOCATIONByID(int.Parse(Session["snlocationID"].ToString()));
        txtBranch.Text = lOCATION.BRANCH.ToString();
        lblRate.Text   = lOCATION.AGENTRATE.ToString();
    }
コード例 #12
0
    public static LOCATION GetLOCATIONByIDByAgentID(int id, int agentID)
    {
        LOCATION            lOCATION            = new LOCATION();
        SqlLOCATIONProvider sqlLOCATIONProvider = new SqlLOCATIONProvider();

        lOCATION = sqlLOCATIONProvider.GetLOCATIONByIDByAGNETID(id, agentID);
        return(lOCATION);
    }
コード例 #13
0
ファイル: Table.cs プロジェクト: BenightedSyper/PEG-EMS
 public Peg(int _number, int _team, int _player, LOCATION _location, int _distance)
 {
     Number = _number;
     Team = _team;
     Player = _player;
     Location = _location;
     Distance = _distance;
 }
コード例 #14
0
ファイル: EditPayment.aspx.cs プロジェクト: anam/koromstar
    protected void loadLocationInfo(int locationID)
    {
        LOCATION lOCATION = new LOCATION();

        lOCATION       = LOCATIONManager.GetLOCATIONByID(locationID);
        txtBranch.Text = lOCATION.BRANCH.ToString();
        lblRate.Text   = lOCATION.AGENTRATE.ToString();
    }
コード例 #15
0
    public static LOCATION GetLOCATIONByID(int id)
    {
        LOCATION            lOCATION            = new LOCATION();
        SqlLOCATIONProvider sqlLOCATIONProvider = new SqlLOCATIONProvider();

        lOCATION = sqlLOCATIONProvider.GetLOCATIONByID(id);
        return(lOCATION);
    }
コード例 #16
0
        public async Task <ActionResult> DeleteConfirmed(short id)
        {
            LOCATION lOCATION = await db.LOCATION.FindAsync(id);

            db.LOCATION.Remove(lOCATION);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
コード例 #17
0
        private async static void OpenLocationAddDialog(LOCATION location, string tittle)
        {
            var view = new LocationAddDialog
            {
                DataContext = new LocationAddDialogViewModel(location, tittle)
            };

            var result = await DialogHost.Show(view, ClosingLocationDialogEventHandler);

            Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL"));
        }
コード例 #18
0
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            int locationId = Convert.ToInt32((sender as Button).Tag);

            if (locationId != 0)
            {
                LOCATION reloadLocation = HomeScreen.GetDatabaseEntities().LOCATIONS.FirstOrDefault(item => item.LOCATION_ID == locationId);
                HomeScreen.GetDatabaseEntities().Entry(reloadLocation).Reload();
                LocationListControl.updateUI();
            }
        }
コード例 #19
0
        public async Task <ActionResult> Edit([Bind(Include = "ID_LOCATION,LOCATION_NAME,CATEGORY,DETAIL,PICTURE,TIME_START_L,TIME_END_L,ADDRESS,FACILITY,PRICE,AREA,PROMOTE_L")] LOCATION lOCATION)
        {
            if (ModelState.IsValid)
            {
                db.Entry(lOCATION).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Details", new { id = lOCATION.ID_LOCATION }));
            }
            ViewBag.PROMOTE_L_ID = new SelectList(db.PROMOTE_L, "PROMOTE_ID", "PROMOTE_ID", lOCATION.PROMOTE_L_ID);
            return(View(lOCATION));
        }
コード例 #20
0
 internal void updateList(LOCATION newLocation)
 {
     if (instance != null)
     {
         LOCATIONS.Add(newLocation);
         DisplayObjects();
         if (LOCATIONS.Count % Paging.RowsPerPage == 1)
         {
             CalculatePagingInfo(Paging.RowsPerPage, LOCATIONS.Count, SelectedIndex);
         }
     }
 }
コード例 #21
0
 public LocationAddDialogViewModel(LOCATION location, string tittle)
 {
     NewLocation = location;
     Tittle      = tittle;
     if (location.LOCATION_ID == 0)
     {
         type = "add";
     }
     else
     {
         type = "edit";
     }
 }
コード例 #22
0
ファイル: UserManager.cs プロジェクト: ismailhnd/lostnfound
        public void AddLocation(Location data)
        {
            using (lostfoundDB db = new lostfoundDB())
            {
                LOCATION location = new LOCATION
                {
                    TITLE = data.Title
                };

                db.LOCATIONs.Add(location);
                db.SaveChanges();
            }
        }
コード例 #23
0
    protected void GetlocationInfo()
    {
        LOCATION lOCATION = new LOCATION();

        lOCATION = LOCATIONManager.GetLOCATIONByID(int.Parse(ddlLoction.SelectedItem.Value.ToString()));
        if (lOCATION != null)
        {
            txtCountry.Text = lOCATION.COUNTRY.ToString();
            txtCity.Text    = lOCATION.CITY.ToString();
            txtBranch.Text  = lOCATION.BRANCH.ToString();
            loadFoodItem(LOCATIONMAPPINGManager.GetLOCATIONMAPPINGByLOCATIONID(int.Parse(ddlLoction.SelectedItem.Value.ToString()))[0].LOCATIONGROUPID);
        }
    }
コード例 #24
0
 public ActionResult DeleteConfirmed(int id)
 {
     if (Request.IsAuthenticated)
     {
         LOCATION lOCATION = db.LOCATIONs.Find(id);
         db.LOCATIONs.Remove(lOCATION);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
コード例 #25
0
        // GET: LOCATIONs/Delete/5
        public async Task <ActionResult> Delete(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LOCATION lOCATION = await db.LOCATION.FindAsync(id);

            if (lOCATION == null)
            {
                return(HttpNotFound());
            }
            return(View(lOCATION));
        }
コード例 #26
0
ファイル: AddLocation.aspx.cs プロジェクト: anam/koromstar
    protected void InsertlocationInfo()
    {
        LOCATION lOCATION = new LOCATION();

        lOCATION.COUNTRY     = txtCOUNTRY.Text;
        lOCATION.CITY        = txtCITY.Text;
        lOCATION.BRANCH      = txtBRANCH.Text;
        lOCATION.BRANCH_CODE = txtBRANCH_CODE.Text;
        lOCATION.SEQUENCE    = Int32.Parse(txtSEQUENCE.Text);
        lOCATION.AGENTID     = Int32.Parse(ddlAGENT.SelectedValue);
        lOCATION.AGENTRATE   = decimal.Parse(txtAGENTRATE.Text);
        int resutl = LOCATIONManager.InsertLOCATION(lOCATION);

        lblMessage.Text = "Saved Successfully";
    }
コード例 #27
0
        // GET: LOCATIONs/Edit/5
        public async Task <ActionResult> Edit(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LOCATION lOCATION = await db.LOCATION.FindAsync(id);

            if (lOCATION == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PROMOTE_L_ID = new SelectList(db.PROMOTE_L, "PROMOTE_ID", "PROMOTE_ID", lOCATION.PROMOTE_L_ID);
            return(View(lOCATION));
        }
コード例 #28
0
        public bool UpdateLocation(LOCATION actualizLoc)
        {
            LOCATION loc = contexto.LOCATION.Where(l => l.ID == actualizLoc.ID).SingleOrDefault();

            if (loc != null)
            {
                loc.LATITUD  = actualizLoc.LATITUD;
                loc.LONGITUD = actualizLoc.LONGITUD;
                contexto.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #29
0
        public JsonResult SaveLocation(int locationId, string name, string description, decimal longitude, decimal latitude)
        {
            JsonResponseModel result = new JsonResponseModel();

            try
            {
                if (locationId > 0 && !string.IsNullOrEmpty(name) && longitude > 0M && latitude > 0M)
                {
                    _locationLogic = new LocationLogic();
                    LOCATION location = _locationLogic.GetEntityBy(c => c.Id == locationId);

                    LOCATION existingLocation = _locationLogic.GetEntitiesBy(c => c.Latitude == latitude && c.Longitude == longitude && c.Id != locationId).LastOrDefault();
                    if (existingLocation == null)
                    {
                        if (location != null)
                        {
                            location.Name        = name;
                            location.Description = description;
                            location.Longitude   = longitude;
                            location.Latitude    = latitude;

                            _locationLogic.Modify(location);
                        }

                        result.IsError = false;
                        result.Message = "Operation Successful!";
                    }
                    else
                    {
                        result.IsError = true;
                        result.Message = "Location with the same cordinates exists.";
                    }
                }
                else
                {
                    result.IsError = true;
                    result.Message = "Invalid parameter";
                }
            }
            catch (Exception ex)
            {
                result.IsError = true;
                result.Message = ex.Message;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #30
0
 public ActionResult Edit([Bind(Include = "locationID,name,address,street,city,state,country")] LOCATION lOCATION)
 {
     if (Request.IsAuthenticated)
     {
         if (ModelState.IsValid)
         {
             db.Entry(lOCATION).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(lOCATION));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
コード例 #31
0
        public async Task <ActionResult> Promote(short id, LOCATIONsViewModel promote_location)
        {
            LOCATION lOCATION = await db.LOCATION.FindAsync(id);

            MEMBER mEMBER = await db.MEMBER.FindAsync(Session["id"]);

            promote_location.location_promote            = new PROMOTE_L();
            promote_location.location_promote.PROMOTE_ID = (short)(db.PROMOTE_L.Count() + 1);
            promote_location.location_promote.END_DATE   = DateTime.Today.AddDays(promote_location.day_of_promote);
            promote_location.location_promote.BUDGETS    = (lOCATION.PRICE * 5 * promote_location.day_of_promote) / 100;
            promote_location.location_promote.MEMBER     = mEMBER;
            promote_location.location_promote.LOCATION.Add(lOCATION);
            db.PROMOTE_L.Add(promote_location.location_promote);
            await db.SaveChangesAsync();

            return(RedirectToAction("Details", new { id = lOCATION.ID_LOCATION }));
        }
コード例 #32
0
ファイル: Arguments.cs プロジェクト: toddcoder/Orange2
        public static Arguments FromValue(Value value, bool returnNullIfNotExecutable = true)
        {
            value = value.Self;
            switch (value)
            {
            case OTuple tuple:
            {
                tuple.Values.Must().HaveLengthOf(2).OrThrow(LOCATION, () => "Tuple must have at least two values");
                var innerValue = tuple[0];
                if (tuple[1] is Lambda innerLambda)
                {
                    return(new Arguments(innerValue, innerLambda.Block, innerLambda.Parameters));
                }

                throw LOCATION.ThrowsWithLocation(() => "Second value must be a lambda");
            }

            case MessagePath chain:
            {
                var builder = new CodeBuilder();
                builder.Variable(State.DefaultParameterNames.ValueVariable);
                builder.Apply();
                builder.Value(chain);
                var block = builder.Block;
                return(new Arguments(new NullBlock(), block));
            }

            case Lambda lambda:
                return(new Arguments(new NullBlock(), lambda.Block, lambda.Parameters)
                {
                    Splatting = lambda.Splatting
                });

            case Block aBlock:
                return(new Arguments(new NullBlock(), aBlock, new NullParameters()));
            }

            if (returnNullIfNotExecutable)
            {
                return(null);
            }

            var argumentsBlock = PushValue(value);

            return(new Arguments(argumentsBlock));
        }
コード例 #33
0
        /// <summary>
        /// Overlays a bitmap onto another bitmap.
        /// </summary>
        /// <param name="bitmap">the base bit map that will have the overlay applied to it</param>
        /// <param name="overlay">the bitmap that will be overlayed (the top layer)</param>
        /// <param name="location">the location where the overlay should be placed.</param>
        public static void OverlayBitmap(Bitmap bitmap, Bitmap overlay, LOCATION location)
        {
            Graphics g = Graphics.FromImage(bitmap);

            Rectangle bitmapRectangle;
            if (location == LOCATION.TOP_LEFT)
                bitmapRectangle = new Rectangle(0, 0, overlay.Width, overlay.Height);
            else if (location == LOCATION.BOTTOM_LEFT)
                bitmapRectangle = new Rectangle(0, bitmap.Height - overlay.Height, overlay.Width, overlay.Height);
            else if (location == LOCATION.TOP_RIGHT)
                bitmapRectangle = new Rectangle(bitmap.Width - overlay.Width, 0, overlay.Width, overlay.Height);
            else if (location == LOCATION.BOTTOM_RIGHT)
                bitmapRectangle = new Rectangle(bitmap.Width - overlay.Width, bitmap.Height - overlay.Height, overlay.Width, overlay.Height);
            else
            {
                Debug.Fail("Unsupported location: " + location);
                bitmapRectangle = new Rectangle(0, 0, overlay.Width, overlay.Height);
            }

            g.DrawImageUnscaled(overlay,
                bitmapRectangle.Left,
                bitmapRectangle.Top);
        }
コード例 #34
0
ファイル: Card.cs プロジェクト: johanjordaan/mtgfool
 public void SetLocation(LOCATION newLocation)
 {
     Location = newLocation;
 }
コード例 #35
0
ファイル: Table.cs プロジェクト: BenightedSyper/PEG-EMS
    public void DisplayMove()
    {
        string MoveDescription= "";
        switch(LastPlayed.Rank){
        case RANK.Ace:
            MoveDescription = "Player: " + TurnCounter + " played an Ace on Peg: " + FirstPeg.Location + " " + FirstPeg.Distance + "\n";
            if(FirstPeg.Location == LOCATION.HOME){
                MoveToLocationFirst = LOCATION.MAINTRACK;
                MoveToDistanceFirst = 0;
                MoveDescription += "moving to " + MoveToLocationFirst + " " + MoveToDistanceFirst;
            }
            if(FirstPeg.Location == LOCATION.MAINTRACK){
                //two options: 1 space and 11 spaces
                hSliderValue = GUI.HorizontalSlider(new Rect(25, (CARDHEIGHT + CARDBUFFER) * 2, 100, 30), hSliderValue, 0.0F, 1.0F);
                CheckAceSlider();
                MoveToLocationFirst = LOCATION.MAINTRACK;
                MoveToDistanceFirst = (hSliderValue > 0 ? 11 : 1);
                MoveDescription += "moving to " + MoveToLocationFirst + " " + MoveToDistanceFirst;
                if( FirstPeg.Distance < TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && MoveToDistanceFirst > TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && (MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter)) < 5){
                    //give the option to move into the castle
                    MoveToLocationFirst = LOCATION.CASTLE;
                    MoveToDistanceFirst = MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter);

                }
            }
            if(FirstPeg.Location == LOCATION.CASTLE){
                MoveToLocationFirst = LOCATION.CASTLE;
                MoveToDistanceFirst = 1;
            }
            break;
        case RANK.Two:
            MoveDescription = "Player: " + TurnCounter + " played a Two on Peg: " + FirstPeg.Location + " " + FirstPeg.Distance + "\n";
            if(FirstPeg.Location == LOCATION.MAINTRACK){
                //2 spaces Forward
                MoveToLocationFirst = LOCATION.MAINTRACK;
                MoveToDistanceFirst = 2;
                MoveDescription += "moving to " + MoveToLocationFirst + " " + MoveToDistanceFirst;
                if( FirstPeg.Distance < TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && MoveToDistanceFirst > TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && (MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter)) < 5){
                    //give the option to move into the castle
                    MoveToLocationFirst = LOCATION.CASTLE;
                    MoveToDistanceFirst = MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter);
                }
            }
            if(FirstPeg.Location == LOCATION.CASTLE){
                MoveToLocationFirst = LOCATION.CASTLE;
                MoveToDistanceFirst = 2;
            }
            break;
        case RANK.Three:
            MoveDescription = "Player: " + TurnCounter + " played a Three on Peg: " + FirstPeg.Location + " " + FirstPeg.Distance + "\n";
            if(FirstPeg.Location == LOCATION.MAINTRACK){
                //2 spaces Forward
                MoveToLocationFirst = LOCATION.MAINTRACK;
                MoveToDistanceFirst = 3;
                MoveDescription += "moving to " + MoveToLocationFirst + " " + MoveToDistanceFirst;
                if( FirstPeg.Distance < TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && MoveToDistanceFirst > TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && (MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter)) < 5){
                    //give the option to move into the castle
                    MoveToLocationFirst = LOCATION.CASTLE;
                    MoveToDistanceFirst = MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter);
                }
            }
            if(FirstPeg.Location == LOCATION.CASTLE){
                MoveToLocationFirst = LOCATION.CASTLE;
                MoveToDistanceFirst = 3;
            }
            break;
        case RANK.Four:
            MoveDescription = "Player: " + TurnCounter + " played a Four on Peg: " + FirstPeg.Location + " " + FirstPeg.Distance + "\n";
            if(FirstPeg.Location == LOCATION.MAINTRACK){
                //2 spaces Forward
                MoveToLocationFirst = LOCATION.MAINTRACK;
                MoveToDistanceFirst = 4;
                MoveDescription += "moving to " + MoveToLocationFirst + " " + MoveToDistanceFirst;
                if( FirstPeg.Distance < TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && MoveToDistanceFirst > TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && (MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter)) < 5){
                    //give the option to move into the castle
                    MoveToLocationFirst = LOCATION.CASTLE;
                    MoveToDistanceFirst = MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter);
                }
            }
            if(FirstPeg.Location == LOCATION.CASTLE){
                MoveToLocationFirst = LOCATION.CASTLE;
                MoveToDistanceFirst = 4;
            }
            break;
        case RANK.Five:
            MoveDescription = "Player: " + TurnCounter + " played a Five on Peg: " + FirstPeg.Location + " " + FirstPeg.Distance + "\n";
            if(FirstPeg.Location == LOCATION.MAINTRACK){
                //2 spaces Forward
                MoveToLocationFirst = LOCATION.MAINTRACK;
                MoveToDistanceFirst = 5;
                MoveDescription += "moving to " + MoveToLocationFirst + " " + MoveToDistanceFirst;
                if( FirstPeg.Distance < TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && MoveToDistanceFirst > TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && (MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter)) < 5){
                    //give the option to move into the castle
                    MoveToLocationFirst = LOCATION.CASTLE;
                    MoveToDistanceFirst = MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter);
                }
            }
            break;
        case RANK.Six:
            MoveDescription = "Player: " + TurnCounter + " played a Six on Peg: " + FirstPeg.Location + " " + FirstPeg.Distance + "\n";
            if(FirstPeg.Location == LOCATION.MAINTRACK){
                //2 spaces Forward
                MoveToLocationFirst = LOCATION.MAINTRACK;
                MoveToDistanceFirst = 6;
                MoveDescription += "moving to " + MoveToLocationFirst + " " + MoveToDistanceFirst;
                if( FirstPeg.Distance < TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && MoveToDistanceFirst > TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && (MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter)) < 5){
                    //give the option to move into the castle
                    MoveToLocationFirst = LOCATION.CASTLE;
                    MoveToDistanceFirst = MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter);
                }
            }
            break;
        case RANK.Seven://needs logic for only one playable peg
            MoveDescription = "Player: " + TurnCounter + " played a Seven on Pegs: " + FirstPeg.Location + " " + FirstPeg.Distance + "and " + SecondPeg + " " + SecondPeg.Distance + "\n";
            //6 options: 1/6 2/5 3/4 4/3 5/2 6/1
            hSliderSevenValue = GUI.HorizontalSlider(new Rect(25, (CARDHEIGHT + CARDBUFFER) * 2, 100, 30), hSliderSevenValue, 1.0F, 6.0F);
            CheckSevenSlider();

            MoveDescription += "Moving Peg " + FirstPeg.Location + " " + FirstPeg.Distance + " Forward " + (int)hSliderSevenValue + "\n";
            MoveToDistanceFirst = (int)hSliderSevenValue;
            MoveToLocationFirst = LOCATION.MAINTRACK;
            MoveDescription += "Moving Peg " + SecondPeg.Location + " " + SecondPeg.Distance + " Forward " + (7 - (int)hSliderSevenValue) + "\n";
            MoveToDistanceSecond = 7 - (int)hSliderSevenValue;
            MoveToLocationFirst = LOCATION.MAINTRACK;
            break;
        case RANK.Eight:
            MoveDescription = "Player: " + TurnCounter + " played an Eight on Peg: " + FirstPeg.Location + " " + FirstPeg.Distance + "\n";
            if(FirstPeg.Location == LOCATION.MAINTRACK){
                //2 spaces Forward
                MoveToLocationFirst = LOCATION.MAINTRACK;
                MoveToDistanceFirst = -8;
                MoveDescription += "moving to " + MoveToLocationFirst + " " + MoveToDistanceFirst;
            }
            break;
        case RANK.Nine://needs logic for only one playable peg
            MoveDescription = "Player: " + TurnCounter + " played a Nine on Pegs: " + FirstPeg.Location + " " + FirstPeg.Distance + "and " + SecondPeg + " " + SecondPeg.Distance + "\n";

            //16 options: 1/-8 2/-7 3/-6 4/-5 5/-4 6/-3 7/-2 8/-1 -1/8 -2/7 -3/6 -4/5 -5/4 -6/3 -7/2 -8/1
            hSliderNineValue = GUI.HorizontalSlider(new Rect(25, (CARDHEIGHT + CARDBUFFER) * 2, 100, 30), hSliderNineValue, 1.0F, 8.0F);
            CheckNineSlider();

            //needs logic to check if the the peg moving backwards is not in the Castle
            NineToggle = GUI.Toggle(new Rect (25, (CARDHEIGHT + CARDBUFFER) * 2 + 30, 100, 30), NineToggle, (NineToggle?"Forward/Backward":"Backward/Forward"));

            MoveDescription += "Moving Peg " + FirstPeg.Location + " " + FirstPeg.Distance + (NineToggle? " Forward ": " Backwards ") + hSliderNineValue + "\n";
            MoveToDistanceFirst = (NineToggle? (int)hSliderNineValue : -(int)hSliderNineValue );
            MoveToLocationFirst = LOCATION.MAINTRACK;
            MoveDescription += "Moving Peg " + SecondPeg.Location + " " + SecondPeg.Distance + (NineToggle? " Backwards ": " Forward ") + (9 - hSliderNineValue) + "\n";
            MoveToDistanceSecond = (NineToggle? -(9 - (int)hSliderNineValue): (9 - (int)hSliderNineValue) );
            MoveToLocationSecond = LOCATION.MAINTRACK;

            break;
        case RANK.Ten://needs logic for only one playable peg
            MoveDescription = "Player: " + TurnCounter + " played a Ten on Pegs: " + FirstPeg.Location + " " + FirstPeg.Distance + "and " + SecondPeg + " " + SecondPeg.Distance + "\n";

            //9 options: 1/9 2/8 3/7 4/6 5/5 6/4 7/3 8/2 9/1
            //+/+ +/- -/+ -/-
            hSliderTenValue = GUI.HorizontalSlider(new Rect(25, (CARDHEIGHT + CARDBUFFER) * 2, 100, 30), hSliderTenValue, 1.0F, 9.0F);
            CheckTenSlider();

            TenFirstToggle = GUI.Toggle(new Rect (25, (CARDHEIGHT + CARDBUFFER) * 2 + 30, 100, 30), TenFirstToggle, (TenFirstToggle?"Forward":"Backward"));
            TenSecondToggle = GUI.Toggle(new Rect (25, (CARDHEIGHT + CARDBUFFER) * 2 + 60, 100, 30), TenSecondToggle, (TenSecondToggle?"Forward":"Backward"));

            MoveDescription += "Moving Peg " + FirstPeg.Location + " " + FirstPeg.Distance + (TenFirstToggle? " Forward " : " Backwards ") + hSliderTenValue + "\n";
            MoveToDistanceFirst = (TenFirstToggle? (int)hSliderTenValue : -(int)hSliderTenValue);
            MoveToLocationFirst = LOCATION.MAINTRACK;
            MoveDescription += "Moving Peg " + SecondPeg.Location + " " + SecondPeg.Distance + (TenSecondToggle? " Forward " : " Backwards ") + (10 - hSliderTenValue) + "\n";
            MoveToDistanceSecond = (TenSecondToggle? (10 - (int)hSliderTenValue) : -(10 - (int)hSliderTenValue));
            MoveToLocationSecond = LOCATION.MAINTRACK;

            break;
        case RANK.Jack:
        case RANK.Queen:
        case RANK.King:
            MoveDescription = "Player: " + TurnCounter + " played a " + LastPlayed.Rank + " on Peg: " + FirstPeg.Location + " " + FirstPeg.Distance + "\n";
            if(FirstPeg.Location == LOCATION.HOME){
                MoveToLocationFirst = LOCATION.MAINTRACK;
                MoveToDistanceFirst = TableBoard.GetPlayerHomeExit(TurnCounter);
                MoveDescription += "moving to " + MoveToLocationFirst + " " + MoveToDistanceFirst;
            }
            if(FirstPeg.Location == LOCATION.MAINTRACK){
                //2 spaces Forward
                MoveToLocationFirst = LOCATION.MAINTRACK;
                MoveToDistanceFirst = 10;
                MoveDescription += "moving to " + MoveToLocationFirst + " " + MoveToDistanceFirst;
                if( FirstPeg.Distance < TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && MoveToDistanceFirst > TableBoard.GetPlayerCastleEntrance(TurnCounter)
                    && (MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter)) < 5){
                    //give the option to move into the castle
                    MoveToLocationFirst = LOCATION.CASTLE;
                    MoveToDistanceFirst = MoveToDistanceFirst - TableBoard.GetPlayerCastleEntrance(TurnCounter);
                }
            }
            break;
        case RANK.Small:
        case RANK.Big:
            MoveDescription = "Player: " + TurnCounter + " played a Joker on Peg: " + FirstPeg.Location + " " + FirstPeg.Distance + "\n";

            hSliderJokerValue = GUI.HorizontalSlider(new Rect(25, (CARDHEIGHT + CARDBUFFER) * 2, 100, 30), hSliderJokerValue, 0, TableBoard.Length);
            CheckJokerSlider();

            MoveToLocationFirst = LOCATION.MAINTRACK;
            MoveToDistanceFirst = Mathf.FloorToInt(hSliderJokerValue);
            MoveDescription += "moving to " + MoveToLocationFirst + " " + MoveToDistanceFirst;
            break;
        }
        GUI.Label(new Rect(0,CARDHEIGHT + CARDBUFFER, Camera.main.pixelWidth, CARDHEIGHT * 2),MoveDescription);
    }
コード例 #36
0
        public static void InsertGoogleStore(string storejson)
        {
            Store s = myConvert.Deserialize<Store>(storejson);
            try
            {
                if (s == null)
                { return; }
                Random r = new Random();
                int i = r.Next(0, 6);
                //string[] users = new string[6] { "gdabli", "harshisame", "nari.dontula", "rungta.sachin", "SiChen", "YongZhuang" };
                string[] users = new string[6] { "Gaurav_Dabli", "Harshita_Gupta", "Harshita_Gupta", "Nari_Dontula", "Nari_Dontula", "Yong_Zhuang" };
                if (mydb.STOREs.SingleOrDefault(ss => ss.PLACE_ID == s.place_id) != null)
                {
                    return;
                }
                //{ "geometry": { "location": { "k": 42.360128, "B": -71.055454 } }, "name": "Cheers", "types": ["cafe", "bar", "restaurant", "food", "establishment"], "vicinity": "1 S Market St, Boston", "html_attributions": [] }
                STORE store = new STORE() { NAME = s.name, PLACE_ID = s.place_id, PRICE_LEVEL = s.price_level, RATING = s.rating, PHONE = s.formatted_phone_number, WEBSITE = s.website, OWNER = users[i], GOOGLE_URL = s.url };
                LOCATION location = new LOCATION() { LATITUDE = s.geometry.location.k, LONGITUDE = s.geometry.location.B };
                mydb.LOCATIONs.InsertOnSubmit(location);
                store.LOCATION = location;
                ADDRESS address = new ADDRESS() { ADDRESS_LINE1 = s.vicinity.Split(',')[0], CITY = s.vicinity.Split(',')[1] };
                if (s.address_components != null)
                {
                    foreach (Address_Components ad in s.address_components)
                    {
                        foreach (string type in ad.types)
                        {
                            switch (type)
                            {
                                case "country":
                                    {
                                        address.COUNTRY = ad.long_name;
                                        break;
                                    }
                                case "postal_code":
                                    {
                                        address.POSTAL_CODE = ad.long_name;
                                        break;
                                    }
                                case "administrative_area_level_1":
                                    {
                                        address.STATE_PROVINCE_REGION = ad.long_name;
                                        break;
                                    }
                            }
                        }
                    }
                }
                mydb.ADDRESSes.InsertOnSubmit(address);
                store.ADDRESS = address;
                if (s.opening_hours != null)
                {
                    foreach (Period period in s.opening_hours.periods)
                    {
                        PERIOD p = new PERIOD() { OPEN_DAY = period.open.day, CLOSE_DAY = period.close.day, OPEN_TIME = Convert.ToDateTime(period.open.hours + ":" + period.open.minutes).TimeOfDay, CLOSE_TIME = Convert.ToDateTime(period.close.hours + ":" + period.close.minutes).TimeOfDay };
                        store.PERIODs.Add(p);
                    }
                }
                if (s.reviews != null)
                {
                    foreach (Review review in s.reviews)
                    {
                        if (string.IsNullOrEmpty(review.author_name) || review.author_name == "A Google User")
                        {
                            continue;
                        }
                        USER user = mydb.USERs.SingleOrDefault(u => u.FIRST_NAME + " " + u.LAST_NAME == review.author_name);
                        if (user == null)
                        {
                            string[] name = review.author_name.Split(' ');
                            if (name.Length > 1)
                            {
                                user = new USER() { FIRST_NAME = name[0], LAST_NAME = name[1], USER_ID = name[0] + "_" + name[1], EMAIL = name[0] + "." + name[1] + "@gmail.com", PASSWORD = "******", ROLE = "0", REGISTER_DATE = DateTime.Now };
                            }
                            else if (name.Length > 0)
                            {
                                user = new USER() { FIRST_NAME = name[0], LAST_NAME = "", USER_ID = name[0], EMAIL = name[0] + "@gmail.com", PASSWORD = "******", ROLE = "0", REGISTER_DATE = DateTime.Now };
                            }
                            mydb.USERs.InsertOnSubmit(user);
                        }
                        if (user != null)
                        {
                            FEEDBACK feed = new FEEDBACK() { COMMENT = review.text, RATING = review.rating  };
                            feed.IS_LIKED = feed.RATING > 2.5 ? 1 : 0;
                            feed.USER = user;
                            feed.STORE = store;
                            mydb.FEEDBACKs.InsertOnSubmit(feed);
                        }
                    }
                }
                if (s.types != null)
                {
                    foreach (string type in s.types)
                    {
                        CATEGORY catergory = mydb.CATEGORies.SingleOrDefault(c => c.NAME == type);
                        if (catergory == null)
                        {
                            catergory = new CATEGORY() { NAME = type, LAYER = 1, PARENT = 0 };
                            mydb.CATEGORies.InsertOnSubmit(catergory);
                        }
                        STORE_CATEGORY s_c = new STORE_CATEGORY();
                        s_c.CATEGORY = catergory;
                        s_c.STORE = store;
                        mydb.STORE_CATEGORies.InsertOnSubmit(s_c);
                    }
                }
                mydb.SubmitChanges();

            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #37
0
ファイル: WMS.designer.cs プロジェクト: krevaz/C-Sharp
 partial void DeleteLOCATION(LOCATION instance);
コード例 #38
0
ファイル: WMS.designer.cs プロジェクト: krevaz/C-Sharp
 partial void UpdateLOCATION(LOCATION instance);
コード例 #39
0
ファイル: WMS.designer.cs プロジェクト: krevaz/C-Sharp
 partial void InsertLOCATION(LOCATION instance);
コード例 #40
0
ファイル: Table.cs プロジェクト: BenightedSyper/PEG-EMS
    public bool TestPegLand(Peg _peg, LOCATION _location, int _distance)
    {
        LOCATION beginningLocation = _peg.Location;
        int beginningDistance = _peg.Distance;

        //need to check moving distances for valid position
        if((_location == LOCATION.MAINTRACK && _distance > TableBoard.Length) || (_location == LOCATION.CASTLE && _distance > 4)){
            //this is outside the play area
            //should pop and error message
            Debug.Log("Move to: " + _location + " " + _distance + " is outside the play area, invalid move.");
            return false;
        }
        //need to check the landing location of any pegs that was landed on
        //check maintrack distance for any other peg
        for(int i = 0; i < Players.Count; i++){
            for(int j = 0; j < 5 /*the number of pegs a player has*/; j++){
                //test each peg to see if its in that spot.
                if(TableBoard.PlayersPegs[i,j].Location == _location && TableBoard.PlayersPegs[i,j].Distance == _distance){
                    if(_peg.Player == TableBoard.PlayersPegs[i,j].Player){
                        return false;
                    }else{//not same player's pegs
                        if(_peg.Team == TableBoard.PlayersPegs[i,j].Team){//same team
                            return TestPegLand(TableBoard.PlayersPegs[i,j], LOCATION.MAINTRACK, TableBoard.GetPlayerCastleEntrance(i));
                        }else{//not same team
                            //PegToPlayerHome(TableBoard.PlayersPegs[i,j]);
                            return true;
                        }
                    }
                }
            }
        }
        return true;
    }
コード例 #41
0
ファイル: Table.cs プロジェクト: BenightedSyper/PEG-EMS
    public bool TestPegMove(Peg _peg, LOCATION _location, int _distance)
    {
        LOCATION beginningLocation = _peg.Location;
        int beginningDistance = _peg.Distance;

        //need to check moving distances for valid position
        if((_location == LOCATION.MAINTRACK && _distance > TableBoard.Length) || (_location == LOCATION.CASTLE && _distance > 4)){
            //this is outside the play area
            //should pop and error message
            Debug.Log("Move to: " + _location + " " + _distance + " is outside the play area, invalid move.");
            return false;
        }
        //need to check that we are not moving over any of our own pegs.
        for(int i = 0; i < 5 /**/; i++){
            if(TableBoard.PlayersPegs[_peg.Player,i].Location == _location){

            }

        }
        return true;
    }

    private void DisplayPegs(List<Peg> _pegs)
    {
        foreach(Peg _peg in _pegs){
            //Peg GUI
            if(GUI.Button( new Rect((CARDBUFFER + CARDWIDTH) * _pegs.IndexOf(_peg), CARDHEIGHT + CARDBUFFER + CARDBUFFER, CARDWIDTH, CARDHEIGHT), _peg.Name())){
                //Select Peg
                if(LastPlayed.Rank == RANK.Ten || LastPlayed.Rank == RANK.Nine || LastPlayed.Rank == RANK.Seven){
                    SecondPeg = FirstPeg;
                }
                FirstPeg = _peg;
            }
        }
    }

    void OnGUI()
    {
        if(Players.Count > 0){
            if(Players[TurnCounter].Hand.Count > 0){
                foreach(Card _card in Players[TurnCounter].Hand){
                    if(GUI.Button(new Rect((CARDWIDTH + CARDBUFFER)* Players[TurnCounter].Hand.IndexOf(_card), CARDBUFFER,CARDWIDTH,CARDHEIGHT),_card.FaceValue())){
                        Players[TurnCounter].SelectedCard = Players[TurnCounter].Hand.IndexOf(_card);
                    }
                }
            }
            switch(PhaseCounter){
            case PHASE.DRAW:
                if(GUI.Button(new Rect((Camera.main.pixelWidth / 2) - CARDWIDTH / 2, Camera.main.pixelHeight / 2,CARDWIDTH,CARDHEIGHT),"Draw")){
                    DrawPhase(Players[TurnCounter]);
                }
                break;
            case PHASE.PLAY:
                if(GUI.Button(new Rect((Camera.main.pixelWidth / 2) - CARDWIDTH - (CARDBUFFER / 2), Camera.main.pixelHeight / 2,CARDWIDTH,CARDHEIGHT),"Play")){
                    PlayPhase(Players[TurnCounter]);
                }
                if(GUI.Button(new Rect((Camera.main.pixelWidth / 2) + (CARDBUFFER / 2), Camera.main.pixelHeight / 2,CARDWIDTH,CARDHEIGHT),"Discard")){
                    DiscardPhase(Players[TurnCounter]);
                }
                break;
            case PHASE.PEG:
                List<Peg> tempPegs = GetAvailablePegs(TurnCounter, LastPlayed);
                //display the available pegs
                DisplayPegs(tempPegs);
                //check the selected card for available pegs
                //Ace Maintrack Pegs of the player, Castle Pegs, and Home Pegs
                //2-9 Maintrack Pegs of the player, Castle Pegs (needs logic for 7's and 9's upon moving the last Peg into the castle)
                //10 All Main Track Pegs + logic for a selected Peg filtering out any Peg from that Player
                //Jack, Queen, KingMaintrack Pegs of the player and Home Pegs
                //Joker all Player's Pegs.
                /*
                GUI.Button(new Rect((CARDWIDTH + CARDBUFFER)* 0, (CARDBUFFER * 2) + CARDHEIGHT,CARDWIDTH,CARDHEIGHT),TableBoard.PlayersPegs[TurnCounter,0].Name());
                GUI.Button(new Rect((CARDWIDTH + CARDBUFFER)* 1, (CARDBUFFER * 2) + CARDHEIGHT,CARDWIDTH,CARDHEIGHT),TableBoard.PlayersPegs[TurnCounter,1].Name());
                GUI.Button(new Rect((CARDWIDTH + CARDBUFFER)* 2, (CARDBUFFER * 2) + CARDHEIGHT,CARDWIDTH,CARDHEIGHT),TableBoard.PlayersPegs[TurnCounter,2].Name());
                GUI.Button(new Rect((CARDWIDTH + CARDBUFFER)* 3, (CARDBUFFER * 2) + CARDHEIGHT,CARDWIDTH,CARDHEIGHT),TableBoard.PlayersPegs[TurnCounter,3].Name());
                GUI.Button(new Rect((CARDWIDTH + CARDBUFFER)* 4, (CARDBUFFER * 2) + CARDHEIGHT,CARDWIDTH,CARDHEIGHT),TableBoard.PlayersPegs[TurnCounter,4].Name());
                */
                if(GUI.Button(new Rect((Camera.main.pixelWidth / 2) + (CARDBUFFER / 2), Camera.main.pixelHeight / 2,CARDWIDTH,CARDHEIGHT),"Select Peg")){
                    if(LastPlayed .Rank == RANK.Seven || LastPlayed .Rank == RANK.Nine || LastPlayed .Rank == RANK.Ten){
                        if(FirstPeg != null && SecondPeg != null && FirstPeg != SecondPeg){
                            PegPhase(Players[TurnCounter]);
                        }else{
                            Debug.Log("You must select 2 different Pegs");
                        }
                    }else{
                        if(FirstPeg != null){
                            PegPhase(Players[TurnCounter]);
                        }
                    }
                }
                if(GUI.Button(new Rect(Camera.main.pixelWidth - (CARDWIDTH + CARDBUFFER), Camera.main.pixelHeight - (CARDHEIGHT + CARDBUFFER), CARDWIDTH, CARDHEIGHT), "Back")){
                    Back(Players[TurnCounter]);
                }
                break;
            case PHASE.MOVE:
                //display the move that will happen
                DisplayMove();
                if(GUI.Button(new Rect((Camera.main.pixelWidth / 2) - CARDWIDTH / 2, Camera.main.pixelHeight / 2,CARDWIDTH,CARDHEIGHT),"Move")){
                    MovePhase(Players[TurnCounter]);
                }
                if(GUI.Button(new Rect(Camera.main.pixelWidth - (CARDWIDTH + CARDBUFFER), Camera.main.pixelHeight - (CARDHEIGHT + CARDBUFFER), CARDWIDTH, CARDHEIGHT), "Back")){
                    Back(Players[TurnCounter]);
                }
                break;
            case PHASE.END:
                if(GUI.Button(new Rect((Camera.main.pixelWidth / 2) - CARDWIDTH / 2, Camera.main.pixelHeight / 2,CARDWIDTH,CARDHEIGHT),"End Turn")){
                    EndPhase(Players[TurnCounter]);
                }
                if(GUI.Button(new Rect(Camera.main.pixelWidth - (CARDWIDTH + CARDBUFFER), Camera.main.pixelHeight - (CARDHEIGHT + CARDBUFFER), CARDWIDTH, CARDHEIGHT), "Back")){
                    Back(Players[TurnCounter]);
                }
                break;
            }