private void broadcastTextBox_TextChanged(object sender, EventArgs e) { if (Buoy.CheckMessage(broadcastTextBox.Text)) { mBuoy.Message = broadcastTextBox.Text; } }
private void CleanScreen() { TrackModel = null; RmoveTrack(); var gpsinfo = new GpsInfo() { UTCTime = DateTime.UtcNow, Latitude = 29.592966F, Longitude = 118.983188F, }; var by = new Buoy() { Id = 1, gps = gpsinfo, IP = "192.168.2.101", }; Buoy1 = by; by.Id = 2; Buoy2 = by; by.Id = 3; Buoy3 = by; by.Id = 4; Buoy4 = by; //UnitCore.Instance.TargetObj.Latitude = 29.592966F; //UnitCore.Instance.TargetObj.Longitude = 118.983188F; //UnitCore.Instance.TargetObj.Status = "未定位"; RefreshBuoy(0, Buoy1); RefreshBuoy(1, Buoy2); RefreshBuoy(2, Buoy3); RefreshBuoy(3, Buoy4); RefreshBuoyInfo(BuoyInfoVisible); }
public static async void InitializeBuoysAsync(IServiceProvider serviceProvider) { // get db context using (var context = new ApplicationDbContext(serviceProvider.GetRequiredService <DbContextOptions <ApplicationDbContext> >())) { // check if db has buoys or not if (context.Buoy.Any()) { return; // db has been seeded } // get xml doc of buoys from NOAA XmlDocument buoyXml = await GetBuoyListXml.FetchAsync(); // get xml node list of buoys from xml doc XmlNodeList buoyList = buoyXml.GetElementsByTagName("station"); // itterate through nodes foreach (XmlNode buoy in buoyList) { // populate a buoy model and add it to the databse string buoyId = buoy.Attributes["id"].Value; string lat = buoy.Attributes["lat"].Value; string lon = buoy.Attributes["lon"].Value; string name = buoy.Attributes["name"].Value; string owner = buoy.Attributes["owner"].Value; Buoy newBuoy = new Buoy(buoyId, lat, lon, name, owner); context.Buoy.Add(newBuoy); } // save changes to db context.SaveChanges(); } }
public static async Task <CurrentReport> GetAsync(Buoy buoy) { CurrentReport currentReport = new CurrentReport(buoy.Name, buoy.NbdcId); SpecData specData = new SpecData(); string buoyStandardId = (buoy.NbdcId).ToUpper() + ".txt"; string buoySpecId = (buoy.NbdcId).ToUpper() + ".spec"; string standardReportText = await GetBuoyData.FetchAsync(buoyStandardId); string spectralReportText = await GetBuoyData.FetchAsync(buoySpecId); string firstCharSpec = (spectralReportText[0]).ToString(); string firstCharStandard = (standardReportText[0].ToString()); StandardData standardReport = ParseCurrentStandard.Get(standardReportText, buoy.NbdcId); if (firstCharSpec != "<" && firstCharStandard != "<") { specData = ParseCurrentSpec.Get(spectralReportText, buoy.NbdcId); currentReport = new CurrentReport(buoy.Name, buoy.NbdcId, standardReport, specData); } else if (firstCharStandard != "<") { currentReport = new CurrentReport(buoy.Name, buoy.NbdcId, standardReport); } return(currentReport); }
public static void RemoveVirtualBuoy(RealPoint center) { Buoy b = _elements.FindBuoy(center); if (b.IsVirtual) { _elements.RemoveBuoy(b); } }
/** Loads from the text file into a list of buoys * @param The filename of the input file, preferably a text file */ public void load(string file) { string[] lines = File.ReadAllLines(file); for (int i = 2; i < lines.Length; i++) //i starts at two to skip the first two header lines of the file. { Buoy temp = new Buoy(); temp.input(lines[i]); blist.Add(temp); } }
public async Task <IActionResult> GetCurrentBuoyData(string nbdcId) { // retreive buoy information from database Buoy buoy = _context.Buoy.Single(b => b.NbdcId == nbdcId); // use buoy data to retreive current report data CurrentReport currentReport = await MakeCurrentReport.GetAsync(buoy); // return current report return(Ok(currentReport)); }
/// <summary> /// Creates a new dataset /// </summary> /// <param name="buoy">The buoy that the dataset came from</param> /// <param name="startTimeStamp">The start time of the dataset</param> /// <param name="endTimeStamp">The end time of the dataset</param> public Dataset(Buoy buoy, DateTime startTimeStamp, DateTime endTimeStamp) { if(buoy == null) throw new ArgumentException("Please provide a buoy this dataset came from"); if(DateTime.Compare(startTimeStamp,endTimeStamp)>=0) throw new ArgumentException("End time stamp must be after start"); _buoy = buoy; _startTimeStamp = startTimeStamp; _endTimeStamp = endTimeStamp; _sensors = new List<Sensor>(); }
public async Task <IActionResult> Get45DayBuoyData(string nbdcId) { // find requested buoy Buoy buoy = _context.Buoy.Single(b => b.NbdcId == nbdcId); // get report data for buoy FullReport fullReport = await Make45DayReport.GetAsync(buoy); // return report data return(Ok(fullReport)); }
public MainWindow() { InitializeComponent(); // Create a material theme manager and add the form to manage (this) MaterialSkinManager materialSkinManager = MaterialSkinManager.Instance; materialSkinManager.AddFormToManage(this); materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT; // Configure color schema materialSkinManager.ColorScheme = new ColorScheme( Primary.Blue400, Primary.LightBlue900, Primary.Blue500, Accent.Cyan700, TextShade.WHITE ); /***** Trigger updateButton_click Event *****/ string pathToSolution = @"C:\Users\User\Code\LabRatsProject\VisualStudio\NOAA_Monitor\VSProjectFiles"; // Run python webscraping script run_cmd(pathToSolution + @"\scrape_NOAA_buoy.py"); // Add timestamp to buoy data file name string updatedDataFile = timestampFile(pathToSolution + @"\bin\Debug\tmp.txt"); // Read in new Buoy data Stations = readBuoyData(updatedDataFile); // Re-populate buoy data string stationNames = "PSBM1 CFWM1 44027 ATGM1 44034" + "MDRM1 44037 44033 MISM1 44032" + "44005 CASM1 44007 44030 WEQM1 WEXM1 WELM1"; List <Buoy> .Enumerator stationIter = Stations.blist.GetEnumerator(); Buoy tmpStation = new Buoy(); ColumnHeader columnHeader1 = new ColumnHeader(); columnHeader1.Text = "Station List"; this.stationList.Columns.AddRange(new ColumnHeader[] { columnHeader1 }); while (stationIter.MoveNext()) { tmpStation = stationIter.Current; if (stationNames.Contains(tmpStation.getbname()) && !String.IsNullOrEmpty(tmpStation.getbname())) { ListViewItem stationNameItems = new ListViewItem(tmpStation.getbname()); stationList.Items.Add(stationNameItems); } } stationList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); }
/// <summary> /// Creates a new dataset /// </summary> /// <param name="buoy">The buoy that the dataset came from</param> /// <param name="startTimeStamp">The start time of the dataset</param> /// <param name="endTimeStamp">The end time of the dataset</param> public Dataset(Buoy buoy, DateTime startTimeStamp, DateTime endTimeStamp) { if (buoy == null) { throw new ArgumentException("Please provide a buoy this dataset came from"); } if (DateTime.Compare(startTimeStamp, endTimeStamp) >= 0) { throw new ArgumentException("End time stamp must be after start"); } _buoy = buoy; _startTimeStamp = startTimeStamp; _endTimeStamp = endTimeStamp; _sensors = new List <Sensor>(); }
public void SetBuoy(Buoy buoy) { BuoyID.Text = buoy.Name; Lat.Text = buoy.gps.Latitude.ToString("F6"); Long.Text = buoy.gps.Longitude.ToString("F6"); TimeGps.Text = buoy.gps.UTCTime.ToLocalTime().ToShortTimeString(); RangeLabel2.Visibility = Visibility.Visible; Range2.Visibility = Visibility.Visible; RangeLabel2.Visibility = Visibility.Visible; Range2.Visibility = Visibility.Visible; RangeLabel1.Content = "测距1"; Range1.Text = buoy.Range1.ToString("F6"); RangeLabel1.Content = "测距2"; Range2.Text = buoy.Range2.ToString("F6"); }
private void RefreshBuoy(int index, Buoy buoy) { //update auv info ObjTarget1.Head = buoy.teleRange1.Head; ObjTarget1.Pitch = buoy.teleRange1.Pitch; ObjTarget1.Roll = buoy.teleRange1.Roll; ObjTarget2.Head = buoy.teleRange2.Head; ObjTarget2.Pitch = buoy.teleRange2.Pitch; ObjTarget2.Roll = buoy.teleRange2.Roll; Head1 = ObjTarget1.Head; Pitch1 = ObjTarget1.Pitch; Roll1 = ObjTarget1.Roll; Head2 = ObjTarget2.Head; Pitch2 = ObjTarget2.Pitch; Roll2 = ObjTarget2.Roll; switch (index) { case 0: Buoy1 = null; Buoy1 = buoy; break; case 1: Buoy2 = null; Buoy2 = buoy; break; case 2: Buoy3 = null; Buoy3 = buoy; break; case 3: Buoy4 = null; Buoy4 = buoy; break; default: break; } Refresh3DView(); RefreshBuoyInfo(BuoyInfoVisible); }
bool needAni = false;// set back to false after animation done!! public BuoyMarker(HomePageView window, GMapMarker marker, Buoy buoy) { this.InitializeComponent(); this.MainWindow = window; this.Marker = marker; RenderTransform = scale; this.Loaded += new RoutedEventHandler(BuoyMarker_Loaded); this.SizeChanged += new SizeChangedEventHandler(BuoyMarker_SizeChanged); this.MouseEnter += new MouseEventHandler(MarkerControl_MouseEnter); this.MouseLeave += new MouseEventHandler(MarkerControl_MouseLeave); //this.MouseMove += new MouseEventHandler(BuoyMarker_MouseMove); this.MouseLeftButtonUp += new MouseButtonEventHandler(BuoyMarker_MouseLeftButtonUp); this.MouseLeftButtonDown += new MouseButtonEventHandler(BuoyMarker_MouseLeftButtonDown); _popup = false; _buoy = buoy; Text = " "; }
public static async Task <FullReport> GetAsync(Buoy buoy) { // create instance of report object, adding buoy name and id FullReport fullReport = new FullReport(buoy.Name, buoy.NbdcId); // create a list to hold the spectral report data List <SpecData> spectralReports = new List <SpecData>(); // create strings that will be used to complete get request urls. string buoyStandardId = (buoy.NbdcId).ToUpper() + ".txt"; string buoySpecId = (buoy.NbdcId).ToUpper() + ".spec"; // make async calls to retreive buoy data in string format string standardReportText = await GetBuoyData.FetchAsync(buoyStandardId); string spectralReportText = await GetBuoyData.FetchAsync(buoySpecId); // get first character from report strings to use as check for succesful request string firstCharSpec = (spectralReportText[0]).ToString(); string firstCharStandard = (standardReportText[0].ToString()); // parse standard reports and store them in list List <StandardData> standardReports = Parse45DayStandard.Get(standardReportText, buoy.NbdcId); // if the first character of the string is an '<' that means the http // response resulted in an xml response stating no data found for url given // if neither request had xml... if (firstCharSpec != "<" && firstCharStandard != "<") { // parse spectral data make new object with entire report spectralReports = Parse45DaySpec.Get(spectralReportText, buoy.NbdcId); fullReport = new FullReport(buoy.Name, buoy.NbdcId, standardReports, spectralReports); } // else, if the standard report contained no xml else if (firstCharStandard != "<") { // store parsed standard data in object with buoy name and id fullReport = new FullReport(buoy.Name, buoy.NbdcId, standardReports); } // return 45 day report return(fullReport); }
private void stationList_SelectedIndexChanged(object sender, EventArgs e) { string selectedStationName = "XXXXX"; ListView.SelectedListViewItemCollection selectedStations = stationList.SelectedItems; if (selectedStations.Count > 0) { selectedStationName = selectedStations[0].Text; } /***** Display buoy data according to station name *****/ // Get selected station name for (int i = 0; i < Stations.blist.Count; ++i) { if (Stations.blist[i].getbname() == selectedStationName) { // Get Buoy from BuoyList Buoy tmp = new Buoy(); tmp = Stations.blist[i]; // Write Buoy data to labels label1.Text = "Name: " + tmp.getbname(); label2.Text = "Lat/Lon:" + tmp.getlatlon(); label3.Text = "Wind Speed:" + tmp.getwindspeed(); label4.Text = "Gust:" + tmp.getgustspeed(); label5.Text = "Wave Height:" + tmp.getwaveheight(); label6.Text = "Wave Direction:" + tmp.getwavedir(); label7.Text = "Wave Period:" + tmp.getdomwave(); label8.Text = "Mean Tide Level:" + tmp.gettide(); label9.Text = "Sea level Pressure:" + tmp.getseapress(); label10.Text = "Pressure Change:" + tmp.getpressten(); label11.Text = "Sea Temp.:" + tmp.getseatemp(); label12.Text = "Air Temp.:" + tmp.getairtemp(); label13.Text = "Dew Point:" + tmp.getdewtemp(); label14.Text = "Visibility:" + tmp.getvis(); } } changeStationPicture(selectedStationName); }
public MovementBuoy(Buoy buoy) { _buoy = buoy; _elevator = Actionneur.FindElevator(_buoy.Color); double delta = _elevator == Actionneur.ElevatorLeft ? 30 : -30; //for (int i = 0; i < 360; i += 60) //{ // Positions.Add(new Geometry.Position(i + delta + 180, new Geometry.Shapes.RealPoint(_buoy.Position.X + 200* new AnglePosition(delta + i).Cos, _buoy.Position.Y + 200 * new AnglePosition(delta + i).Sin))); //} for (int i = 0; i < 360; i += 60) { Positions.Add(new Geometry.Position(i + 180 + delta, new Geometry.Shapes.RealPoint(_buoy.Position.X + 250 * new AnglePosition(i).Cos, _buoy.Position.Y + 250 * new AnglePosition(i).Sin))); } //AnglePosition a = 0; //Positions.Add(new Geometry.Position(a + 180 + delta, new Geometry.Shapes.RealPoint(_buoy.Position.X + 250 * new AnglePosition(a).Cos, _buoy.Position.Y + 250 * new AnglePosition(a).Sin))); //a = 180; //Positions.Add(new Geometry.Position(a + 180 + delta, new Geometry.Shapes.RealPoint(_buoy.Position.X + 250 * new AnglePosition(a).Cos, _buoy.Position.Y + 250 * new AnglePosition(a).Sin))); }
private void updateButton_Click(object sender, EventArgs e) { string pathToSolution = @"C:\Users\User\Code\LabRatsProject\VisualStudio\NOAA_Monitor\VSProjectFiles"; // Run python webscraping script run_cmd(pathToSolution + @"\scrape_NOAA_buoy.py"); // Add timestamp to buoy data file name string updatedDataFile = timestampFile(pathToSolution + @"\bin\Debug\tmp.txt"); // Read in new Buoy data Stations = readBuoyData(updatedDataFile); // Re-populate buoy data string stationNames = "PSBM1 CFWM1 44027 ATGM1 44034 " + "MDRM1 44037 44033 MISM1 44032 " + "44005 CASM1 44007 44030 WEQM1 WEXM1 WELM1"; List <Buoy> .Enumerator stationIter = Stations.blist.GetEnumerator(); Buoy tmpStation = new Buoy(); ColumnHeader columnHeader1 = new ColumnHeader(); columnHeader1.Text = "Station List"; this.stationList.Columns.AddRange(new ColumnHeader[] { columnHeader1 }); while (stationIter.MoveNext()) { tmpStation = stationIter.Current; if (stationNames.Contains(tmpStation.getbname()) && !String.IsNullOrEmpty(tmpStation.getbname())) { ListViewItem stationNameItems = new ListViewItem(tmpStation.getbname()); stationList.Items.Add(stationNameItems); } } stationList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); }
public virtual Key AddKey(Key key) { var keys = from kv in Buoy where kv.Key.CompareTo(key) < 0 orderby kv.Key descending select kv.Key; Key pk = keys.FirstOrDefault(); if (pk != null) { pk.Next = key; } else { FirstKey = key; } key.Previous = pk; keys = from kv in Buoy where kv.Key.CompareTo(key) > 0 orderby kv.Key select kv.Key; pk = keys.FirstOrDefault(); if (pk != null) { pk.Previous = key; } else { LastKey = key; } key.Next = pk; Buoy.Add(key, null); return(key); }
public void Handle(object sender, CustomEventArgs e) { if (e.ParseOK) { // try { var buf = new byte[e.DataBuffer.Length + 2]; var ip = e.CallSrc as string; int id = 0; id = Int16.Parse(ip.Substring(ip.Length - 1)); if (ip != null && !UnitCore.Instance.IsReplay) { //save Buffer.BlockCopy(e.DataBuffer, 0, buf, 2, e.DataBuffer.Length); Buffer.BlockCopy(BitConverter.GetBytes(id), 0, buf, 0, 2); UnitCore.Instance.MonTraceService.Save("ALL", buf); switch (id) { case 1: UnitCore.Instance.MonTraceService.Save("Buoy1", e.DataBuffer); break; case 2: UnitCore.Instance.MonTraceService.Save("Buoy2", e.DataBuffer); break; case 3: UnitCore.Instance.MonTraceService.Save("Buoy3", e.DataBuffer); break; case 4: UnitCore.Instance.MonTraceService.Save("Buoy4", e.DataBuffer); break; default: break; } } Buoy buoy = null; if (UnitCore.Instance.Buoy.ContainsKey(id - 1)) { buoy = ((Buoy)UnitCore.Instance.Buoy[id - 1]); } if (buoy == null) { return; } //类型标志 if (e.Mode == CallMode.UDPAns) { App.Current.Dispatcher.Invoke(new Action(() => { UnitCore.Instance.EventAggregator.PublishMessage(new LogEvent("浮标命令发送成功", LogType.OnlyInfoandClose)); })); return; } else if (e.Mode == CallMode.GPS) //gps { var gpsbuf = new byte[1030]; Buffer.BlockCopy(e.DataBuffer, 2, gpsbuf, 0, 1030); var info = MonProtocol.MonProtocol.ParseGps(gpsbuf); if (info != null) { buoy.gps = info; } } else if (e.Mode == CallMode.Range) { var litebuf = new byte[204]; Buffer.BlockCopy(e.DataBuffer, 2, litebuf, 0, 204); var range = MonProtocol.MonProtocol.ParsePulseRange(litebuf, false); var gpsbuf = new byte[1030]; Buffer.BlockCopy(e.DataBuffer, 16, gpsbuf, 0, 200 - 16); var info = MonProtocol.MonProtocol.ParseGps(gpsbuf); if (info != null) { buoy.gps = info; } if (range.ID == UnitCore.Instance.TargetObj1.ID) { buoy.liteRange1 = range; buoy.Range1 = MonProtocol.MonProtocol.CalDistanceByLite(range); } if (range.ID == UnitCore.Instance.TargetObj2.ID) { buoy.liteRange2 = range; buoy.Range2 = MonProtocol.MonProtocol.CalDistanceByLite(range); } } else if (e.Mode == CallMode.TeleRange) { var litebuf = new byte[14]; Buffer.BlockCopy(e.DataBuffer, 2, litebuf, 0, 14); var range = MonProtocol.MonProtocol.ParsePulseRange(litebuf, true); var length = BitConverter.ToUInt16(e.DataBuffer, 31); var combuf = new byte[242]; Buffer.BlockCopy(e.DataBuffer, 16, combuf, 0, 242); var telerange = MonProtocol.MonProtocol.ParseTeleRange(combuf, length); var gpsbuf = new byte[1030]; Buffer.BlockCopy(e.DataBuffer, 33 + length, gpsbuf, 0, 256 - 33 - length); var info = MonProtocol.MonProtocol.ParseGps(gpsbuf); if (telerange.ID == UnitCore.Instance.TargetObj1.ID) { buoy.teleRange1 = telerange; buoy.liteRange1 = range; buoy.Range1 = MonProtocol.MonProtocol.CalDistanceByTele(range, telerange); } if (telerange.ID == UnitCore.Instance.TargetObj2.ID) { buoy.teleRange2 = telerange; buoy.liteRange2 = range; buoy.Range2 = MonProtocol.MonProtocol.CalDistanceByTele(range, telerange); } if (info != null) { buoy.gps = info; } } if (buoy.gps == null) { return; } if (buoy.Range1 > 0.5) { var lpoint = new Locate2D(buoy.RangeTime1, buoy.gps.Longitude, buoy.gps.Latitude, buoy.Range1); //remove possible duplicate data UnitCore.Instance.Locate1.Buoys.Remove(id); UnitCore.Instance.Locate1.Buoys.Add(id, lpoint); } if (buoy.Range2 > 0.5) { var lpoint = new Locate2D(buoy.RangeTime2, buoy.gps.Longitude, buoy.gps.Latitude, buoy.Range2); //remove possible duplicate data UnitCore.Instance.Locate2.Buoys.Remove(id); UnitCore.Instance.Locate2.Buoys.Add(id, lpoint); } var point = new PointLatLng(buoy.gps.Latitude, buoy.gps.Longitude); point.Offset(UnitCore.Instance.MainMapCfg.MapOffset.Lat, UnitCore.Instance.MainMapCfg.MapOffset.Lng); UnitCore.Instance.EventAggregator.PublishMessage(new RefreshBuoyInfoEvent(id - 1)); App.Current.Dispatcher.Invoke(new Action(() => { if (UnitCore.Instance.mainMap != null) { UnitCore.Instance.BuoyLock.WaitOne(); var itor = UnitCore.Instance.mainMap.Markers.GetEnumerator(); while (itor.MoveNext()) { var marker = itor.Current; if ((int)marker.Tag == id) { if (marker.Shape is BuoyMarker buoymarker) { buoymarker.Refresh(buoy); marker.Position = point; } } } UnitCore.Instance.BuoyLock.ReleaseMutex(); } })); } catch (Exception ex) { if (UnitCore.Instance.BuoyLock.WaitOne(100) == true) { UnitCore.Instance.BuoyLock.ReleaseMutex(); } App.Current.Dispatcher.Invoke(new Action(() => { UnitCore.Instance.EventAggregator.PublishMessage(new ErrorEvent(ex, LogType.Both)); })); } } else { if (e.Mode == CallMode.ErrMode) { App.Current.Dispatcher.Invoke(new Action(() => { UnitCore.Instance.NetCore.StopUDPService(); // UnitCore.Instance.EventAggregator.PublishMessage(new ErrorEvent(e.Ex, LogType.Both)); })); } } }
private void ReadInitPara() { string gridname = MonConf.GetInstance().MyExecPath + "\\" + "default.ini"; Stream stream = null; try { stream = new FileStream(gridname, FileMode.Open, FileAccess.Read, FileShare.Read); IFormatter formatter = new BinaryFormatter(); initpara = (InitialData)formatter.Deserialize(stream); stream.Close(); Buoy = initpara.buoy; if (Buoy.Count == 0) { throw new Exception();//use default value } //clean the range info,only need gps location foreach (var buoy in Buoy.Values) { var b = (Buoy)buoy; b.Range1 = 0; b.Range2 = 0; b.liteRange1 = new LiteRange(); b.teleRange1 = new TeleRange(); b.liteRange2 = new LiteRange(); b.teleRange2 = new TeleRange(); } //InfoBoard = initpara.info; } catch (Exception MyEx) { if (stream != null) { stream.Close(); } var gpsinfo = new GpsInfo() { UTCTime = DateTime.UtcNow, Latitude = 29.592966F, Longitude = 118.983188F, }; var by1 = new Buoy() { Id = 1, gps = gpsinfo, IP = "192.168.2.101", }; Buoy.Add(0, by1); gpsinfo = new GpsInfo() { UTCTime = DateTime.UtcNow, Latitude = 29.502966F, Longitude = 118.903188F, }; var by2 = new Buoy() { Id = 2, gps = gpsinfo, IP = "192.168.2.102", }; Buoy.Add(1, by2); gpsinfo = new GpsInfo() { UTCTime = DateTime.UtcNow, Latitude = 29.512966F, Longitude = 118.913188F, }; var by3 = new Buoy() { Id = 3, gps = gpsinfo, IP = "192.168.2.103", }; Buoy.Add(2, by3); gpsinfo = new GpsInfo() { UTCTime = DateTime.UtcNow, Latitude = 29.542966F, Longitude = 118.943188F, }; var by4 = new Buoy() { Id = 4, gps = gpsinfo, IP = "192.168.2.104", }; Buoy.Add(3, by4); //InfoBoard = new Hashtable(); SaveInitPara(); var errmsg = new ErrorEvent(MyEx, LogType.Both) { Message = "浮标信息读取失败,使用默认参数" }; UnitCore.Instance.EventAggregator.PublishMessage(errmsg); } }
// Update is called once per frame void Update() { // MUSIC AudioSource asrc = gameObject.GetComponent <AudioSource>(); if (!asrc.isPlaying) { asrc.clip = backgroundMusic[CurrentMusic + 1]; asrc.Play(); CurrentMusic = (CurrentMusic + 1) < backgroundMusic.Count - 1?CurrentMusic + 1:0; } // MUSIC if (!(menu.GetState() == MenuManager.GameState.PLAYING || menu.GetState() == MenuManager.GameState.PLAYINGNOTIMER)) { return; } int playerPosition = ais.Count + 1; foreach (AI a in ais) { if (CurrentBuoy > a.CurrentBuoy) { playerPosition--; } } MenuManager.instance.PlayerPosition = playerPosition; Vector3 playerOffset = UpdatePlayer(); MoveEverythingWithPlayer(playerOffset); StickEverythingToSea(); for (int i = 0; i < ais.Count; ++i) { Vector3 aiRandomOffset = new Vector3(Random.Range(-BuoyCatchSqrRangeAI, BuoyCatchSqrRangeAI), 0.0f, Random.Range(-BuoyCatchSqrRangeAI, BuoyCatchSqrRangeAI)); if ((ais[i].CurrentBuoy + 1) < buoys.Count) { Buoy buoy = buoys[ais[i].CurrentBuoy + 1]; ais[i].direction = (buoy.go.transform.position + aiRandomOffset - ais[i].go.transform.position).normalized; ais[i].go.transform.LookAt(buoy.go.transform.position + aiRandomOffset); if ((ais[i].go.transform.position - buoy.go.transform.position).sqrMagnitude < BuoyCatchSqrRangeAI) { ais[i].CurrentBuoy = (ais[i].CurrentBuoy + 1) < NumberOfSteps ? ais[i].CurrentBuoy + 1 : ais[i].CurrentBuoy; if (menu.GetState() == MenuManager.GameState.PLAYING && (ais[i].CurrentBuoy + 1) >= buoys.Count) { // AI arrived before you TimerSecondsLeft = TimerAtTheStart; CurrentBuoy = -1; MenuManager.instance.EndGame(); } } } else { ais[i].direction = (aiRandomOffset * 10.0f - ais[i].go.transform.position).normalized; } //ais[i].currentSpeed = Mathf.Lerp(boatMaxSpeed, ais[i].currentSpeed, Mathf.Pow(2.0f, -boatAcceleration * Time.deltaTime)); } if ((CurrentBuoy + 1) >= buoys.Count) { MenuManager.instance.IncrementScore(computeScore()); // Restart Generate(); TimerSecondsLeft = TimerAtTheStart; CurrentBuoy = -1; PlaySFX(SFX4); foreach (AI a in ais) { a.currentSpeed = Random.Range(0.05f, boatMaxSpeed * 0.50f); } } if (TimerSecondsLeft > 0.0f) { if (ais.Count < numberIAs) { AI ai = new AI(); ai.go = Instantiate(aiPrefab) as GameObject; Vector3 aiRandomOffset = new Vector3(Random.Range(-BuoyCatchSqrRangeAI, BuoyCatchSqrRangeAI), 0.0f, Random.Range(-BuoyCatchSqrRangeAI, BuoyCatchSqrRangeAI)); ai.go.transform.position = playerBoat.transform.position + aiRandomOffset; ai.CurrentBuoy = -1; ai.currentSpeed = Random.Range(0.05f, boatMaxSpeed * 0.50f); if ((ai.CurrentBuoy + 1) < buoys.Count) { Buoy buoy = buoys[ai.CurrentBuoy + 1]; ai.direction = (buoy.go.transform.position + aiRandomOffset - ai.go.transform.position).normalized; } else { ai.direction = (aiRandomOffset - ai.go.transform.position).normalized; } ais.Add(ai); } // Catch fish List <Fish> fishesToDelete = new List <Fish>(); foreach (Fish f in fishs) { if ((playerFishNet.transform.position - f.go.transform.position).sqrMagnitude < FishCatchSqrRange) { TimerSecondsLeft += MenuManager.instance.BonusTimeFish; MenuManager.instance.IncrementScore(MenuManager.instance.BonusScoreFish); // TODO : juice it up, display some FX fishesToDelete.Add(f); PlaySFX(SFX1); // sound } } foreach (Fish f in fishesToDelete) { DestroyObject(f.go); fishs.Remove(f); } // Next Buoy if ((CurrentBuoy + 1) < buoys.Count) { Buoy buoy = buoys[CurrentBuoy + 1]; if ((playerBoat.transform.position - buoy.go.transform.position).sqrMagnitude < BuoyCatchSqrRange) { CurrentBuoy = (CurrentBuoy + 1) < NumberOfSteps ? CurrentBuoy + 1 : CurrentBuoy; TimerSecondsLeft += MenuManager.instance.BonusTimeBuoy; ParticleSystem ps = buoy.go.GetComponentInChildren <ParticleSystem>(); ps.Play(); Animator animator = buoy.go.GetComponent <Animator>(); animator.SetBool("Triggered", true); PlaySFX(SFX3); } } // DrawHelp if ((CurrentBuoy + 1) < buoys.Count) { Buoy buoy = buoys[CurrentBuoy + 1]; if (BuoyHelper != null) { float lerpFactor = Mathf.Pow(2.0f, -30.0f * Time.deltaTime); if ((playerBoat.transform.position - buoy.go.transform.position).sqrMagnitude < (9.0f * 9.0f)) { Transform arrow = BuoyHelper.transform.Find("arrow").transform; Transform anchor = buoy.go.transform.Find("ArrowAttachPoint").transform; if (ArrowReachedBuoy) { arrow.position = anchor.position; arrow.rotation = anchor.rotation; } else { arrow.position = Vector3.Lerp(anchor.position, arrow.position, lerpFactor); arrow.rotation = Quaternion.Lerp(anchor.rotation, arrow.rotation, lerpFactor); ArrowReachedBuoy = (arrow.position - anchor.position).sqrMagnitude < (1.0f * 1.0f); } } else { ArrowReachedBuoy = false; BuoyHelper.transform.LookAt(buoy.go.transform); Transform arrow = BuoyHelper.transform.Find("arrow").transform; Transform anchor = BuoyHelper.transform.Find("HelperAttachPoint").transform; arrow.position = Vector3.Lerp(anchor.position, arrow.position, lerpFactor); arrow.rotation = Quaternion.Lerp(anchor.rotation, arrow.rotation, lerpFactor); } BuoyHelper.transform.Find("arrow").GetComponent <Animator>().SetBool("Point", ArrowReachedBuoy); } } // Updating timer until the end if (MenuManager.instance.GetState() == MenuManager.GameState.PLAYING && (CurrentBuoy + 1) < NumberOfSteps) { int IntTimerBefore = (int)TimerSecondsLeft; TimerSecondsLeft -= Time.deltaTime; int IntTimerAfter = (int)TimerSecondsLeft; if (IntTimerAfter < 10 && IntTimerBefore != IntTimerAfter) { PlaySFX(SFX7); } } } else { /* Ultimate End*/ TimerSecondsLeft = TimerAtTheStart; CurrentBuoy = -1; MenuManager.instance.EndGame(); } // UI if (UIScoreValue != null) { UIScoreValue.text = MenuManager.instance.GetScore().ToString(); } if (UIScoreValue2 != null) { UIScoreValue2.text = MenuManager.instance.GetScore().ToString(); } if (UINumBuoys != null) { UINumBuoys.text = (CurrentBuoy + 1) + " OVER " + NumberOfSteps; } if (UITimer.gameObject.activeSelf && menu.GetState() == MenuManager.GameState.PLAYINGNOTIMER) { UITimer.gameObject.SetActive(false); UIClock.gameObject.SetActive(false); } else if (!UITimer.gameObject.activeSelf && menu.GetState() != MenuManager.GameState.PLAYINGNOTIMER) { UITimer.gameObject.SetActive(true); UIClock.gameObject.SetActive(true); } if (UITimer != null) { UITimer.text = ((int)TimerSecondsLeft).ToString(); if (TimerSecondsLeft <= 10.0f) { UITimer.color = Color.red; } else { UITimer.color = defaultUITimerColor; } } if (UIPlayerPosition != null || UIPlayerPositionInGame != null) { string rank = MenuManager.instance.PlayerPosition.ToString(); switch (MenuManager.instance.PlayerPosition) { case 1: rank = MenuManager.instance.PlayerPosition.ToString() + "ST"; break; case 2: rank = MenuManager.instance.PlayerPosition.ToString() + "ND"; break; case 3: rank = MenuManager.instance.PlayerPosition.ToString() + "RD"; break; default: rank = MenuManager.instance.PlayerPosition.ToString() + "TH"; break; } if (UIPlayerPosition != null) { UIPlayerPosition.text = MenuManager.instance.PlayerPosition.ToString() + " / " + (numberIAs + 1); } if (UIPlayerPositionInGame != null) { UIPlayerPositionInGame.text = rank + " OVER " + (numberIAs + 1); } } ClipEverythingOutsideSea(); }
private void Start() { _Buoyancy = GetComponent <Buoy>(); Explosion.SetActive(false); }
public BuoyMapUnit(Map map, Buoy buoy, Vector movementOffset) : base(map, buoy, movementOffset) { this.buoy = buoy; }
public void Refresh(Buoy buoy) { _buoy = buoy; InvalidateVisual(); }
/** * This is the function for when the graph button is clicked on the graphingForm **/ private void button1_Click(object sender, EventArgs e) { chart1.Series[0].Points.Clear(); List <Buoy> .Enumerator data = Stations.blist.GetEnumerator(); int stepper = 0; int graphSelection; graphSelection = comboBox1.SelectedIndex; switch (graphSelection) { //Wind Speed Graph case 0: while (data.MoveNext()) { tmpBuoy = data.Current; if (maineBuoys.Contains(tmpBuoy.getbname()) && !String.IsNullOrEmpty(tmpBuoy.getbname())) { chart1.Series[0].Points.AddY(tmpBuoy.getwindspeed()); chart1.Series[0].Points[stepper].AxisLabel = tmpBuoy.getbname(); chart1.Series[0].Points[stepper].IsValueShownAsLabel = true; stepper++; } } windSpeedText(); break; //Wind Direction Graph case 1: while (data.MoveNext()) { tmpBuoy = data.Current; if (maineBuoys.Contains(tmpBuoy.getbname()) && !String.IsNullOrEmpty(tmpBuoy.getbname())) { chart1.Series[0].Points.AddY(tmpBuoy.getwinddirection()); chart1.Series[0].Points[stepper].AxisLabel = tmpBuoy.getbname(); chart1.Series[0].Points[stepper].IsValueShownAsLabel = true; stepper++; } } windDirectionText(); break; //Dominant Wave Period Graph case 2: while (data.MoveNext()) { tmpBuoy = data.Current; if (maineBuoys.Contains(tmpBuoy.getbname()) && !String.IsNullOrEmpty(tmpBuoy.getbname())) { chart1.Series[0].Points.AddY(tmpBuoy.getdomwave()); chart1.Series[0].Points[stepper].AxisLabel = tmpBuoy.getbname(); chart1.Series[0].Points[stepper].IsValueShownAsLabel = true; stepper++; } } dominantWavePeriodText(); break; //Average Wave Period Graph case 3: while (data.MoveNext()) { tmpBuoy = data.Current; if (maineBuoys.Contains(tmpBuoy.getbname()) && !String.IsNullOrEmpty(tmpBuoy.getbname())) { chart1.Series[0].Points.AddY(tmpBuoy.getavewave()); chart1.Series[0].Points[stepper].AxisLabel = tmpBuoy.getbname(); chart1.Series[0].Points[stepper].IsValueShownAsLabel = true; stepper++; } } averageWavePeriodText(); break; //Sea Pressure Graph case 4: while (data.MoveNext()) { tmpBuoy = data.Current; if (maineBuoys.Contains(tmpBuoy.getbname()) && !String.IsNullOrEmpty(tmpBuoy.getbname())) { chart1.Series[0].Points.AddY(tmpBuoy.getseapress()); chart1.Series[0].Points[stepper].AxisLabel = tmpBuoy.getbname(); chart1.Series[0].Points[stepper].IsValueShownAsLabel = true; stepper++; } } seaPressureText(); break; //Air Tempreature Graph case 5: while (data.MoveNext()) { tmpBuoy = data.Current; if (maineBuoys.Contains(tmpBuoy.getbname()) && !String.IsNullOrEmpty(tmpBuoy.getbname())) { chart1.Series[0].Points.AddY(tmpBuoy.getairtemp()); chart1.Series[0].Points[stepper].AxisLabel = tmpBuoy.getbname(); chart1.Series[0].Points[stepper].IsValueShownAsLabel = true; stepper++; } } airTemperatureText(); break; //Sea Temperature Graph case 6: while (data.MoveNext()) { tmpBuoy = data.Current; if (maineBuoys.Contains(tmpBuoy.getbname()) && !String.IsNullOrEmpty(tmpBuoy.getbname())) { chart1.Series[0].Points.AddY(tmpBuoy.getseatemp()); chart1.Series[0].Points[stepper].AxisLabel = tmpBuoy.getbname(); chart1.Series[0].Points[stepper].IsValueShownAsLabel = true; stepper++; } } seaTemperatureText(); break; //Dew Temperature Graph case 7: while (data.MoveNext()) { tmpBuoy = data.Current; if (maineBuoys.Contains(tmpBuoy.getbname()) && !String.IsNullOrEmpty(tmpBuoy.getbname())) { chart1.Series[0].Points.AddY(tmpBuoy.getdewtemp()); chart1.Series[0].Points[stepper].AxisLabel = tmpBuoy.getbname(); chart1.Series[0].Points[stepper].IsValueShownAsLabel = true; stepper++; } } dewTemperatureText(); break; //Visibility Distance Graph case 8: while (data.MoveNext()) { tmpBuoy = data.Current; if (maineBuoys.Contains(tmpBuoy.getbname()) && !String.IsNullOrEmpty(tmpBuoy.getbname())) { chart1.Series[0].Points.AddY(tmpBuoy.getvis()); chart1.Series[0].Points[stepper].AxisLabel = tmpBuoy.getbname(); chart1.Series[0].Points[stepper].IsValueShownAsLabel = true; stepper++; } } visibilityText(); break; //Tide Height Graph case 9: while (data.MoveNext()) { tmpBuoy = data.Current; if (maineBuoys.Contains(tmpBuoy.getbname()) && !String.IsNullOrEmpty(tmpBuoy.getbname())) { chart1.Series[0].Points.AddY(tmpBuoy.gettide()); chart1.Series[0].Points[stepper].AxisLabel = tmpBuoy.getbname(); chart1.Series[0].Points[stepper].IsValueShownAsLabel = true; stepper++; } } tideHeightText(); break; default: break; } //Displays the series value to the chart area chart1.Series[0].ChartArea = "ChartArea1"; //Displays each values buoy name as a corresponding x-axis value chart1.ChartAreas[0].AxisX.Interval = 1; //Explination for the 0 values in the chart textBox1.AppendText(Environment.NewLine + Environment.NewLine + "*For all 0 values in the graph assume the buoy or land station did not take a reading"); }
private async void SendCMD_Click(object sender, RoutedEventArgs e) { var newdialog = (BaseMetroDialog)Application.Current.MainWindow.Resources["BuoyCMDDialog"]; var id = int.Parse(newdialog.Title.Substring(3, 1)); var CmdTypeBox = newdialog.FindChild <ComboBox>("CmdTypeBox"); var AUVIDBox = newdialog.FindChild <NumericUpDown>("AUVIDBox"); var XmtValue3DBox = newdialog.FindChild <NumericUpDown>("XmtValue3DBox"); var XmtValueBox = newdialog.FindChild <NumericUpDown>("XmtValueBox"); var FixTypeBox = newdialog.FindChild <ComboBox>("ModeTypeBox"); var FixtimeBox = newdialog.FindChild <TextBox>("timevalue"); var FixdistBox = newdialog.FindChild <TextBox>("distvalue"); var FixdepBox = newdialog.FindChild <TextBox>("depthvalue"); var FixdirBox = newdialog.FindChild <TextBox>("dirvalue"); var FixspeedBox = newdialog.FindChild <NumericUpDown>("speedvalue"); byte[] cmd = new byte[1032]; Array.Clear(cmd, 0, 1032); cmd[0] = 0x2B; cmd[1] = 0x00; Buffer.BlockCopy(BitConverter.GetBytes((Int16)XmtValueBox.Value.Value * 32767 / 100), 0, cmd, 2, 2); byte[] tinycmd = new byte[19]; if (CmdTypeBox.SelectedIndex == 0) { tinycmd[0] = 0x09; Buffer.BlockCopy(BitConverter.GetBytes((byte)AUVIDBox.Value.Value), 0, tinycmd, 1, 1); Buffer.BlockCopy(BitConverter.GetBytes((Int16)XmtValue3DBox.Value.Value * 32767 / 100), 0, tinycmd, 2, 2); } if (CmdTypeBox.SelectedIndex == 1) { tinycmd[0] = 0x11; Buffer.BlockCopy(BitConverter.GetBytes((byte)AUVIDBox.Value.Value), 0, tinycmd, 1, 1); } if (CmdTypeBox.SelectedIndex == 2) { tinycmd[0] = 0x19; Buffer.BlockCopy(BitConverter.GetBytes((byte)AUVIDBox.Value.Value), 0, tinycmd, 1, 1); tinycmd[2] = 0x05; tinycmd[3] = 0x81; if (AUVIDBox.Value.Value == 0) { tinycmd[4] = 0x04; } if (AUVIDBox.Value.Value == 1) { tinycmd[4] = 0x16; } tinycmd[5] = 0x0; tinycmd[6] = 0x46; tinycmd[7] = 0x0; Buffer.BlockCopy(BitConverter.GetBytes((byte)AUVIDBox.Value.Value), 0, tinycmd, 1, 1); } if (CmdTypeBox.SelectedIndex == 3) { tinycmd[0] = 0x19; Buffer.BlockCopy(BitConverter.GetBytes((byte)AUVIDBox.Value.Value), 0, tinycmd, 1, 1); tinycmd[2] = 0x0D; tinycmd[3] = 0x81; if (AUVIDBox.Value.Value == 0) { tinycmd[4] = 0x04; } if (AUVIDBox.Value.Value == 1) { tinycmd[4] = 0x16; } tinycmd[5] = 0x0; tinycmd[6] = 0x43; tinycmd[7] = 0x08; if (FixTypeBox.SelectedIndex == 0) { tinycmd[8] = 2; var timebytes = BitConverter.GetBytes((UInt16)(float.Parse(FixtimeBox.Text) * 10)); tinycmd[13] = timebytes[1]; tinycmd[14] = timebytes[0]; } if (FixTypeBox.SelectedIndex == 1) { tinycmd[8] = 1; var distbytes = BitConverter.GetBytes((UInt16)(float.Parse(FixdistBox.Text) * 10)); tinycmd[13] = distbytes[1]; tinycmd[14] = distbytes[0]; } var deptbytes = BitConverter.GetBytes((UInt16)(float.Parse(FixdepBox.Text) * 10)); tinycmd[9] = deptbytes[1]; tinycmd[10] = deptbytes[0]; var dirbytes = BitConverter.GetBytes((UInt16)(float.Parse(FixdirBox.Text) * 10)); tinycmd[11] = deptbytes[1]; tinycmd[12] = deptbytes[0]; tinycmd[15] = BitConverter.GetBytes(FixspeedBox.Value.Value)[0]; } Buffer.BlockCopy(tinycmd, 0, cmd, 8, 19); //send cmd Buoy b = (Buoy)UnitCore.Instance.Buoy[id - 1]; UnitCore.Instance.NetCore.UDPSend(b.IP, cmd); await TaskEx.Delay(500); await MainFrameViewModel.pMainFrame.DialogCoordinator.HideMetroDialogAsync(MainFrameViewModel.pMainFrame, newdialog); }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { //check for each item available and add. //itemtype references the item array found under the inventoryScript //gameobject. //check if full so we can add the items if (InventoryScript.MyInstance.MyEmptySlotCount > 0) { if (itemType == "Leaflet") { Leaflet leaflet = (Leaflet)Instantiate(InventoryScript.MyInstance.items[1]); InventoryScript.MyInstance.AddItem(leaflet); } else if (itemType == "Egg") { Egg egg = (Egg)Instantiate(InventoryScript.MyInstance.items[2]); InventoryScript.MyInstance.AddItem(egg); } else if (itemType == "Sword") { Sword sword = (Sword)Instantiate(InventoryScript.MyInstance.items[3]); InventoryScript.MyInstance.AddItem(sword); } else if (itemType == "Trident") { Trident trident = (Trident)Instantiate(InventoryScript.MyInstance.items[4]); InventoryScript.MyInstance.AddItem(trident); } else if (itemType == "Airpump") { AirPump ap = (AirPump)Instantiate(InventoryScript.MyInstance.items[5]); InventoryScript.MyInstance.AddItem(ap); } else if (itemType == "Bar") { PlatinumBar bar = (PlatinumBar)Instantiate(InventoryScript.MyInstance.items[6]); InventoryScript.MyInstance.AddItem(bar); } else if (itemType == "Knife") { Knife knife = (Knife)Instantiate(InventoryScript.MyInstance.items[7]); InventoryScript.MyInstance.AddItem(knife); } else if (itemType == "Rope") { Rope rope = (Rope)Instantiate(InventoryScript.MyInstance.items[8]); InventoryScript.MyInstance.AddItem(rope); } else if (itemType == "Skull") { Skull skull = (Skull)Instantiate(InventoryScript.MyInstance.items[9]); InventoryScript.MyInstance.AddItem(skull); } else if (itemType == "Sack") { Sack sack = (Sack)Instantiate(InventoryScript.MyInstance.items[10]); InventoryScript.MyInstance.AddItem(sack); } else if (itemType == "Lantern") { Lantern lantern = (Lantern)Instantiate(InventoryScript.MyInstance.items[11]); InventoryScript.MyInstance.AddItem(lantern); } else if (itemType == "Bottle") { Bottle bottle = (Bottle)Instantiate(InventoryScript.MyInstance.items[12]); InventoryScript.MyInstance.AddItem(bottle); } else if (itemType == "Candle") { Candle candle = (Candle)Instantiate(InventoryScript.MyInstance.items[13]); InventoryScript.MyInstance.AddItem(candle); } else if (itemType == "BlackBook") { BlkBook book = (BlkBook)Instantiate(InventoryScript.MyInstance.items[14]); InventoryScript.MyInstance.AddItem(book); } else if (itemType == "PlasticPile") { PlasticPile plastic = (PlasticPile)Instantiate(InventoryScript.MyInstance.items[15]); InventoryScript.MyInstance.AddItem(plastic); } else if (itemType == "Buoy") { Buoy buoy = (Buoy)Instantiate(InventoryScript.MyInstance.items[16]); InventoryScript.MyInstance.AddItem(buoy); } else if (itemType == "Shovel") { Shovel shovel = (Shovel)Instantiate(InventoryScript.MyInstance.items[17]); InventoryScript.MyInstance.AddItem(shovel); } else if (itemType == "Scarab") { Scarab scarab = (Scarab)Instantiate(InventoryScript.MyInstance.items[18]); InventoryScript.MyInstance.AddItem(scarab); } else if (itemType == "PotOfGold") { PotOfGold gold = (PotOfGold)Instantiate(InventoryScript.MyInstance.items[19]); InventoryScript.MyInstance.AddItem(gold); } else if (itemType == "Bracelet") { Bracelet bracelet = (Bracelet)Instantiate(InventoryScript.MyInstance.items[20]); InventoryScript.MyInstance.AddItem(bracelet); } else if (itemType == "Coal") { Coal coal = (Coal)Instantiate(InventoryScript.MyInstance.items[21]); InventoryScript.MyInstance.AddItem(coal); } else if (itemType == "Figurine") { Figurine fig = (Figurine)Instantiate(InventoryScript.MyInstance.items[22]); InventoryScript.MyInstance.AddItem(fig); } else if (itemType == "Diamond") { Diamond diamond = (Diamond)Instantiate(InventoryScript.MyInstance.items[23]); InventoryScript.MyInstance.AddItem(diamond); } else if (itemType == "Torch") { Torch torch = (Torch)Instantiate(InventoryScript.MyInstance.items[24]); InventoryScript.MyInstance.AddItem(torch); } else if (itemType == "Coins") { Coins coins = (Coins)Instantiate(InventoryScript.MyInstance.items[25]); InventoryScript.MyInstance.AddItem(coins); } else if (itemType == "Key") { Key key = (Key)Instantiate(InventoryScript.MyInstance.items[26]); InventoryScript.MyInstance.AddItem(key); } else if (itemType == "Matches") { Matches matches = (Matches)Instantiate(InventoryScript.MyInstance.items[27]); InventoryScript.MyInstance.AddItem(matches); } else if (itemType == "Wrench") { Wrench wrench = (Wrench)Instantiate(InventoryScript.MyInstance.items[28]); InventoryScript.MyInstance.AddItem(wrench); } else if (itemType == "Screwdriver") { Screwdriver sd = (Screwdriver)Instantiate(InventoryScript.MyInstance.items[29]); InventoryScript.MyInstance.AddItem(sd); } else if (itemType == "Jewels") { Jewels jewels = (Jewels)Instantiate(InventoryScript.MyInstance.items[30]); InventoryScript.MyInstance.AddItem(jewels); } else if (itemType == "Coffin") { Coffin coffin = (Coffin)Instantiate(InventoryScript.MyInstance.items[31]); InventoryScript.MyInstance.AddItem(coffin); } else if (itemType == "Chalice") { Chalice chalice = (Chalice)Instantiate(InventoryScript.MyInstance.items[32]); InventoryScript.MyInstance.AddItem(chalice); } //the following items should not be displayed in the world //but going to add just in case we revamp how these items //are obtained. else if(itemType == "Garlic") { Garlic garlic = (Garlic)Instantiate(InventoryScript.MyInstance.items[33]); InventoryScript.MyInstance.AddItem(garlic); } else if(itemType == "Sceptre") { Sceptre sep = (Sceptre)Instantiate(InventoryScript.MyInstance.items[34]); InventoryScript.MyInstance.AddItem(sep); } Destroy(gameObject); } //probably want to utilize CLI popup here else { Debug.Log("Bag full"); } } }