void OnTriggerEnter2D(Collider2D other) { PhoneIcon phoneIcon = other.gameObject.GetComponent <PhoneIcon>(); Obstacle myObstacle = other.gameObject.GetComponent <Obstacle>(); CoinIcon coinIcon = other.gameObject.GetComponent <CoinIcon>(); if (phoneIcon) { float value = phoneIcon.value; GameObject.Destroy(other.gameObject); phoneScore.addScore(value); phoneSlider.value += phoneIcon.value; Debug.Log("slider value: " + phoneSlider.value); } else if (myObstacle) { PlayerPrefs.SetFloat("phone_runner_score", phoneScore.getScore()); Application.LoadLevel("game_over_scene"); } else if (coinIcon) { float value = coinIcon.value; GameObject.Destroy(other.gameObject); coinAudio.PlayOneShot(coinSound); phoneScore.addScore(value); } }
private void buttonKeyPadButton_Click(object sender, RoutedEventArgs e) { var btn = sender as Button; if (call == null && btn.Content.Equals('#')) { return; } //Вводим номер для перевода bool transferFlag = (isTransferNumber(txtPhoneNumber.Text) || btn.Content.Equals("#")); if (transferFlag) //if (txtPhoneNumber.Text.Contains("#")) { InvokeGUIThread(() => { txtStatus.Text = "Трансфер на.."; PhoneIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "answer"); this.btnConnectOrReject.Background = Brushes.Green; }); } if (call != null && !transferFlag) { return; } // Добавим символ с кнокпки PutNumberWithDTMF(btn.Content.ToString()); }
// Входящий звонок private void softphone_IncomingCallEvent(Call incomingCall) { // Reject incoming call, if we have active if (this.call != null) { Softphone.TerminateCall(incomingCall); // write rejected call to base RecordToLocalDataBase.Phone = GetPhone(incomingCall.From); RecordToLocalDataBase.TimeStart = DateTime.Now; RecordToLocalDataBase.isRejected = true; return; } ; // set flag isIncoming = true; // Recieve incoming call this.call = incomingCall; //Echo cancellation Softphone.EchoCancellation(this.call, Settings.isEchoOff); string phone = GetPhone(this.call.From); string callId = GetCallId(this.call.From); InvokeGUIThread(() => { dialog = new IncomingDialog(); // show incoming call dialog dialog.Call = this.call; dialog.SoftPhone = Softphone; dialog.UpdateTextPanel(phone, callId); dialog.Show(); // change icon to incoming call this.txtStatus.Text = "Занят"; lblStatusRecord.Text = "Входящий"; PhoneIcon.SetResourceReference(Image.SourceProperty, "decline"); StatusIcon.SetResourceReference(Image.SourceProperty, "presence_not_available"); this.btnConnectOrReject.Background = Brushes.Red; }); // Play Sound #pragma warning disable CS0103 // The name 'Properties' does not exist in the current context #pragma warning disable CS0103 // The name 'Properties' does not exist in the current context Classes.LocalAudioPlayer.PlaySound(Properties.Resources.signal, true); #pragma warning restore CS0103 // The name 'Properties' does not exist in the current context #pragma warning restore CS0103 // The name 'Properties' does not exist in the current context // record call info RecordToLocalDataBase.Phone = phone; RecordToLocalDataBase.TimeStart = DateTime.Now; // Get information about caller GetInfoAboutCaller(call.From); }
// Звонок завершился private void softphone_CallCompletedEvent(Call call) { if (isIncoming) { // drop down Incoming call form InvokeGUIThread(() => { // Close borderCallNotification CloseCallNotification(); // hide incoming call dialog if (dialog != null) { dialog.Close(); dialog = null; } // add badge value to history button int value = string.IsNullOrEmpty(viewModel.BadgeValue) ? 0 : Convert.ToInt32(viewModel.BadgeValue); viewModel.BadgeValue = (++value).ToString(); }); } // write to database RecordToLocalDataBase.isOutcoming = isOutcoming; RecordToLocalDataBase.isIncoming = isIncoming; RecordToLocalDataBase.TimeEnd = DateTime.Now; Classes.SQLiteBase.AddRecordToDataBase(RecordToLocalDataBase); // clear flags isIncoming = false; isOutcoming = false; this.call = null; InvokeGUIThread(() => { txtStatus.Text = "Свободно"; PhoneIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "answer"); StatusIcon.SetResourceReference(Image.SourceProperty, "presenceAvailable"); btnConnectOrReject.Background = Brushes.Green; CloseCallNotification(); // discard blur effect to infoPanel if (borderCallNotification.BitmapEffect != null) { borderCallNotification.BitmapEffect = null; borderCallNotification.Background = null; } }); Classes.LocalAudioPlayer.PlaySound(Properties.Resources.notification_call_ended); }
private void softphone_PhoneConnectedEvent() { InvokeGUIThread(() => { //set available icon and text message PhoneIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "answer"); this.btnConnectOrReject.Background = Brushes.Green; StatusIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "presenceAvailable"); txtStatus.Text = "Подключен!"; }); }
// Звонок принят или исходящий private void softphone_CallActiveEvent(Call call) { if (isIncoming) { // sound notification off Classes.LocalAudioPlayer.StopSound(); if (dialog != null) { dialog.Close(); } // write incoming call to base RecordToLocalDataBase.Phone = GetPhone(call.From); RecordToLocalDataBase.TimeStart = DateTime.Now; RecordToLocalDataBase.isRejected = false; } else { this.call = call; // set outcoming call flag isOutcoming = true; // Disable echo Softphone.EchoCancellation(this.call, Settings.isEchoOff); string phone = GetPhone(call.To); //show caller info GetInfoAboutCaller(call.To); InvokeGUIThread(() => { txtStatus.Text = "Занят"; lblStatusRecord.Text = "Исходящий"; PhoneIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "decline"); StatusIcon.SetResourceReference(Image.SourceProperty, "presence_not_available"); btnConnectOrReject.Background = Brushes.Red; }); // set volume Softphone.SetSpeakerValue(this.call, (float)volumeSliderValue); // db record RecordToLocalDataBase.Phone = phone; RecordToLocalDataBase.isOutcoming = true; RecordToLocalDataBase.TimeStart = DateTime.Now; //Classes.SQLiteBase.AddRecordToDataBase(RecordToLocalDataBase); } }
// Update is called once per frame void Update() { float current_time = Time.time; if (current_time - lastCoinSpawnTime > 1.0) { //height and width of camera - used to determine where to spawn food float camHeight = Camera.main.orthographicSize; float camWidth = camHeight * Camera.main.aspect; //gets a random location relative to camera boundaries Vector3 spawn_loc_vector = new Vector3(Random.Range(15, 19), Random.Range(-1, 2)); CoinIcon newIcon = (CoinIcon)GameObject.Instantiate(coinIcon, spawn_loc_vector, new Quaternion()); newIcon.initialize(this); lastCoinSpawnTime = Time.time; } if (current_time - lastPhoneSpawnTime > 1.5) { //height and width of camera - used to determine where to spawn food float camHeight = Camera.main.orthographicSize; float camWidth = camHeight * Camera.main.aspect; //gets a random location relative to camera boundaries Vector3 spawn_loc_vector = new Vector3(Random.Range(15, 19), Random.Range(-1, 2)); PhoneIcon newIcon = (PhoneIcon)GameObject.Instantiate(phoneIcon, spawn_loc_vector, new Quaternion()); newIcon.initialize(this); lastPhoneSpawnTime = Time.time; } if (current_time - lastObstacleSpawnTime > 2) { //height and width of camera - used to determine where to spawn food float camHeight = Camera.main.orthographicSize; float camWidth = camHeight * Camera.main.aspect; //gets a random location relative to camera boundaries Vector3 spawn_loc_vector = new Vector3(BOX_SPAWN_POSX, Random.Range(-4, -2)); Obstacle newObstacle = (Obstacle)GameObject.Instantiate(obstacle, spawn_loc_vector, new Quaternion()); newObstacle.initialize(this); lastObstacleSpawnTime = Time.time; } }
public void removePhoneIcon(PhoneIcon removeMe) { GameObject.Destroy(removeMe.gameObject); }