public ShipStatus getStatus(Position position) { bool check = false; int offset = -1; ShipInterface shootedShip = null; foreach (KeyValuePair <Placement, ShipInterface> kvp in dict) { Position pos = kvp.Key.getPosition(); if (pos.getX() == position.getX() && pos.getY() == position.getY()) { IEnumerable <Placement> matches = dict.Where(pair => pair.Value == kvp.Value).Select(pair => pair.Key); foreach (Placement val in matches) { offset++; if (position.getX() == val.getPosition().getX() && position.getY() == val.getPosition().getY()) { break; } } shootedShip = kvp.Value; check = true; } } if (!check) { throw new InvalidPositionException("На этой клетке нет корабля"); } return(shootedShip.getStatus(offset)); }
public void SetNewShip(GameObject ship) { this.myShip = ship; myShip.tag = "PlayerShip"; this.currentShip = myShip.GetComponent(typeof(ShipInterface)) as ShipInterface; myShip.GetComponent <BaseShip> ().setSpeed(2); }
public void SetNewShip(GameObject ship) { this.myShip = ship; myShip.tag = "PlayerShip"; this.currentShip = myShip.GetComponent (typeof(ShipInterface)) as ShipInterface; myShip.GetComponent<BaseShip> ().setSpeed (2); }
public override void overrideUpdate() { tmpBar = this.Charge / 1f; if (tmpBar < 1f) { ChargeBar.transform.localScale = new Vector3((this.Charge / 1f), 1, 1); } if (this.Shooting) { this.Speed = 0f; this.Charge += Time.deltaTime; if (this.Charge >= 1) { this.createLaser(); this.Speed = 0; RaycastHit2D[] hit = Physics2D.RaycastAll(this.transform.position, this.transform.right, 200f); int size = hit.Length; for (int i = 0; i < size; i++) { if (this.tag == "PlayerShip") { if (hit[i].transform.tag == "Enemy") { ShipInterface enem = hit[i].transform.gameObject.GetComponent(typeof(ShipInterface)) as ShipInterface; enem.TakeDamage(this.Damage); } } else if (this.tag == "Enemy") { if (hit[i].transform.tag == "PlayerShip") { ShipInterface playa = hit[i].transform.gameObject.GetComponent(typeof(ShipInterface)) as ShipInterface; playa.TakeDamage(this.Damage); } } if (hit[i].transform.name == "boundwall4" || hit[i].transform.name == "boundwall2") { endpoint = (Vector2)hit[i].point; } } if (this.endpoint.x == 0f && this.endpoint.y == -10f) { this.endpoint = (Vector2)this.transform.position + new Vector2(this.transform.right.x * 100, 0); } LR.SetPosition(1, (Vector3)endpoint); } if (this.Charge >= 2) { LR.enabled = false; this.Charge = 0; this.Speed = .1f; this.Shooting = false; this.endpoint = new Vector2(0f, -10f); } } }
public Placement choosePlacement(ShipInterface ship, BoardInterface board) { ConsoleGraphics.showField(board, 70); bool isVertical = checkIsVertical(); Console.WriteLine("Введите кординату X(1 - 10):"); string answ = Console.ReadLine(); if (answ == "пауза") { throw new PauseException(); } int x = int.Parse(answ); Console.WriteLine("Введите кординату Y(1 - 10):"); answ = Console.ReadLine(); if (answ == "пауза") { throw new PauseException(); } int y = int.Parse(answ); Position position = null; BoardInterface boardToShow = board.Clone() as BoardInterface; try { position = new Position(x, y); boardToShow.placeShip(ship, position, isVertical); } catch { Console.WriteLine("данные введены неправильно, введите заново"); return(choosePlacement(ship, board)); } Console.Clear(); ConsoleGraphics.showField(boardToShow, 70); while (true) { Console.WriteLine("Вы уверены в своём выборе?"); answ = Console.ReadLine(); if (answ == "да") { return(new Placement(position, isVertical)); } else if (answ == "нет") { return(choosePlacement(ship, board)); } } }
public void SetShipInterface(ShipInterface sInterface) { connectedInterface = sInterface; if (connectedInterface != null) { controller.SetMobility(false); } else { controller.SetMobility(true); } }
public object Clone() { Board newBoard = new Board(); foreach (KeyValuePair <Placement, ShipInterface> kvp in dict) { Position position = kvp.Key.getPosition(); ShipInterface ship = kvp.Value; newBoard.dict.Add(new Placement(new Position(position.getX(), position.getY()), kvp.Key.isVerticalValue()), ship); } return(newBoard); }
public void OnTriggerEnter2D(Collider2D coll) { if (String.Equals(coll.gameObject.tag, this.Foe)) { ShipInterface enem = coll.gameObject.GetComponent(typeof(ShipInterface)) as ShipInterface; enem.TakeDamage(this.Damage); Destroy(this.gameObject); } else if (coll.gameObject.tag == "endwall") { Destroy(this.gameObject); } }
public override void OnTriggerEnter2D(Collider2D coll) { if (String.Equals(coll.gameObject.tag, "Enemy")) { ShipInterface enem = coll.gameObject.GetComponent(typeof(ShipInterface)) as ShipInterface; if (enem.getShields() > 0) { this.OnDeath(); } else { this.Infect(coll.gameObject, enem); } } }
void Update() { if (endPass == true) { this.GetComponent<MeshRenderer>().enabled = true; //playa.Eject(); playerShip = GameObject.FindGameObjectWithTag("PlayerShip"); si = playerShip.GetComponent (typeof(ShipInterface)) as ShipInterface; Destroy(playerShip.GetComponent<Rigidbody2D>()); playa.enabled = false; endPass = false; istime = true; } if (istime) si.Move(new Vector2(1, .5f)); }
public void OnTriggerEnter2D(Collider2D coll) { if (String.Equals(coll.gameObject.tag, "PlayerShip")) { ShipInterface player = coll.gameObject.GetComponent(typeof(ShipInterface)) as ShipInterface; player.TakeDamage(1); } else if (coll.gameObject.tag == "endwall" & passWall == true) { Destroy(this.gameObject); } else if (coll.gameObject.tag == "endwall") { this.passWall = true; } }
public Placement choosePlacement(ShipInterface ship, BoardInterface board) { Random rnd = new Random(); while (true) { try { Position position = new Position(rnd.Next(1, 10), rnd.Next(1, 10)); bool isVertical = rnd.Next(0, 1) == 1; BoardInterface tempBoard = board.Clone() as BoardInterface; tempBoard.placeShip(ship, position, isVertical); return(new Placement(position, isVertical)); } catch { } } }
void Update() { if (endPass == true) { this.GetComponent <MeshRenderer>().enabled = true; //playa.Eject(); playerShip = GameObject.FindGameObjectWithTag("PlayerShip"); si = playerShip.GetComponent(typeof(ShipInterface)) as ShipInterface; Destroy(playerShip.GetComponent <Rigidbody2D>()); playa.enabled = false; endPass = false; istime = true; } if (istime) { si.Move(new Vector2(1, .5f)); } }
public virtual void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "endwall") { Destroy(this.gameObject); } if (coll.tag == "Enemy" && this.tag == "PlayerShip") { ShipInterface si = coll.gameObject.GetComponent(typeof(ShipInterface)) as ShipInterface; si.TakeDamage(1); } else if (coll.tag == "PlayerShip" && this.tag == "Enemy") { ShipInterface si = coll.gameObject.GetComponent(typeof(ShipInterface)) as ShipInterface; si.TakeDamage(1); } overrideOnTriggerEnter2D(coll); }
void Infect(GameObject ship, ShipInterface enem) { //remove the AI controller on the ship Destroy (ship.GetComponent (typeof(AI))); //Flip the ship 180 ship.transform.rotation = this.transform.rotation; ship.GetComponent<BoxCollider2D> ().isTrigger = false; //Set the player to control this new ship now. GameObject player = GameObject.FindGameObjectWithTag ("Player"); player.GetComponent<PlayerScript>().SetNewShip(ship); BaseShip bs = ship.GetComponent ((typeof(BaseShip))) as BaseShip; bs.SetParasite (true); bs.AttatchParasite (); //Delete your current ship, the infection guy. //this.transform.SetParent(ship.transform); //this.transform.localPosition = (ship.GetComponent((typeof(BaseShip))) as BaseShip).getAttachPoint(); //this.tag = "Untagged"; //this.GetComponent<BoxCollider2D>().enabled = false; //this.enabled = false; Destroy (this.gameObject); }
protected void EditShippinClick(object sender, EventArgs e) { ShipInterface order = new ShipInterface(); order.Shipcompany = tbScompany.Text; order.Shipfirstname = tbSfirstname.Text; order.Shiplastname = tbSlastname.Text; order.Shipmiddlename = tbSmName.Text; order.Shipemail = tbSSEmail.Text; order.ShipAddress = tbSaddress1.Text; order.ShipCity = tbScity.Text; order.ShipProvince = tbSprovince.Text; order.ShipPostalcode = tbSPcode.Text; order.ShipCountry = tbScountry.Text; order.ShipPhone = tbSphone.Text; order.ShipMobilephone = tbSmpohone.Text; order.Shipfax = tbSfax.Text; Session["Shipping"] = order; lblshipInfo.Text = order.Shipemail + "<br/>Mr " + order.Shipfirstname + " " + order.Shiplastname + "<br/>" + order.ShipAddress + "<br/>" + order.ShipCity + ", " + order.ShipProvince + "<br/>" + order.ShipCountry + "<br/>" + order.ShipPostalcode + "<br/>" + order.ShipPhone; cancel(); }
void Infect(GameObject ship, ShipInterface enem) { //remove the AI controller on the ship Destroy(ship.GetComponent(typeof(AI))); //Flip the ship 180 ship.transform.rotation = this.transform.rotation; ship.GetComponent <BoxCollider2D> ().isTrigger = false; //Set the player to control this new ship now. GameObject player = GameObject.FindGameObjectWithTag("Player"); player.GetComponent <PlayerScript>().SetNewShip(ship); BaseShip bs = ship.GetComponent((typeof(BaseShip))) as BaseShip; bs.SetParasite(true); bs.AttatchParasite(); //Delete your current ship, the infection guy. //this.transform.SetParent(ship.transform); //this.transform.localPosition = (ship.GetComponent((typeof(BaseShip))) as BaseShip).getAttachPoint(); //this.tag = "Untagged"; //this.GetComponent<BoxCollider2D>().enabled = false; //this.enabled = false; Destroy(this.gameObject); }
public void placeShip(ShipInterface ship, Position position, bool isVertical) { foreach (KeyValuePair <Placement, ShipInterface> kvp in dict) { for (int i = 0; i < ship.getSize(); i++) { Position pos = null; if (isVertical) { pos = new Position(position.getX(), position.getY() + i); } else { pos = new Position(position.getX() + i, position.getY()); } if (pos.getY() == kvp.Key.getPosition().getY() && pos.getX() == kvp.Key.getPosition().getX()) { throw new ShipOverlapException("Место занято другим кораблём"); } } } for (int i = 0; i < ship.getSize(); i++) { if (isVertical) { dict.Add(new Placement(new Position(position.getX(), position.getY() + i), isVertical), ship); } else { dict.Add(new Placement(new Position(position.getX() + i, position.getY()), isVertical), ship); } } }
protected void ConfirmPurchase(object sender, EventArgs e) { //string ftotal = Session["FTotal"].ToString(); //lbloutput.Text = "Shopping done thanks Total " + ftotal.ToString(); // OrderInterface order = new OrderInterface(); var user = (alamaat_User)Session["alamaat_User"]; BillInterface bill = (BillInterface)Session["Billing"]; if (user == null) { //lbloutput.Text = "* User login or billing address required."; //e.Cancel = true; if (bill == null) { lbloutput.Text = "* User login or billing address required."; //e.Cancel = true; return; } //return; } if (bill == null) { lbloutput.Text = "* User login or billing address required."; //e.Cancel = true; return; } ShipInterface ship = (ShipInterface)Session["Shipping"]; // if (ship == null) // { // lbloutput.Text = "* User login or billing address required."; //e.Cancel = true; // return; // } decimal subtotal = (decimal)Session["subtotal"]; int shipping = (int)Session["shipTotal"]; decimal total = (decimal)Session["total"]; string shipType = (string)Session["shipType"]; Orders ordercontent = new Orders(); OrderInterface neworder = new OrderInterface(); neworder.SubTotal = Convert.ToDecimal(subtotal); neworder.Total = Convert.ToDecimal(total); DateTime datetime = DateTime.Now; neworder.OrderNumber = "A" + datetime.Year.ToString() + datetime.Month.ToString() + datetime.Day.ToString() + datetime.Hour.ToString() + datetime.Minute.ToString() + datetime.Second.ToString(); neworder.Shipment = shipType; neworder.Shippingtotal = Convert.ToDecimal(shipping); neworder.Billcompany = bill.Billcompany; neworder.Billfirstname = bill.Billfirstname; neworder.Billlastname = bill.Billlastname; neworder.Billmiddlename = bill.Billmiddlename; neworder.Billemail = bill.Billemail; neworder.BillCountry = bill.BillCountry; neworder.BillAddress = bill.BillAddress; neworder.BillCity = bill.BillCity; neworder.BillPostalcode = bill.BillPostalcode; neworder.BillProvince = bill.BillProvince; neworder.BillPhone = bill.BillPhone; neworder.BillMobilephone = bill.BillMobilephone; neworder.Billfax = bill.Billfax; neworder.Shipcompany = ship.Shipcompany; neworder.Shipfirstname = ship.Shipfirstname; neworder.Shiplastname = ship.Shiplastname; neworder.Shipmiddlename = ship.Shiplastname; neworder.ShipAddress = ship.ShipAddress; neworder.ShipCity = ship.ShipCity; neworder.ShipPostalcode = ship.ShipPostalcode; neworder.ShipProvince = ship.ShipProvince; neworder.ShipCountry = ship.ShipCountry; neworder.ShipPhone = ship.ShipPhone; neworder.ShipMobilephone = ship.ShipMobilephone; neworder.Shipfax = ship.Shipfax; List <OrderItems> orderitemList = new List <OrderItems>(); foreach (var item in ShoppingCart.Instance.Items) { OrderItems newitem = new OrderItems(); newitem.ID = Guid.NewGuid(); newitem.Name = item.Description; newitem.Status = "Pending"; newitem.Price = item.UnitPrice; newitem.Quantity = item.Quantity; newitem.Discount = 0; newitem.Total = item.TotalPrice; newitem.Productid = item.ProductId; orderitemList.Add(newitem); } if (ordercontent.InsertOrder(neworder, orderitemList)) { lblorderemail.Text = "Info: Message sent to " + neworder.Billfirstname + " " + neworder.Billlastname + " " + neworder.Billemail; lblordershiptype.Text = neworder.Shipment; lblordernumber.Text = neworder.OrderNumber; lblorderamount.Text = neworder.Total.ToString(); //Session["Billing"] = null; // Session["Shippig"] = null; Session["shipTotal"] = null; Session["shipType"] = null; foreach (var item in orderitemList) { ShoppingCart.Instance.RemoveItem(item.Productid); } gvShoppingCart.DataSource = null; gvShoppingCart.DataBind(); gvShoppingCart2.DataSource = null; gvShoppingCart2.DataBind(); clear(); // ShoppingCart.Instance.Items = null; ShippingWizard.Visible = false; ConfOrder.Visible = true; string Items = string.Empty; foreach (var item in orderitemList) { Items += "<tr><td>" + item.Name + "</td><td>" + item.Quantity + "</td><td>" + item.Price + "</td><td>" + item.Total + "</td></tr>"; } string emailcontent = "<div style='background:#e6e6e6;padding-top:10px;padding-left:10px;padding-bottom:10px'>Hello " + neworder.Billfirstname + " " + neworder.Billlastname + ",<br/><br/>" + "<b>Order Number:</b> " + neworder.OrderNumber + "<br/>" + "<b>Order Total: Rs.</b> " + neworder.Total + "<br/>" + "<b>Order Status:</b> Pending<br/><br/>" + "<table><tr><td style='Width:300px;text-align:center'><b>Bill To</b></td><td style='Width:300px;text-align:center'><b>Ship To</b></td></tr>" + "<tr><td>" + neworder.Billemail + "<br/>" + neworder.Billfirstname + " " + neworder.Billlastname + "<br/>" + neworder.BillAddress + "<br/>" + neworder.BillCity + ", " + neworder.BillProvince + "<br/>" + neworder.BillCountry + "<br/>" + neworder.BillPostalcode + "<br/>" + neworder.BillPhone + "</td>" + "<td>" + neworder.Shipfirstname + " " + neworder.Shiplastname + "<br/>" + neworder.ShipAddress + "<br/>" + neworder.ShipCity + ", " + neworder.ShipProvince + "<br/>" + neworder.ShipCountry + "<br/>" + neworder.ShipPostalcode + "<br/>" + neworder.ShipPhone + "</td></tr></table><br/>" + "<table><tr style='width:100%'><td style='width:250px'><b>Product Name<b/></td><td style='width:150px'><b>Quantity</b></td>" + "<td style='width:150px'><b>Unit Price</b></td><td ><b>Total</b></td></tr>" + "<tr><td colspan='4'> </td></tr>" + Items + "<tr><td colspan='4'> </td></tr>" + "<tr><td style='width:250px'></td><td style='width:150px'></td><td style='width:150px'><b>Sub Total:</b> <td><td>" + neworder.SubTotal + "</td></tr>" + "<tr><td style='width:250px'></td><td style='width:150px'></td><td style='width:150px'><b>Shipping: </b><td><td>" + neworder.Shippingtotal + "</td></tr>" + "<tr><td style='width:250px'></td><td></td><td style='width:150px'><b>Total:</b> <td><td>" + neworder.Total + "</td></tr></table><br/>" + "Thank you for purchasing at Alamaat." + "<br/><b>Alamaat</b></div>"; //MailMessage mail = new MailMessage(); //mail.From = new MailAddress("*****@*****.**", "Administrator"); //mail.To.Add(new MailAddress("*****@*****.**")); //mail.Bcc.Add(new MailAddress("*****@*****.**")); //set the content string subject = "Alamaat Order " + neworder.OrderNumber + "total Rs. " + neworder.Total; // AlternateView view = AlternateView.CreateAlternateViewFromString(emailcontent, null, "text/html"); // mail.AlternateViews.Add(view); //send the message //SmtpClient smtp = new SmtpClient("relay-hosting.secureserver.net"); //specify the mail server address //SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587); //smtp.Send(mail); SendEmail("*****@*****.**", subject, emailcontent); //MailMessage message = new MailMessage(); //message.Subject = subject; //message.Body = emailcontent; //message.To.Add("*****@*****.**"); //message.From = new MailAddress("*****@*****.**"); //message.IsBodyHtml = true; //var smtp = new System.Net.Mail.SmtpClient(); //{ // smtp.Host = "smtp.gmail.com"; // smtp.Port = 587; // smtp.EnableSsl = true; // smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; // smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "nazarh504"); // smtp.Timeout = 20000; //} //// Passing values to smtp object //smtp.Send(message); } }
protected void loginClick(object sender, EventArgs e) { lbllogin.Text = ""; UserContent Ucontent = new UserContent(); var user = Ucontent.GetbyUsername(tbloginname.Text); if (user != null) { if (user.password == tbloginpassword.Text) { if (user.active == true) { lblusername.Text = "Welcome " + user.username; tblogin.Visible = false; Panellogin.Visible = true; tbloginname.Text = ""; Session["alamaat_User"] = user; //billing interface BillInterface bill = new BillInterface(); bill.Billemail = user.email; bill.Billfirstname = user.firstname; bill.Billlastname = user.lastname; bill.Billcompany = user.companyname; bill.BillAddress = user.address; bill.BillCity = user.city; bill.BillPostalcode = user.postalcode; bill.BillProvince = user.province; bill.BillCountry = user.country; bill.BillPhone = user.phone; bill.BillMobilephone = user.mobilephone; bill.Billfax = user.fax; Session["Billing"] = bill; //Shipping interface ShipInterface ship = new ShipInterface(); ship.Shipemail = user.email; ship.Shipfirstname = user.firstname; ship.Shiplastname = user.lastname; ship.ShipAddress = user.address; ship.ShipCity = user.city; ship.ShipPostalcode = user.postalcode; ship.ShipProvince = user.province; ship.ShipCountry = user.country; ship.ShipPhone = user.phone; ship.ShipMobilephone = user.mobilephone; ship.Shipfax = user.fax; Session["Shipping"] = ship; loginInfor.Text = user.email + "<br/>Mr " + user.firstname + " " + user.lastname + "<br/>" + user.address + "<br/>" + user.city + ", " + user.province + "<br/>" + user.country + "<br/>" + user.postalcode + "<br/>" + user.phone; //lblshipaddress.Text = user.email + "<br/>Mr " + user.firstname + " " + user.lastname + "<br/>" + user.city + "<br/>" + user.postalcode + ", " + user.province + "<br/>" + user.country + "<br/>" + user.phone; } else { lbllogin.Text = "User account is invalid."; return; } } else { lbllogin.Text = "Username or password is incorrect."; return; } } else { lbllogin.Text = "Username or password is incorrect."; return; } }
public void Start() { currentShip = this.GetComponent(typeof(ShipInterface)) as ShipInterface; registerSelf (); overrideStart (); }
public void Start() { currentShip = this.GetComponent(typeof(ShipInterface)) as ShipInterface; registerSelf(); overrideStart(); }
// Use this for initialization void Start() { myShip.tag = "PlayerShip"; GameObject.Find ("GameManager").GetComponent<PauseManager> ().registerObject (this.gameObject); currentShip = myShip.GetComponent (typeof(ShipInterface)) as ShipInterface; }
// Use this for initialization void Start() { myShip.tag = "PlayerShip"; GameObject.Find("GameManager").GetComponent <PauseManager> ().registerObject(this.gameObject); currentShip = myShip.GetComponent(typeof(ShipInterface)) as ShipInterface; }