Example #1
0
        public ToxicForm(TemplateUnitBase tu, IReactable binded)
            : base(tu)
        {
            InitializeComponent();

            #region visual
            this.Text = (DEFTEXT != "") ? DEFTEXT : Statics.ERname(tu.TemplateFileName);
            //title
            Rectangle r = Screen.FromControl(this).Bounds;
            hp = r.Height / 100;
            wp = r.Width / 100;

            this.MinimumSize = new Size(wp * 80, hp * 50);
            Icon             = new System.Drawing.Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("VAB.Ui.icon.ico"));
            Panel back = new Panel();
            back.Dock = DockStyle.Fill;
            var rrr = this.BackColor;
            this.Controls.Add(back);
            Panel P = new Panel();
            P.Name       = "OuR Canvas";
            P.Height     = 10000;
            P.Width      = back.Width;
            P.Location   = new Point(0, 0);
            P.MouseDown += new MouseEventHandler(P_MouseDown);
            P.MouseMove += new MouseEventHandler(P_MouseMove);
            P.MouseUp   += new MouseEventHandler(P_MouseUp);
            back.Controls.Add(P);
            canvas       = P;
            this.Resize += new EventHandler((s, v) =>
            {
                back.Height  = this.ClientRectangle.Height - 66;
                back.Width   = this.ClientRectangle.Width - 13;
                canvas.Width = back.Width;
            });

            Width       = wp * 70;
            Height      = hp * 60;
            MinimumSize = new System.Drawing.Size(600, Height);
            MaximumSize = new System.Drawing.Size(10000, Height);
            #endregion

            this.Load += new EventHandler(ToxicForm_Load);
            TU         = tu;
            bind       = binded;

            Show();
        }
    IEnumerator SoundAlarm(StateController controller)
    {
        controller.bHasStatedAction = true;
        float alarmAgainTIme = 0.2f;
        Alarm alarm          = controller.GetComponent <Alarm>();

        if (alarm != null)
        {
            alarm.alarmPhase = Alarm.AlarmPhase.Alarming;
            alarm.ChangeAlarmRadiusColour();

            controller.onExitState += alarm.ChangeAlarmRadiusColour;

            while (controller.bHasStatedAction)
            {
                Collider2D[] objectsInAlarmSoundRadius = Physics2D.OverlapCircleAll(controller.transform.position, alarm.sensorDectecionRadius, alarm.objectsToAlertMask);
                for (int i = 0; i < objectsInAlarmSoundRadius.Length; ++i)
                {
                    IReactable reactableObject = objectsInAlarmSoundRadius[i].GetComponent <IReactable>();
                    if (reactableObject != null)
                    {
                        //TODO add a raycast around here to limit distance or area that reactable object can me manipulated.
                        if (controller.fov.visableTagets.Count > 0)
                        {
                            Transform firstDetectedObject = controller.fov.visableTagets[0];
                            reactableObject.React(Reactor.ReactorType.Alarm, alarm.reactionPriorityValue, firstDetectedObject, controller.transform);
                        }
                    }
                    else
                    {
                        Debug.Log("IReactable = null on object : " + objectsInAlarmSoundRadius[i].gameObject.name);
                    }
                }

                yield return(new WaitForSeconds(alarmAgainTIme));
            }
        }
    }