示例#1
0
    void shoot(Vector3 dir, int intType, int intColor, int timeToLive)
    {
        if (debugPrints)
        {
            print("Shooot!");
        }
        Shot.ShotTypes type   = (Shot.ShotTypes)intType;
        GameColors     color  = (GameColors)intColor;
        GameObject     myShot = (GameObject)Instantiate(shot);

        myShot.GetComponent <Shot> ().InitShot(new Shot.ShotParams(type, color, timeToLive));
        var shotRigidBody = myShot.GetComponent <Rigidbody> ();

        shotRigidBody.transform.position = this.transform.position + mozzleOffset;
        shotRigidBody.velocity           = dir;
        Manager.instance.updateTurn();
    }
        private void _adapter_OnChange(MediaItem obj, Shot.ShotTypes tp)
        {
            if (!TRIMMODE)
            {
                currentpick = obj;
                if (tp == Shot.ShotTypes.TITLE)
                {
                    //show dialog:
                    var builder = new Android.Support.V7.App.AlertDialog.Builder(this);

                    preview.StopPlayback();
                    _adapter.UpdatePlaying(null);

                    FrameLayout frameView = new FrameLayout(this);
                    var         di        = LayoutInflater.Inflate(Resource.Layout.textentrydialog, frameView);
                    di.FindViewById <EditText>(Resource.Id.text).Text = obj.titletext;
                    if (!string.IsNullOrEmpty(obj.titletext))
                    {
                        var lines = obj.titletext?.Split('\n');
                        di.FindViewById <TextView>(Resource.Id.counter).Text = GetString(Resource.String.linecounter, lines.Count());
                    }


                    builder.SetView(frameView);
                    builder.SetPositiveButton(Android.Resource.String.Ok, (o, e) => { });
                    builder.SetTitle(Resource.String.entertitledialog);
                    builder.SetCancelable(true);


                    var dialog = builder.Show();

                    var cantsubmit = false;


                    Button positiveButton = (Button)dialog.GetButton((int)DialogButtonType.Positive);
                    positiveButton.Click += delegate
                    {
                        if (cantsubmit)
                        {
                            return;
                        }

                        var lns = di.FindViewById <EditText>(Resource.Id.text).Text.ToString().Split('\n');
                        if (lns.Length > 8)
                        {
                            //LoginFuncs.ShowError(this, Resource.String.titlelengthwarning);
                            TextInputLayout lay = dialog.FindViewById <TextInputLayout>(Resource.Id.textlayout);
                            lay.ErrorEnabled = true;
                            lay.Error        = GetString(Resource.String.titlelengthwarning);
                        }
                        else
                        {
                            var sanitisetext = Regex.Replace(di.FindViewById <TextView>(Resource.Id.text).Text, @"\p{Cs}", "").Replace('"', '\'').TrimStart('\n');

                            currentpick.titletext = sanitisetext;

                            if (!string.IsNullOrEmpty(currentpick.titletext))
                            {
                                var index = CurrentEdit.media.IndexOf(currentpick);
                                try
                                {
                                    CurrentEdit.media.RemoveAt(index);
                                }
                                catch
                                {
                                    index = CurrentEdit.media.Count() - 1;
                                }

                                var newobj = obj.Copy();
                                newobj.MediaType = Shot.ShotTypes.TITLE;
                                newobj.Status    = MediaItem.MediaStatus.DONE;
                                newobj.inpoint   = TimeSpan.Zero;
                                newobj.outpoint  = TimeSpan.FromSeconds(3);
                                newobj.event_id  = Bootlegger.BootleggerClient.CurrentEvent.id;
                                CurrentEdit.media.Insert(index, newobj);

                                allclipsfragment.UpdateEdit(CurrentEdit.media);


                                _adapter.UpdateData(CurrentEdit.media);
                                _sliveradapter.UpdateData(CurrentEdit.media);

                                UpdateTimings();
                                Bootlegger.BootleggerClient.LogUserAction("EditScreenAddTitle",
                                                                          new KeyValuePair <string, string>("title", currentpick.titletext),
                                                                          new KeyValuePair <string, string>("editid", CurrentEdit.id),
                                                                          new KeyValuePair <string, string>("eventid", Bootlegger.BootleggerClient.CurrentEvent.id));

                                currentpick = null;
                                dialog.Dismiss();
                            }
                            else
                            {
                                //dont insert blank title:
                                //currentpick = null;
                            }
                        }
                    };

                    dialog.FindViewById <EditText>(Resource.Id.text).RequestFocus();
                    dialog.FindViewById <EditText>(Resource.Id.text).TextChanged += (sender, e) =>
                    {
                        int linetoolong = -1;
                        var lns         = e.Text.ToString().Split('\n');


                        for (int line = 0; line < lns.Length; line++)
                        {
                            if (lns[line].Length > 29)
                            {
                                linetoolong = line;
                                break;
                            }
                        }

                        if (linetoolong != -1)
                        {
                            TextInputLayout titlelayout = dialog.FindViewById <TextInputLayout>(Resource.Id.textlayout);
                            titlelayout.ErrorEnabled = true;
                            titlelayout.Error        = Resources.GetString(Resource.String.linetoolong, (linetoolong + 1));
                            cantsubmit = true;
                        }
                        else
                        {
                            TextInputLayout titlelayout = dialog.FindViewById <TextInputLayout>(Resource.Id.textlayout);
                            titlelayout.ErrorEnabled = false;
                            cantsubmit = false;
                        }

                        dialog.FindViewById <TextView>(Resource.Id.counter).Text = GetString(Resource.String.linecounter, lns.Length);
                    };

                    //dialog.Show();
                }
                else
                {
                    ExpandPane();
                    (allclipsfragment as IImagePausable).Resume();
                }
            }
        }
 private void View_OnChange(MediaItem obj, Shot.ShotTypes tp)
 {
     OnChange?.Invoke(obj, tp);
 }