Ejemplo n.º 1
0
        private Insight SetGeneratedAndClosedTimes(Insight insight)
        {
            insight.GeneratedTimeUtc = UtcTime;
            insight.ReferenceValue   = _securityValuesProvider.GetValues(insight.Symbol).Get(insight.Type);
            if (string.IsNullOrEmpty(insight.SourceModel))
            {
                // set the source model name if not already set
                insight.SourceModel = Alpha.GetModelName();
            }

            TimeSpan barSize;
            Security security;
            SecurityExchangeHours exchangeHours;

            if (Securities.TryGetValue(insight.Symbol, out security))
            {
                exchangeHours = security.Exchange.Hours;
                barSize       = security.Resolution.ToTimeSpan();
            }
            else
            {
                barSize       = insight.Period.ToHigherResolutionEquivalent(false).ToTimeSpan();
                exchangeHours = MarketHoursDatabase.GetExchangeHours(insight.Symbol.ID.Market, insight.Symbol, insight.Symbol.SecurityType);
            }

            var localStart = UtcTime.ConvertFromUtc(exchangeHours.TimeZone);

            barSize = QuantConnect.Time.Max(barSize, QuantConnect.Time.OneMinute);
            var barCount = (int)(insight.Period.Ticks / barSize.Ticks);

            insight.CloseTimeUtc = QuantConnect.Time.GetEndTimeForTradeBars(exchangeHours, localStart, barSize, barCount, false).ConvertToUtc(exchangeHours.TimeZone);

            return(insight);
        }
Ejemplo n.º 2
0
 private void InitializeVariable()
 {
     joints[1]       = joint1;
     joints[2]       = joint2;
     joints[3]       = joint3;
     joints[4]       = joint4;
     joints[5]       = joint5;
     joints[6]       = joint6;
     joints[7]       = joint7;
     joints[8]       = joint8;
     joints[9]       = joint9;
     joints[10]      = joint10;
     joints[11]      = joint11;
     joints[12]      = joint12;
     joints[13]      = joint13;
     joints[14]      = joint14;
     joints[15]      = joint15;
     joints[16]      = joint16;
     updateFromAlpha = true;
     for (int id = 1; id <= 16; id++)
     {
         double angle;
         double minAngle;
         double maxAngle;
         if (Alpha.GetServoInfo(id, out angle, out minAngle, out maxAngle))
         {
             joints[id].Value   = angle;
             joints[id].Minimum = minAngle;
             joints[id].Maximum = maxAngle;
         }
     }
     updateFromAlpha = false;
 }
Ejemplo n.º 3
0
        public void WriteChar(int x, int y, int ch, int color)
        {
            int w = 3, h = 12;

            if (!Alpha.IsValidChar(ch))
            {
                return;
            }

            // Get char mask
            Surface tmp  = Char2Surface(ref alphas, ch - 32, w, h);
            int     size = tmp.w * tmp.h;

            byte[] pixels = new byte[size];
            Marshal.Copy(tmp.pixels, pixels, 0, pixels.Length);

            for (int i = 0; i < size; ++i)
            {
                pixels[i] = GetPixelColorFromMask(pixels[i], color);
            }

            // save original pixels
            IntPtr originalPixels = Marshal.AllocHGlobal(size);

            StdLib.MemCpy(originalPixels, tmp.pixels, size);

            Marshal.Copy(pixels, 0, tmp.pixels, size);
            PutImage(x, y, tmp, w, h);

            StdLib.MemCpy(tmp.pixels, originalPixels, size);
            Marshal.FreeHGlobal(originalPixels);
        }
Ejemplo n.º 4
0
    static void Main() 
    { 
        Alpha objA = new Alpha(4); 
        Beta objВ = new Beta (9); 
        // Продемонстрировать сначала контравариантность. 
        // Объявить делегат SomeOp<Alpha> и задать для него метод IsEven. 
        SomeOp<Alpha> checklt = IsEven;

        // Объявить делегат SomeOp<Beta>. 
        SomeOp<Beta> checklt2;
        //А теперь- присвоить делегат SomeOp<Alpha> делегату SomeOp<Beta>. 
        // *** Это допустимо только благодаря контравариантности. *** 
        checklt2 = checklt;
        // Вызвать метод через делегат. 
        Console.WriteLine(checklt2(objВ));
        // Далее, продемонстрировать контравариантность. 
        // Объявить сначала два делегата типа AnotherOp. 
        // Здесь возвращаемым типом является класс Beta, 
        //а параметром типа — класс Alpha. 
        // Обратите внимание на то, что для делегата modifylt 
        // задается метод Changelt. 
        AnotherOp<Beta, Alpha> modifylt = Changelt;
        // Здесь возвращаемым типом является класс Alpha, 
        //а параметром типа — тот же класс Alpha. 
        AnotherOp<Alpha, Alpha> modifyIt2;
        // А теперь присвоить делегат modifylt делегату modifyIt2. 
        // *** Это допустимо только благодаря ковариантности. *** 
        modifyIt2 = modifylt;
        // Вызвать метод и вывести результаты на экран. 
        objA = modifyIt2(objA);
        Console.WriteLine(objA.Val);
    }
Ejemplo n.º 5
0
        public void bind_template_primitive_types()
        {
            PropertyTreeReader pt = LoadContent("alpha.xml");

            Assert.True(pt.Read());
            var template = pt.Bind <Template <Alpha> >();
            var a        = new Alpha();

            template.Apply(a);

            Assert.True(a.A);
            Assert.False(a.AA.HasValue);
            Assert.Equal(0, a.B);
            Assert.True(a.BB.HasValue);
            Assert.Equal(0, a.BB.Value);
            Assert.Equal('g', a.D);
            Assert.Equal(DateTime.Parse("3/30/2011 1:50 AM"), a.E);
            Assert.Equal(10.5000m, a.F);
            Assert.Equal(10.5, a.G);
            Assert.Equal(256, a.H);
            Assert.Equal(1024, a.I);
            Assert.Equal(102410241024, a.J);
            Assert.Equal(-120, a.K);
            Assert.Equal(float.NaN, a.L);
            Assert.Equal("Carbonfrost F5 Project", a.M);
            Assert.Equal(65535, a.N);
            Assert.True(6553620 == a.O);
            Assert.True(6553620655362 == a.P);
            Assert.Equal(new Uri("http://carbonfrost.com"), a.Q);
            Assert.Equal(TimeSpan.Parse("4.12:0:30.5"), a.R);
            Assert.Equal(new Guid("{BF972F0A-CB10-441B-9D25-3D6DEB9065D1}"), a.S);
            Assert.Equal(DateTimeOffset.Parse("4/1/2011 12:11:01 AM -04:00"), a.T);
            Assert.Equal(typeof(Glob), a.U);
        }
Ejemplo n.º 6
0
        public override void Draw(ref Particle particle, float lasttime, float globaltime, NodeReference reference, ResourceManager res, Billboards billboards, ref Matrix4 transform, float sparam)
        {
            var time    = particle.TimeAlive / particle.LifeSpan;
            var node_tr = GetTranslation(reference, transform, sparam, time);

            var       p = node_tr.Transform(particle.Position);
            Texture2D tex;
            Vector2   tl, tr, bl, br;

            HandleTexture(res, globaltime, sparam, ref particle, out tex, out tl, out tr, out bl, out br);
            var c = Color.GetValue(sparam, time);
            var a = Alpha.GetValue(sparam, time);

            var p2 = node_tr.Transform(particle.Position + particle.Normal);
            //var n = (p - p2).Normalized();
            var n = Vector3.UnitZ;

            /*billboards.DrawPerspective(
             *      tex,
             *      p,
             *      new Vector2(Width.GetValue(sparam, time), Height.GetValue(sparam, time)),
             *      new Color4(c, a),
             *      tl,
             *      tr,
             *      bl,
             *      br,
             *      n,
             * Rotate == null ? 0f : MathHelper.DegreesToRadians(Rotate.GetValue(sparam, time)),
             *      SortLayers.OBJECT,
             *      BlendInfo
             * );*/
        }
Ejemplo n.º 7
0
 private void check_Click(object sender, EventArgs e)
 {
     if (bluelabel.ForeColor == Color.Blue && greenlabel.ForeColor == Color.Green && yellowlabel.ForeColor == Color.Yellow)
     {
         timer2.Start();
         bluelabel.Visible   = false;
         greenlabel.Visible  = false;
         yellowlabel.Visible = false;
         blue.Visible        = false;
         green.Visible       = false;
         yellow.Visible      = false;
         check.Visible       = false;
     }
     else if (bluelabel.Text == "" && greenlabel.Text == "" && yellowlabel.Text == "")
     {
     }
     else
     {
         System.Media.SoundPlayer begin = new System.Media.SoundPlayer(@"X:\ER-Audacitated\incorrect.wav");
         begin.Play();
         Hide();
         Alpha form = new Alpha();
         form.ShowDialog();
         Close();
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Used to send security changes to algorithm framework models
 /// </summary>
 /// <param name="changes">Security additions/removals for this time step</param>
 public sealed override void OnFrameworkSecuritiesChanged(SecurityChanges changes)
 {
     Alpha.OnSecuritiesChanged(this, changes);
     PortfolioConstruction.OnSecuritiesChanged(this, changes);
     Execution.OnSecuritiesChanged(this, changes);
     RiskManagement.OnSecuritiesChanged(this, changes);
 }
Ejemplo n.º 9
0
        private void attempt4_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape && e.Shift)
            {
                timer1.Stop(); timer2.Stop(); timer3.Stop(); timer4.Stop(); timer5.Stop(); timer6.Stop(); timer7.Stop(); timer8.Stop(); timer9.Stop(); timer10.Stop(); timer11.Stop(); timer12.Stop(); timer13.Stop(); timer14.Stop();
                labelFlash.Stop();
                toFirstFlash.Stop();
                firstFlash.Stop();
                secondFlash.Stop();
                return2flash.Stop();
                toNormalWindowstate.Stop();
                normalwsFlash.Stop();
                minandmax.Stop();
                tominimize.Stop();
                toolate.Stop();
                correctLeave.Stop();
                kill.Stop();
                flashscare1.Stop(); flashscare2.Stop(); flashscare3.Stop(); flashscare4.Stop(); flashscare5.Stop(); flashscare6.Stop(); flashscare7.Stop(); flashscare8.Stop(); flashscare9.Stop(); flashscare10.Stop(); flashscare11.Stop(); flashscare12.Stop();
                retardflash1.Stop(); retardflash2.Stop(); retardflash3.Stop(); retardflash4.Stop(); retardflash5.Stop(); retardflash6.Stop(); retardflash7.Stop(); retardflash8.Stop();
                godflash.Stop();
                godflash2.Stop();

                System.Media.SoundPlayer begin = new System.Media.SoundPlayer(@"X:\ER-Audacitated\halt.wav");
                begin.Play();
                Hide();
                Alpha form = new Alpha();
                form.ShowDialog();
                Close();
            }
            if (e.KeyCode == Keys.Escape)
            {
                Application.Exit();
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Prints the current Node: used for debugging
 /// </summary>
 public void printNode()
 {
     Console.Clear();
     Console.WriteLine("Alpha: " + Alpha.ToString() + " Beta: " + Beta.ToString());
     Console.WriteLine("Value: " + Value.ToString());
     NodeBoard.printBoard();
 }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            try
            {
                dynamic engine = Python.CreateEngine();
                dynamic scope  = engine.CreateScope();
                scope.Add = new Func <int, int, int>((x, y) => x + y);
                Console.WriteLine(scope.Add(2, 3)); // prints 5
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Random r  = new Random();
            Alpha  A1 = new Alpha(1, r);
            Alpha  A2 = new Alpha(2, r);
            //Beta A1 = new Beta(1);
            //Beta A2 = new Beta(2);
            Thread p1 = new Thread(new ThreadStart(A1.ThreadRun));
            Thread p2 = new Thread(new ThreadStart(A2.ThreadRun));

            p1.Start();
            p2.Start();

            // Put the Main thread to sleep for 1 millisecond to allow oThread
            // to do some work:
            Console.WriteLine("Sleep 5");
            Thread.Sleep(5000);
        }
Ejemplo n.º 12
0
        public void NotifyGenericMessageTest()
        {
            var listenerAlpha = new GenericHandler <Alpha>();
            var listenerBeta  = new GenericHandler <Beta>();
            IEventAggregator eventAggregator = CreateEventAggregator();

            eventAggregator.Subscribe(listenerAlpha);
            eventAggregator.Subscribe(listenerBeta);

            //Publish about alpha.
            var alpha = new Alpha();

            eventAggregator.Publish(eventAggregator, alpha);
            listenerAlpha.Count.ShouldEqual(1);
            listenerAlpha.Message.ShouldEqual(alpha);
            listenerAlpha.Sender.ShouldEqual(eventAggregator);
            listenerBeta.Count.ShouldEqual(0);

            //Publish about beta.
            var beta = new Beta();

            eventAggregator.Publish(eventAggregator, beta);
            listenerAlpha.Count.ShouldEqual(2);
            listenerAlpha.Message.ShouldEqual(beta);
            listenerAlpha.Sender.ShouldEqual(eventAggregator);
            listenerBeta.Count.ShouldEqual(1);
            listenerBeta.Message.ShouldEqual(beta);
            listenerBeta.Sender.ShouldEqual(eventAggregator);
        }
Ejemplo n.º 13
0
        public override void UpdateViewMatrix()
        {
            if (Beta < MinBeta)
            {
                Beta = MinBeta;
            }

            var sideRadius = Radius * Beta.Cos();
            var height     = Radius * Beta.Sin();

            if (Target.Y + height < MinY)
            {
                height = MinY - Target.Y;
            }

            Position = new Vector3(
                Target.X + sideRadius * Alpha.Cos(),
                Target.Y + height,
                Target.Z + sideRadius * Alpha.Sin());
            SetView(Matrix.LookAtRH(Position, Target, GetUpTilt(Target, Vector3.UnitY)));

            Right = new Vector3(View.M11, View.M21, View.M31);
            Right.Normalize();

            Up = new Vector3(View.M12, View.M22, View.M32);
            Up.Normalize();

            Look = -new Vector3(View.M13, View.M23, View.M33);
            Look.Normalize();
        }
Ejemplo n.º 14
0
        public void AnalyseDuplicateAssignmentTest()
        {
            // Arrange
            var alpha = new Alpha
            {
                FieldValues = new List <DynamicFieldValue>
                {
                    ConfigurationHelper.CreateField(FieldType.Text, nameof(DynamicFieldValue.ValueString), "Let's get dangerous")
                }
            };

            var fieldInformation = new FieldInformation <DynamicFieldDefinition, DynamicFieldAssignment, DynamicFieldValue, string, int>
            {
                Definitions = new List <DynamicFieldDefinition>
                {
                    ConfigurationHelper.CreateDefinition(FieldType.Text)
                },
                Assignments = new List <DynamicFieldAssignment>
                {
                    ConfigurationHelper.CreateAssignment(FieldType.Text),
                    ConfigurationHelper.CreateAssignment(FieldType.Text)
                },
                Values = alpha.FieldValues
            };

            // Act
            var result = _classUnderTest.Analyse(alpha, fieldInformation);

            // Assert
            result.Result[nameof(FieldType.Text) + "Assignment"].Id.Should().Be(nameof(FieldType.Text) + "Value");
            result.Result[nameof(FieldType.Text) + "Assignment"].Value.Should().Be("Let's get dangerous");
            result.Result[nameof(FieldType.Text) + "Assignment"].Type.Should().Be(typeof(string));
        }
Ejemplo n.º 15
0
        public void AnalyseMissingFieldValueTest()
        {
            // Arrange
            var alpha = new Alpha
            {
                FieldValues = new List <DynamicFieldValue>
                {
                    ConfigurationHelper.CreateField(FieldType.TextMultiline, nameof(DynamicFieldValue.ValueString), "Let's get dangerous")
                }
            };

            var fieldInformation = new FieldInformation <DynamicFieldDefinition, DynamicFieldAssignment, DynamicFieldValue, string, int>
            {
                Definitions = new List <DynamicFieldDefinition>
                {
                    ConfigurationHelper.CreateDefinition(FieldType.Text)
                },
                Assignments = new List <DynamicFieldAssignment>
                {
                    ConfigurationHelper.CreateAssignment(FieldType.Text)
                },
                Values = alpha.FieldValues
            };

            // Act
            var result = _classUnderTest.Analyse(alpha, fieldInformation);

            // Assert
            result.Result.ContainsKey(nameof(FieldType.Text) + "Assignment").Should().BeFalse();
        }
Ejemplo n.º 16
0
        public void MakeEmptyPetriNetTest()
        {
            // Arrange
            List <string> activities = new List <string>()
            {
                "wake up", "have coffee", "have tea", "work", "go home", "go sleep", "play witcher"
            };
            HashSet <string> startActivities = new HashSet <string>()
            {
                "wake up"
            };
            HashSet <string> endActivities = new HashSet <string>()
            {
                "go sleep", "play witcher"
            };
            RelationMatrix matrix = new RelationMatrix(activities, startActivities, endActivities);

            // Act
            IPetriNet madeNet = Alpha.MakePetriNet(matrix);

            // Assert
            Assert.IsNotNull(madeNet);
            Assert.AreEqual("p1", madeNet.EndPlace.Id);
            Assert.AreEqual("p0", madeNet.StartPlace.Id);
            Assert.AreEqual(2, madeNet.Places.Count);
            Assert.AreEqual(7, madeNet.Transitions.Count);
        }
Ejemplo n.º 17
0
        public bool IsEqualTo(TileCell cell)
        {
            if (X != cell.X || Y != cell.Y)
            {
                return(false);
            }
            if (Alpha.Equals(cell.Alpha) == false)
            {
                return(false);
            }
            if (Rotation.Equals(cell.Rotation) == false)
            {
                return(false);
            }
            if (AutoTextureType != cell.AutoTextureType)
            {
                return(false);
            }
            if (FlipEffect != cell.FlipEffect)
            {
                return(false);
            }

            return(TextureSource.IsEqualTo(cell.TextureSource));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 속성들을 Xml Attribute로 생성합니다.
        /// </summary>
        /// <param name="writer">Attribute를 쓸 Writer</param>
        public override void GenerateXmlAttributes(XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (MinValue.HasValue)
            {
                writer.WriteAttributeString("minValue", MinValue.ToString());
            }
            if (MaxValue.HasValue)
            {
                writer.WriteAttributeString("maxValue", MaxValue.ToString());
            }

            if (Label.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("label", Label);
            }

            if (Code.HasValue)
            {
                writer.WriteAttributeString("Code", Code.Value.ToHexString());
            }
            if (Alpha.HasValue)
            {
                writer.WriteAttributeString("Alpha", Alpha.ToString());
            }
            if (BorderColor.HasValue)
            {
                writer.WriteAttributeString("BorderColor", BorderColor.Value.ToHexString());
            }
            if (BorderAlpha.HasValue)
            {
                writer.WriteAttributeString("BorderAlpha", BorderAlpha.ToString());
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// コンストラクター
        /// </summary>
        public MainWindowViewModel(IAppSettingsService appSettingsService, IOpenFileDialogService openFileDialogService, ITextReadService textReadService, ITalkService talkService, ITalkQueueService talkQueueService)
        {
            AppSettingsService    = appSettingsService;
            OpenFileDialogService = openFileDialogService;
            TextReadService       = textReadService;
            TalkService           = talkService;
            TalkQueueService      = talkQueueService;

            TextReadService.Subscribe(TalkQueueService.Enqueue);

            SelectedCast.Value = TalkService.Cast;
            SelectedCast.Subscribe(x => TalkService.Cast = x);

            Volume.Value = TalkService.Volume;
            Volume.Subscribe(x => TalkService.Volume = x);

            Speed.Value = TalkService.Speed;
            Speed.Subscribe(x => TalkService.Speed = x);

            Tone.Value = TalkService.Tone;
            Tone.Subscribe(x => TalkService.Tone = x);

            Alpha.Value = TalkService.Alpha;
            Alpha.Subscribe(x => TalkService.Alpha = x);

            ToneScale.Value = TalkService.ToneScale;
            ToneScale.Subscribe(x => TalkService.ToneScale = x);

            LoadSettingsCommand.Subscribe(LoadSettings);
            SaveSettingsCommand.Subscribe(SaveSettings);

            OpenCommand.Subscribe(Open);

            ToggleWatchCommand.Subscribe(ToggleWatch);
        }
Ejemplo n.º 20
0
 private void attempt1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape && e.Shift)
     {
         beginWoods.Stop();
         downloadTimer.Stop();
         spook.Stop();
         backToAlpha.Stop();
         returnEscapeFail.Stop();
         string path      = System.Reflection.Assembly.GetExecutingAssembly().Location;
         string directory = Path.GetDirectoryName(path);
         path = Path.Combine(directory, "halt.wav");
         System.Media.SoundPlayer sound = new System.Media.SoundPlayer(path);
         sound.Play();
         Hide();
         Alpha form = new Alpha();
         form.ShowDialog();
         Close();
     }
     else
     if (e.KeyCode == Keys.Escape)
     {
         Application.Exit();
     }
 }
        private void ExecuteControlBoard(string sCommand)
        {
            Regex  rx    = new Regex("\\s+");
            string input = rx.Replace(sCommand, " ");

            string[]    sData    = input.Split(' ');
            List <byte> lCommand = new List <byte>();

            for (int i = 0; i < sData.Length; i++)
            {
                GetInputCommand(sData[i], lCommand);
            }

            byte[] command = lCommand.ToArray();

            string output = BitConverter.ToString(command);

            output       = output.Replace("-", ", ");
            txtSend.Text = output;

            byte[] result = Alpha.ControlBoardV1Command(command);
            if (result == null)
            {
                txtReturn.Text = "";
            }
            else
            {
                Alpha.StartAnimation();
                output         = BitConverter.ToString(result);
                output         = output.Replace("-", ", ");
                txtReturn.Text = output;
                Alpha.DummyAction();
            }
        }
Ejemplo n.º 22
0
        public void LogNoExceptionTest()
        {
            // Arrange
            var eventId = new EventId(0, "MegaVolt");
            var alpha   = new Alpha
            {
                Beta  = 123,
                Gamma = "Super Hero",
            };
            var additionalInformation = new AdditionalInformation
            {
                Class       = "Villain",
                Method      = "Attack",
                Message     = "DarkwingDuck is late",
                Information = alpha
            };

            var logEntry = default(LogEntry);

            A.CallTo(() => _logWriterFake.Write(A <LogEntry> .Ignored)).Invokes(fakeCallObject =>
            {
                logEntry = fakeCallObject.Arguments[0] as LogEntry;
            });

            // Act
            _classUnderTest.Log(LogLevel.Error, eventId, additionalInformation, null, null);

            // Assert
            logEntry.Exception.Should().BeNull();
        }
Ejemplo n.º 23
0
 protected override void OnMouseEnter(EventArgs e)
 {
     this.Focus();
     base.OnMouseEnter(e);
     alpha = Alpha.MoveOrUp;
     base.Invalidate();
 }
Ejemplo n.º 24
0
        internal static bool TryParse(string id, out Alpha row, out int col)
        {
            row = Alpha.A;
            col = 0;

            var   alpha = id.FirstOrDefault().ToString().ToUpper();
            Alpha a;

            if (!Enum.TryParse(alpha, out a))
            {
                return(false);
            }
            else
            {
                row = a;
            }

            var colString = id.ToUpper().Replace(alpha, "");

            if (!Int32.TryParse(colString, out col))
            {
                return(false);
            }

            return(col > 0 && col < 13);
        }
Ejemplo n.º 25
0
 /// <summary>
 /// tries to apply the formulas in the text boxes.
 /// throws an exception on failure
 /// </summary>
 public void ApplyFormulas()
 {
     Color.Apply();
     Alpha.Apply();
     model.UseFilter = useFilter;
     prevHasChanged  = false;
 }
Ejemplo n.º 26
0
        public static double[] EigenvalueBound()
        {
            int    n   = Alpha.GetLength(0);
            double min = Alpha[0] - Math.Abs(Beta[0]);
            double max = Alpha[0] + Math.Abs(Beta[0]);
            double lambda;

            for (int i = 1; i < n - 1; i++)
            {
                lambda = Alpha[i] - Math.Abs(Beta[i]) - Math.Abs(Beta[i - 1]);
                if (lambda < min)
                {
                    min = lambda;
                }
                lambda = Alpha[i] + Math.Abs(Beta[i]) + Math.Abs(Beta[i - 1]);
                if (lambda > max)
                {
                    max = lambda;
                }
            }
            lambda = Alpha[n - 1] - Math.Abs(Beta[n - 2]);
            if (lambda < min)
            {
                min = lambda;
            }
            lambda = Alpha[n - 1] + Math.Abs(Beta[n - 2]);
            if (lambda > max)
            {
                max = lambda;
            }
            return(new double[] { min, max });
        }
Ejemplo n.º 27
0
        public void GivenIHaveASecondThreadToRun()
        {
            Alpha alpha = new Alpha();

            new Thread(new ParameterizedThreadStart(alpha.Beta)).Start("Secondary thread");
            alpha.Beta("main thread");
        }
Ejemplo n.º 28
0
 public static void AlphaTest()
 {
     Console.WriteLine("Thread Start/Stop/Join Sample");
     Alpha oAlpha = new Alpha();
     // Create the thread object, passing in the Alpha.Beta method
     // via a ThreadStart delegate. This does not start the thread.
     Thread oThread = new Thread(new ThreadStart(oAlpha.Beta));
     // Start the thread
     oThread.Start();
     // Spin for a while waiting for the started thread to become
     // alive:
     if (oThread.IsAlive) Console.WriteLine("thread is running...");
     // Put the Main thread to sleep for 1 millisecond to allow oThread
     // to do some work:
     Thread.Sleep(1000);
     // Request that oThread be stopped
     if (oThread.IsAlive) Console.WriteLine("thread is still running...");
     oThread.Abort(); // this will kill the thread
     if (!oThread.IsAlive) Console.WriteLine("thread is dead...");
     // Wait until oThread finishes. Join also has overloads
     // that take a millisecond interval or a TimeSpan object.
     oThread.Join(); // not sure what this does to a dead thread
     Console.WriteLine("Alpha.Beta has finished");
     try
     {
         Console.WriteLine("Try to restart the Alpha.Beta thread");
         oThread.Start();
     }
     catch (ThreadStateException)
     {
         Console.Write("ThreadStateException trying to restart Alpha.Beta. ");
         Console.WriteLine("Expected since aborted threads cannot be restarted.");
     }
 }
Ejemplo n.º 29
0
        public void MakeEasyPetriNetTest()
        {
            // Arrange
            ImportedEventLog elog = CSVImport.MakeDataFrame(easyCsv);

            elog.SetActivity("act");
            elog.SetCaseId("id");
            WorkflowLog    wlog       = new WorkflowLog(elog);
            RelationMatrix matrix     = new RelationMatrix(wlog);
            IPetriNet      exampleNet = MakeEasyPetriNet();

            // Act
            IPetriNet madeNet = Alpha.MakePetriNet(matrix);

            // Assert
            Assert.IsNotNull(exampleNet);
            Assert.AreEqual(exampleNet.EndPlace.Id, madeNet.EndPlace.Id);
            Assert.AreEqual(exampleNet.StartPlace.Id, madeNet.StartPlace.Id);
            Assert.AreEqual(exampleNet.Places.Count, madeNet.Places.Count);
            Assert.AreEqual(exampleNet.Transitions.Count, madeNet.Transitions.Count);

            foreach (IPlace p in exampleNet.Places)
            {
                Assert.IsTrue(madeNet.Places.Exists(a => a.Id == p.Id));
            }
            foreach (ITransition t in exampleNet.Transitions)
            {
                Assert.IsTrue(madeNet.Transitions.Exists(a => a.Id == t.Id &&
                                                         a.Activity == t.Activity &&
                                                         a.InputPlaces.Count == t.InputPlaces.Count &&
                                                         a.OutputPlaces.Count == t.OutputPlaces.Count));
            }
        }
Ejemplo n.º 30
0
 private void attempt5_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape && e.Shift)
     {
         load.Stop();
         timer1.Stop();
         timer2.Stop();
         timer3.Stop();
         incorrectTimer.Stop();
         downloadTimer.Stop();
         downloadTimer2.Stop();
         didntclickyesorno.Stop();
         System.Media.SoundPlayer begin = new System.Media.SoundPlayer(@"X:\ER-Audacitated\halt.wav");
         begin.Play();
         Hide();
         Alpha form = new Alpha();
         form.ShowDialog();
         Close();
     }
     else
     if (e.KeyCode == Keys.Escape)
     {
         Application.Exit();
     }
 }
Ejemplo n.º 31
0
    public void Sample()
    {
        if (IsPlaying == false)
        {
            return;
        }

        transform.position = new Vector3(0f, CurrentPosition * m_Scale - Depth * 0.15f, Depth + PlaybackTime * 0.01f) + AttachTransform.position;

        Vector3 scale = Vector3.one * Scale.Evaluate(PlaybackTime);

        scale.z = 1f;
        transform.localScale = (IsUGUI ? 0.05f : 1f) * scale;

        Color32 color = m_Text.color;

        color.a      = (byte)(255 * Alpha.Evaluate(PlaybackTime));
        m_Text.color = color;

        IsPlaying = PlaybackTime < Position.Length || PlaybackTime < Scale.Length || PlaybackTime < Alpha.Length;

        if (IsPlaying == false)
        {
            AttachTransform = null;
        }
    }
Ejemplo n.º 32
0
        private Alpha SetGeneratedAndClosedTimes(Alpha alpha)
        {
            alpha.GeneratedTimeUtc = UtcTime;

            TimeSpan barSize;
            Security security;
            SecurityExchangeHours exchangeHours;

            if (Securities.TryGetValue(alpha.Symbol, out security))
            {
                exchangeHours = security.Exchange.Hours;
                barSize       = security.Resolution.ToTimeSpan();
            }
            else
            {
                barSize       = alpha.Period.ToHigherResolutionEquivalent(false).ToTimeSpan();
                exchangeHours = MarketHoursDatabase.GetExchangeHours(alpha.Symbol.ID.Market, alpha.Symbol, alpha.Symbol.SecurityType);
            }

            var localStart = UtcTime.ConvertFromUtc(exchangeHours.TimeZone);

            barSize = QuantConnect.Time.Max(barSize, QuantConnect.Time.OneMinute);
            var barCount = (int)(alpha.Period.Ticks / barSize.Ticks);

            alpha.CloseTimeUtc = QuantConnect.Time.GetEndTimeForTradeBars(exchangeHours, localStart, barSize, barCount, false).ConvertToUtc(exchangeHours.TimeZone);

            return(alpha);
        }
 static void Main(){
     
     Stopwatch timer = new Stopwatch();
     timer.Start();
     
     
     Alpha oAlpha = new Alpha();
     Beta oBeta = new Beta();
     
     // create the threads
     Thread aThread = new Thread(new ThreadStart(oAlpha.Counter));
     Thread bThread = new Thread(new ThreadStart(oBeta.Counter));
     
     
     // start the threads
     aThread.Start();
     bThread.Start();
     
     // spin until both threads have finished
     while(aThread.IsAlive && bThread.IsAlive);
     
     timer.Stop();
     
     TimeSpan ts = timer.Elapsed;
     
     Console.WriteLine("Execution Time: " + ts);
     
     
     
     
 }
 public bool IsAlpha_IsValid(string propertyValue)
 {
     //Create Validator
     var validator = new Alpha<Contact>();
     RuleValidatorContext<Contact, string> context = BuildContextForLength(propertyValue);
     //Validate the validator only, return true of no error returned
     return validator.Validate(context, null) == null;
 }
        public void bind_empty_node()
        {
            PropertyTree pt = LoadTree("alpha-empty.xml");
            Alpha a = new Alpha();

            pt.Bind(a);
            Assume.That(a.A, Is.False);
            Assume.That(a.C, Is.Null);
        }
Ejemplo n.º 36
0
        public static void Main(string[] args)
        {
            Application.Init ();

            Stage stage = Stage.Default as Stage;
            (stage as Stage).KeyPressEvent += delegate {
                Clutter.Main.Quit();
            };

            // fixme: add constructor
            Clutter.Color stage_color = new Clutter.Color (0xcc, 0xcc, 0xcc, 0xff);
            stage.SetColor (stage_color);

            Clutter.Group group = new Group();
            stage.Add (group);
            group.Show ();

            // Make a hand
            Clutter.Actor hand = new Texture ("redhand.png");
            hand.SetPosition (0,0);
            hand.Show ();

            // Make a rect
            Clutter.Rectangle rect = new Clutter.Rectangle();
            rect.SetPosition (0,0);
            rect.SetSize ((int)hand.Width, (int)hand.Height);

            Clutter.Color rect_bg_color = new Clutter.Color (0x33, 0x22, 0x22, 0xff);
            rect.SetColor (rect_bg_color);
            rect.BorderWidth = 10;
            rect.Show ();

            group.Add (rect);
            group.Add (hand);

            // Make a timeline
            Timeline timeline = new Timeline (100, 26);
            timeline.Loop = true;

            Alpha alpha = new Alpha (timeline, (a) => a.Value);

            Behaviour o_behave = new BehaviourOpacity (alpha, 0x33, 0xff);
            o_behave.Apply (group);

            // Make a path behaviour and apply that too
            Behaviour p_behave = new BehaviourPath(alpha, knots); // fixme: add custom constructor?
            p_behave.Apply (group);

            // start timeline
            timeline.Start ();

            stage.ShowAll();

            // launch
            Application.Run ();
        }
        public void binding_from_object_to_tree()
        {
            Alpha a = new Alpha();
            a.A = true;
            a.TT = new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.FromHours(-8));

            PropertyTree pt = PropertyTree.FromValue(a);
            Assert.That(pt["A"].Value, Is.True);
            Assert.That(pt["TT"].Value, Is.EqualTo(a.TT));
        }
        public void bind_empty_self_closing_node_in_parent_context()
        {
            PropertyTree pt = LoadTree("alpha-list.xml");
            Alpha a = new Alpha();

            pt.Children[2].Bind(a);

            Assume.That(a.A, Is.False);
            Assume.That(a.C, Is.Null);
            Assume.That(a.U, Is.Null);
        }
        /// <summary>
        /// Alters the alpha component of the image.
        /// </summary>
        /// <param name="source">The image this method extends.</param>
        /// <param name="percent">The new opacity of the image. Must be between 0 and 100.</param>
        /// <param name="rectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
        /// </param>
        /// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
        /// <returns>The <see cref="Image"/>.</returns>
        public static Image Alpha(this Image source, int percent, Rectangle rectangle, ProgressEventHandler progressHandler = null)
        {
            Alpha processor = new Alpha(percent);
            processor.OnProgress += progressHandler;

            try
            {
                return source.Process(rectangle, processor);
            }
            finally
            {
                processor.OnProgress -= progressHandler;
            }
        }
        public void binding_from_object_into_tree_value()
        {
            PropertyTree tree = new PropertyTree();
            Alpha a = new Alpha();
            a.A = true;
            a.TT = new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.FromHours(-8));
            tree.Value = a;

            Assert.That(tree.QualifiedName, Is.Null);
            Assert.That(tree.Children.Count, Is.EqualTo(typeof(Alpha).GetProperties().Length));
            Assert.That(tree.Children.Select(t => t.Name), Contains.Item("TT"));

            Assert.That(tree["TT"].Value, Is.EqualTo(a.TT));
            Assert.That(tree["A"].Value, Is.True);
        }
Ejemplo n.º 41
0
        static void Main(string[] args)
        {
            Console.WriteLine(">>>>:Thread Pool Sample:");
            bool W2K = false;
            // 允许线程池中运行最多 10 个线程
            int MaxCount = 10;
            // 新建 ManualResetEvent 对象并且初始化为无信号状态
            ManualResetEvent eventX = new ManualResetEvent(false);
            Console.WriteLine(">>>>:Queuing {0} items to Thread Pool", MaxCount);
            // 注意初始化 oAlpha 对象的 eventX 属性
            Alpha oAlpha = new Alpha(MaxCount);
            oAlpha.eventX = eventX;
            Console.WriteLine(">>>>:Queue to Thread Pool 0");
            try
            {
                // 将工作项装入线程池
                // 这里要用到 Windows 2000 以上版本才有的 API,所以可能出现 NotSupp ortException 异常
                ThreadPool.QueueUserWorkItem(new WaitCallback(oAlpha.Beta), new SomeState(0));
                W2K = true;
            }
            catch (NotSupportedException)
            {
                Console.WriteLine("These API's may fail when called on a non-Wind ows 2000 system.");
                W2K = false;
            }

            if (W2K) // 如果当前系统支持 ThreadPool 的方法.
            {
                for (int iItem = 1; iItem < MaxCount; iItem++)
                {
                    // 插入队列元素
                    Console.WriteLine("Queue to Thread Pool {0}", iItem);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(oAlpha.Beta), new SomeState(iItem));
                }
                Console.WriteLine("Waiting for Thread Pool to drain");
                // 等待事件的完成,即线程调用 ManualResetEvent.Set() 方法
                eventX.WaitOne(Timeout.Infinite, true);
                // WaitOne() 方法使调用它的线程等待直到 eventX.Set() 方法被调用
                Console.WriteLine("Thread Pool has been drained (Event fired)");
                Console.WriteLine();
                Console.WriteLine("Load across threads");
                foreach (object o in oAlpha.HashCount.Keys)
                {
                    Console.WriteLine("{0} {1}", o, oAlpha.HashCount[o]);
                }
            }
            Console.ReadLine();
        }
Ejemplo n.º 42
0
 // Возвратить логическое значение true, если значение 
 // переменной obj.Val окажется четным, 
 static bool IsEven(Alpha obj)
 { 
     if((obj.Val % 2) == 0) return true; 
     return false; 
 } 
Ejemplo n.º 43
0
 static Beta Changelt(Alpha obj) 
 { 
     return new Beta(obj.Val +2); 
 } 
 public void implement_fallback_none_fails()
 {
     var a = new Alpha();
     a.Implement<INiladicMethod>(FallbackBehavior.None);
 }
 public void live_blessed_object_causes_error_missing_property()
 {
     Alpha a = new Alpha();
     PropertyTree pt = PropertyTree.FromValue(a);
     Assert.That(() => (pt["XXX"].Value = 5), Throws.InvalidOperationException);
 }
 public void link_property_tree_to_object()
 {
     Alpha a = new Alpha();
     PropertyTree tree = PropertyTree.FromValue(a);
 }
        public void bind_template_primitive_types()
        {
            PropertyTreeReader pt = LoadContent("alpha.xml");
            Assume.That(pt.Read(), Is.True);
            var template = pt.Bind<ITemplate<Alpha>>();
            var a = new Alpha();
            template.Initialize(a);

            Assert.That(a.A, Is.True);
            Assert.That(a.AA.HasValue, Is.False);
            Assert.That(a.B, Is.EqualTo(0));
            Assert.That(a.BB.HasValue, Is.True);
            Assert.That(a.BB, Is.EqualTo(0));
            Assert.That(a.D, Is.EqualTo('g'));
            Assert.That(a.E, Is.EqualTo(DateTime.Parse("3/30/2011 1:50 AM")));
            Assert.That(a.F, Is.EqualTo(10.5000m));
            Assert.That(a.G, Is.EqualTo(10.5));
            Assert.That(a.H, Is.EqualTo(256));
            Assert.That(a.I, Is.EqualTo(1024));
            Assert.That(a.J, Is.EqualTo(102410241024));
            Assert.That(a.K, Is.EqualTo(-120));
            Assert.That(a.L, Is.EqualTo(float.NaN));
            Assert.That(a.M, Is.EqualTo("Carbonfrost F5 Project"));
            Assert.That(a.N, Is.EqualTo(65535));
            Assert.That(a.O, Is.EqualTo(6553620));
            Assert.That(a.P, Is.EqualTo(6553620655362));
            Assert.That(a.Q, Is.EqualTo(new Uri("http://carbonfrost.com")));
            Assert.That(a.R, Is.EqualTo(TimeSpan.Parse("4.12:0:30.5")));
            Assert.That(a.S, Is.EqualTo(new Guid("{BF972F0A-CB10-441B-9D25-3D6DEB9065D1}")));
            Assert.That(a.T, Is.EqualTo(DateTimeOffset.Parse("4/1/2011 12:11:01 AM -04:00")));
            Assert.That(a.U, Is.EqualTo(typeof(Glob)));
        }
Ejemplo n.º 48
0
 public static int Main(string[] args)
 {
     Console.WriteLine("Thread Pool Sample:");
     bool W2K = false;
     int MaxCount = 10;  // Allow a total of 10 threads in the pool
     // Mark the event as unsignaled.
     ManualResetEvent eventX = new ManualResetEvent(false);
     Console.WriteLine("Queuing {0} items to Thread Pool", MaxCount);
     Alpha oAlpha = new Alpha(MaxCount);  // Create the work items.
     // Make sure the work items have a reference to the signaling event.
     oAlpha.eventX = eventX;
     Console.WriteLine("Queue to Thread Pool 0");
     try
     {
         // Queue the work items, which has the added effect of checking
         // which OS is running.
         ThreadPool.QueueUserWorkItem(new WaitCallback(oAlpha.Beta),
         new SomeState(0));
         W2K = true;
     }
     catch (NotSupportedException)
     {
         Console.WriteLine("These API's may fail when called on a non-Windows 2000 system.");
         W2K = false;
     }
     if (W2K)  // If running on an OS which supports the ThreadPool methods.
     {
         for (int iItem=1;iItem < MaxCount;iItem++)
         {
             // Queue the work items:
             Console.WriteLine("Queue to Thread Pool {0}", iItem);
             ThreadPool.QueueUserWorkItem(new WaitCallback(oAlpha.Beta),new SomeState(iItem));
         }
         Console.WriteLine("Waiting for Thread Pool to drain");
         // The call to exventX.WaitOne sets the event to wait until
         // eventX.Set() occurs.
         // (See oAlpha.Beta).
         // Wait until event is fired, meaning eventX.Set() was called:
         eventX.WaitOne(Timeout.Infinite,true);
         // The WaitOne won't return until the event has been signaled.
         Console.WriteLine("Thread Pool has been drained (Event fired)");
         Console.WriteLine();
         Console.WriteLine("Load across threads");
         foreach(object o in oAlpha.HashCount.Keys)
         Console.WriteLine("{0} {1}", o, oAlpha.HashCount[o]);
     }
     return 0;
 }
 public Delta(Alpha alpha)
 {
 }
Ejemplo n.º 50
0
 public void Read(MpqFileStream stream)
 {
     stream.Position += 4;
     this.Name = stream.ReadString(256, true);
     this.Hash = StringHashHelper.HashItemName(this.Name);
     this.SNOActor = stream.ReadValueS32(); //260
     this.ItemType1 = stream.ReadValueS32(); //264
     this.Flags = stream.ReadValueS32(); //268
     this.I0 = stream.ReadValueS32(); //272
     this.ItemLevel = stream.ReadValueS32(); //276
     this.E0 = (eItem)stream.ReadValueS32(); //280
     this.I2 = stream.ReadValueS32(); //284
     this.RandomPropertiesCount = stream.ReadValueS32(); //288
     this.MaxSockets = stream.ReadValueS32(); //292
     this.MaxStackAmount = stream.ReadValueS32(); //296
     this.BaseGoldValue = stream.ReadValueS32(); //300
     this.I7 = stream.ReadValueS32(); //304
     this.RequiredLevel = stream.ReadValueS32(); //308
     this.DurabilityMin = stream.ReadValueS32(); //312
     this.DurabilityDelta = stream.ReadValueS32(); //316
     this.SNOBaseItem = stream.ReadValueS32(); //320
     this.SNOSet = stream.ReadValueS32(); //324
     this.SNOComponentTreasureClass = stream.ReadValueS32(); //328
     this.SNOComponentTreasureClassMagic = stream.ReadValueS32(); //332
     this.SNOComponentTreasureClassRare = stream.ReadValueS32(); //336
     this.SNORareNamePrefixStringList = stream.ReadValueS32(); //340
     this.SNORareNameSuffixStringList = stream.ReadValueS32(); //344
     this.I15 = new int[4]; //348
     for (int i = 0; i < 4; i++)
         this.I15[i] = stream.ReadValueS32();
     stream.Position += 88;
     this.WeaponDamageMin = stream.ReadValueF32(); //452
     this.WeaponDamageDelta = stream.ReadValueF32(); //456
     stream.Position += 84;
     this.ArmorValue = stream.ReadValueF32(); //544
     this.F3 = stream.ReadValueF32(); //548
     stream.Position += 168;
     this.AttacksPerSecond = stream.ReadValueF32(); //720
     stream.Position += 84;
     this.F4 = stream.ReadValueF32(); //808
     this.F5 = stream.ReadValueF32(); //812
     stream.Position += 100;
     this.SNOSkill0 = stream.ReadValueS32(); //916
     this.I11 = stream.ReadValueS32(); //920
     this.SNOSkill1 = stream.ReadValueS32(); //924
     this.I12 = stream.ReadValueS32(); //928
     this.SNOSkill2 = stream.ReadValueS32(); //932
     this.I13 = stream.ReadValueS32(); //936
     this.SNOSkill3 = stream.ReadValueS32(); //940
     this.I14 = stream.ReadValueS32(); //944
     stream.Position += 44;
     this.Attribute = new AttributeSpecifier[16];
     for (int i = 0; i < 16; i++)
         this.Attribute[i] = new AttributeSpecifier(stream);
     this.Quality = (ItemQuality)stream.ReadValueS32(); //1376
     this.RecipeToGrant = new int[10]; //1380
     for (int i = 0; i < 10; i++)
         this.RecipeToGrant[i] = stream.ReadValueS32();
     this.EnhancementToGrant = stream.ReadValueS32(); //1420
     this.LegendaryAffixFamily = new int[6];
     for (int i = 0; i < 6; i++)
         this.LegendaryAffixFamily[i] = stream.ReadValueS32(); //1424
     this.MaxAffixLevel = new int[6];
     for (int i = 0; i < 6; i++)
         this.MaxAffixLevel[i] = stream.ReadValueS32(); //1446
     this.Gem = (GemType)stream.ReadValueS32(); //1472
     this.I16 = stream.ReadValueS32(); //1476
     this.I17 = (Alpha)stream.ReadValueS32(); //1780
     stream.Position += 4;
 }
 public void implement_fallback_throw_should_throw()
 {
     var a = new Alpha();
     IMultipleMethods result = a.Implement<IMultipleMethods>(FallbackBehavior.ThrowException);
     Assert.That(result, Is.Not.Null);
     Assert.That(() => result.Baz(null), Throws.InstanceOf(typeof(NotImplementedException)));
 }
        public void bind_template_untyped_transition()
        {
            // The property return type ITemplate gets constructed as a
            // typed version
            PropertyTreeReader pt = LoadContent("iota-chi-3.xml");
            Assume.That(pt.Read(), Is.True);

            var template = pt.Bind<IotaChi>().Template;
            var a = new Alpha();
            template.Initialize(a);

            Assert.That(template, Is.InstanceOf<ITemplate<Alpha>>());
            Assert.That(a.I, Is.EqualTo(1024));
            Assert.That(a.J, Is.EqualTo(102410241024));
            Assert.That(a.K, Is.EqualTo(-120));
            Assert.That(a.L, Is.EqualTo(float.NaN));
        }
 public void try_implement_returns_null()
 {
     var a = new Alpha();
     INiladicMethod result = a.TryImplement<INiladicMethod>();
     Assert.That(result, Is.Null);
 }
Ejemplo n.º 54
0
    void VisibilityCanvasOnStart(Alpha alpha)
    {
        switch (alpha)
        {
            case Alpha.MaxAlpha:
                gameObject.GetComponent<G2_GraWKoloryInformationPanel>().InformationCanvas.GetComponent<CanvasGroup>().alpha = 1;
                gameObject.GetComponent<G2_GraWKoloryNavigation>().NavigationCanvas.GetComponent<CanvasGroup>().alpha = 1;
                break;
            case Alpha.MinAlpha:
                gameObject.GetComponent<G2_GraWKoloryInformationPanel>().InformationCanvas.GetComponent<CanvasGroup>().alpha = 0;
                gameObject.GetComponent<G2_GraWKoloryNavigation>().NavigationCanvas.GetComponent<CanvasGroup>().alpha = 0;
                break;

            default:
                gameObject.GetComponent<G2_GraWKoloryInformationPanel>().InformationCanvas.GetComponent<CanvasGroup>().alpha = 1;
                gameObject.GetComponent<G2_GraWKoloryNavigation>().NavigationCanvas.GetComponent<CanvasGroup>().alpha = 1;
                break;
        }

    }
 public void implement_fallback_default_returns_default()
 {
     var a = new Alpha();
     IMultipleMethods result = a.Implement<IMultipleMethods>(FallbackBehavior.CreateDefault);
     Assert.That(result, Is.Not.Null);
     Assert.That(result.Bar(false, null), Is.EqualTo(null));
     Assert.That(result.Baz(null), Is.EqualTo(0));
     Assert.That(result.Foo(0), Is.EqualTo(default(FileLocation)));
 }
 public void unlink_property_tree_from_blessed_object()
 {
     Alpha a = new Alpha();
     PropertyTree tree = PropertyTree.FromValue(a);
     tree.Unbless();
 }
Ejemplo n.º 57
0
    public override void OnInspectorGUI()
    {
        Emerald_Animal_AI self = (Emerald_Animal_AI)target;

        float thirdOfScreen = Screen.width/3-10;
        int sizeOfHideButtons = 18;

        EditorGUILayout.LabelField("Emerald - Animal AI System Editor", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Editor Options", EditorStyles.boldLabel);
        string showOrHide = "Show";
        if(showHelpOptions)
            showOrHide = "Hide";
        if(GUILayout.Button(showOrHide+ " Help Boxes", GUILayout.Width(thirdOfScreen*2), GUILayout.Height(sizeOfHideButtons)) )
        {
            showHelpOptions = !showHelpOptions;
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Animal Options", EditorStyles.boldLabel);

        editorAgression = (AgressionDropDown)self.aggression;
        editorAgression = (AgressionDropDown)EditorGUILayout.EnumPopup("Behavior Type", editorAgression);
        self.aggression = (int)editorAgression;

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("The Behavior Type determins whether your AI is a Wild or a Farm type animal. A Wild animal will flee when its flee tag is within its flee radius. A Farm animal will never flee and can have players near without being affected by them.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Animal Type Name", EditorStyles.miniLabel);
        self.animalNameType = EditorGUILayout.TextArea(self.animalNameType, GUILayout.MaxHeight(75));

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("The Animal Type helps with Emerald dynamically forming herds and packs based on your Animal Name Type. So, only animals with the same Animal Name Type will create herds or packs.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        editorPreyOrPredator = (PreyOrPredator)self.preyOrPredator;
        editorPreyOrPredator = (PreyOrPredator)EditorGUILayout.EnumPopup("Prey or Predator?", editorPreyOrPredator);
        self.preyOrPredator = (int)editorPreyOrPredator;

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("This allows you to choose if your animal is either Prey or Predator. If an animal is marked as Prey, a Predator will be able to chase and kill them, if the Predator size is less than or equal to their size.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        if (self.preyOrPredator == 1)
        {
            editorPreySize = (PreySize)self.preySize;
            editorPreySize = (PreySize)EditorGUILayout.EnumPopup("Prey Size", editorPreySize);
            self.preySize = (int)editorPreySize;

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("The Prey Size determins how big your Prey animal is. The Prey Size must match a Predator's Size in order for that predator to be able to hunt the prey.", MessageType.None, true);
            }
        }

        if (self.preyOrPredator == 2)
        {
            editorPredatorSize = (PredatorSize)self.predatorSize;
            editorPredatorSize = (PredatorSize)EditorGUILayout.EnumPopup("Predator Size", editorPredatorSize);
            self.predatorSize = (int)editorPredatorSize;

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("The Predator Size determins how big your Predator animal is. The Predator Size must be less than or equal to the Prey's Size in order for that predator to be able to hunt the prey.", MessageType.None, true);
            }

            EditorGUILayout.Space();

            self.attackTime = EditorGUILayout.Slider ("Attack Speed", (float)self.attackTime, 0.5f, 6.0f);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("Attack Speed controls how fast your animal can attack. Emerald calculates your animals animations to match your attack speed.", MessageType.None, true);
            }
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Herd Options", EditorStyles.boldLabel);

        EditorGUILayout.Space();

        self.autoGenerateAlpha = EditorGUILayout.Toggle ("Auto Generate Alpha?",self.autoGenerateAlpha);

        EditorGUILayout.Space();

        if (!self.autoGenerateAlpha)
        {
            editorAlpha = (Alpha)self.isAlphaOrNot;
            editorAlpha = (Alpha)EditorGUILayout.EnumPopup("Is this animal an Alpha?", editorAlpha);
            self.isAlphaOrNot = (int)editorAlpha;
        }

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("If Auto Generate Alpha is enabled, alphas will be generated automatically. There is a 1 in 5 chance of an animal being an alpha. If this option is disabled, you can customize which animals are alphas manually.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        self.maxPackSize = EditorGUILayout.IntSlider ("Max Pack Size", self.maxPackSize, 1, 10);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("Controls the max pack size for this animal, if they're generated to become an alpha.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        self.offSetHerdXMin = EditorGUILayout.Slider ("offset Herd X Min", (float)self.offSetHerdXMin, -30, -5);
        self.offSetHerdXMax = EditorGUILayout.Slider ("offset Herd X Max", (float)self.offSetHerdXMax, 5, 30);

        EditorGUILayout.Space();

        self.offSetHerdZMin = EditorGUILayout.Slider ("offset Herd Z Min", (float)self.offSetHerdZMin, -15, -5);
        self.offSetHerdZMax = EditorGUILayout.Slider ("offset Herd Z Max", (float)self.offSetHerdZMax, 5, 15);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("These control the Offset of how the aniaml's herds form. The bigger the distance, both positive and negative, the more separation.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        self.alphaWaitForHerd = EditorGUILayout.Toggle ("Alpha Waits for Herd?",self.alphaWaitForHerd);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("This toggles whether or not you want the alpha to wait for its herd if a member's distance from the alpha becomes too far away.", MessageType.None, true);
        }

        if (self.alphaWaitForHerd)
        {
            EditorGUILayout.Space();

            self.maxDistanceFromHerd = EditorGUILayout.IntSlider ("Max Distance From Herd", (int)self.maxDistanceFromHerd, 1, 100);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("This controls when the alpha will wait for its herd. This happens when this distance is met.", MessageType.None, true);
            }
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Health Options", EditorStyles.boldLabel);

        self.startingHealth = EditorGUILayout.FloatField("Starting Health", self.startingHealth);

        EditorGUILayout.Space();

        self.currentHealth = EditorGUILayout.FloatField("Current Health", self.currentHealth);

        EditorGUILayout.Space();

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("Here you can set your animal's health. When its health reaches 0, the animal will die and it will spawn a dead replacement.", MessageType.None, true);
        }

        if (self.preyOrPredator == 2)
        {
            self.attackDamage = EditorGUILayout.Slider ("Attack Damage", self.attackDamage, 0, 25.0f);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("Attack Damage calls the Damage function within Emerald. The amount set above is the damage the animal will do.", MessageType.None, true);
            }
        }

        EditorGUILayout.Space();

        bool deadObject  = !EditorUtility.IsPersistent (self);
        self.deadObject = (GameObject)EditorGUILayout.ObjectField ("Dead Object", self.deadObject, typeof(GameObject), deadObject);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("Here you can set your animal's dead GameObject replacement.", MessageType.None, true);
        }

        //Uncomment if you would like to add a hit effect (Ex: UFPS shake effect)
        /*
        EditorGUILayout.Space();

        bool hitEffect  = !EditorUtility.IsPersistent (self);
        self.hitEffect = (GameObject)EditorGUILayout.ObjectField ("Hit Effect", self.bloodEffect, typeof(GameObject), hitEffect);
        */

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Sound Options Options", EditorStyles.boldLabel);

        EditorGUILayout.Space();

        if (self.preyOrPredator == 2)
        {
            self.useAttackSound = EditorGUILayout.Toggle ("Use Attack Sound?",self.useAttackSound);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("The Attack Sound is the sound the animal will use when it attacks.", MessageType.None, true);
            }

            EditorGUILayout.Space();

            if (self.useAttackSound)
            {
                bool attackSound  = !EditorUtility.IsPersistent (self);
                self.attackSound = (AudioClip)EditorGUILayout.ObjectField ("Attack Sound", self.attackSound, typeof(AudioClip), attackSound);
            }
        }

        EditorGUILayout.Space();

        self.useHitSound = EditorGUILayout.Toggle ("Use Get Hit Sound?",self.useHitSound);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("The Hit Sound is the sound the animal will use when it receives damage.", MessageType.None, true);
        }

        if (self.useHitSound)
        {
            EditorGUILayout.Space();
            bool getHitSound  = !EditorUtility.IsPersistent (self);
            self.getHitSound = (AudioClip)EditorGUILayout.ObjectField ("Hit Sound", self.getHitSound, typeof(AudioClip), getHitSound);
        }

        EditorGUILayout.Space();

        if (self.aggression == 1)
        {
            self.playSoundOnFlee = EditorGUILayout.Toggle ("Play Flee Sound?",self.playSoundOnFlee);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("The Flee Sound is the sound the animal will use when it flees from a predator or player.", MessageType.None, true);
            }

            EditorGUILayout.Space();

            if (self.playSoundOnFlee)
            {
                bool fleeSound  = !EditorUtility.IsPersistent (self);
                self.fleeSound = (AudioClip)EditorGUILayout.ObjectField ("Flee Sound", self.fleeSound, typeof(AudioClip), fleeSound);
            }
        }

        EditorGUILayout.Space();

        self.useRunSound = EditorGUILayout.Toggle ("Use Get Run Sound?",self.useRunSound);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("The sound the animal uses when it runs.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        if (self.useRunSound)
        {
            bool runSound  = !EditorUtility.IsPersistent (self);
            self.runSound = (AudioClip)EditorGUILayout.ObjectField ("Run Sound", self.runSound, typeof(AudioClip), runSound);

            EditorGUILayout.Space();

            self.footStepSeconds = EditorGUILayout.Slider ("Footstep Seconds", (float)self.footStepSeconds, 0.1f, 1.0f);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("The Footstep Seconds controls the seconds in between each time the sound is playing.", MessageType.None, true);
            }
        }

        EditorGUILayout.Space();

        self.minSoundPitch = EditorGUILayout.Slider ("Min Sound Pitch", (float)self.minSoundPitch, 0.5f, 1.5f);
        self.maxSoundPitch = EditorGUILayout.Slider ("Max Sound Pitch", (float)self.maxSoundPitch, 0.5f, 1.5f);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("This controls the min and max sound pitch for the animal's AudioSource. This affects all sounds adding various pitches to each animal keeping them unique.", MessageType.None, true);
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Pathfinding Options", EditorStyles.boldLabel);

        //Hold
        //self.maxNumberOfActiveAnimals = EditorGUILayout.IntSlider ("Max Active Aniamls", self.maxNumberOfActiveAnimals, 1, 100);

        self.drawWaypoints = EditorGUILayout.Toggle ("Draw Waypoints?",self.drawWaypoints);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("Draw Waypoints determins if the AI will draw its current waypoint/destination. This can make it helpful for development/testing.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        self.drawPaths = EditorGUILayout.Toggle ("Draw Paths?",self.drawPaths);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("Draw Paths determins if the AI will draw its current path to its current destination. This can make it helpful for development/testing.", MessageType.None, true);
        }

        if (self.drawPaths)
        {
            EditorGUILayout.Space();

            self.pathWidth = EditorGUILayout.Slider ("Path Line Width", (float)self.pathWidth, 1.0f, 100.0f);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("Choose how wide you would like your Path Lines drawn.", MessageType.None, true);
            }

            EditorGUILayout.Space();

            self.lineYOffSet = EditorGUILayout.Slider ("Path Line Y Offset", (float)self.lineYOffSet, 0.0f, 5.0f);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("The Path Line Y Offset will offset your path line on the Y axis based on the amount used on the slider above. This is useful if the Path Line is too high or too low.", MessageType.None, true);
            }
        }

        if (self.drawPaths)
        {
            EditorGUILayout.Space();

            self.pathColor = EditorGUILayout.ColorField("Path Line Color", self.pathColor);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("Path Line Color allows you to customize what color you want the path lines to be.", MessageType.None, true);
            }

            EditorGUILayout.Space();

            bool pathMaterial  = !EditorUtility.IsPersistent (self);
            self.pathMaterial = (Material)EditorGUILayout.ObjectField ("Path Line Material", self.pathMaterial, typeof(Material), pathMaterial);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("Choose the material you want to be used for your Path Line. If no material is applied, a default one will be used. Note: The color of the default material is purple and can't be adjusted.", MessageType.None, true);
            }

        }

        EditorGUILayout.Space();

        /*
        self.enableDebugLogs = EditorGUILayout.Toggle ("Enable Debug Logs?",self.enableDebugLogs);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("Enable Debug Logs can be useful to help balance your ecosystem. When an initial hunt or flee is triggered, it tells what's happening by the predator or prey's name.", MessageType.None, true);
        }
        */

        EditorGUILayout.Space();

        self.alignAI = EditorGUILayout.Toggle ("Align AI?",self.alignAI);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("If Align AI is enabled, it will automatically, and smoothly, align AI to the slope of the terrain. This allows much more realistic results.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        self.updateSpeed = EditorGUILayout.Slider ("Update Speed", self.updateSpeed, 0.01f, 2.0f);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("Update Speed determines how often culling is checked. If an animal is culled, it will be disabled to increase performance. If an animal is visible, it will enable all components on that animal. The less often this option is updated, the more it increases performance, but animals may not react the second a player looks at them. So, it's best to balance this option with performance and playing quality.", MessageType.None, true);
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Range Options", EditorStyles.boldLabel);

        EditorGUILayout.Space();

        self.useVisualRadius = EditorGUILayout.Toggle ("Use Visual Radiuses?",self.useVisualRadius);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("Using Visual Radiuses will visually render the radiuses in the scene view. This makes it easy to see where your AI's Ranges are.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        self.stoppingDistance = EditorGUILayout.Slider ("Stopping Distance", self.stoppingDistance, 0.1f, 10.0f);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("The Stopping Distance determins the distance in which your AI will stop for its waypoint/destination.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        if (self.aggression == 1)
        {
            self.fleeRadius = EditorGUILayout.IntSlider ("Flee Trigger Radius", self.fleeRadius, 1, 100);

            EditorGUILayout.Space();

            self.fleeRadiusColor = EditorGUILayout.ColorField("Flee Radius Color", self.fleeRadiusColor);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("The Flee Trigger Radius is the radius in which the AI will be triggered to flee.", MessageType.None, true);
            }

            EditorGUILayout.Space();

            self.extraFleeSeconds = EditorGUILayout.Slider ("Extra Flee Seconds", (float)self.extraFleeSeconds, 0f, 10.0f);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("Extra Flee Seconds controls how many extra seconds the Animal AI will be in Flee Mode before it stops.", MessageType.None, true);
            }

            EditorGUILayout.Space();

            self.chaseSeconds = EditorGUILayout.IntSlider ("Chase Seconds", (int)self.chaseSeconds, 1, 60);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("Chase Seconds determines how long an animal can flee before being exhausted and switching to cooldown mode.", MessageType.None, true);
            }

            EditorGUILayout.Space();

            self.coolDownSeconds = EditorGUILayout.Slider ("Cool Down Seconds", self.coolDownSeconds, 0, 25);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("Cool Down Seconds controls how many seconds your animal will wait after they have reached their chase seconds. The animal will then return back to its statring position while in this mode.", MessageType.None, true);
            }
        }

        if (self.aggression == 3)
        {
            self.huntRadius = EditorGUILayout.IntSlider ("Hunt Trigger Radius", self.huntRadius, 1, 200);

            EditorGUILayout.Space();

            self.huntRadiusColor = EditorGUILayout.ColorField("Hunt Radius Color", self.huntRadiusColor);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("The Hunt Trigger Radius is the radius in which the AI will be triggered to hunt. This process is pause if the animal is within attacking distance.", MessageType.None, true);
            }

            self.huntSeconds = EditorGUILayout.Slider ("Hunt Seconds", self.huntSeconds, 1, 50);

            EditorGUILayout.Space();

            self.coolDownSeconds = EditorGUILayout.Slider ("Cool Down Seconds", self.coolDownSeconds, 0, 25);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("Cool Down Seconds controls how many seconds your animal will wait after they have reached their max Hunt Seconds. During the Cool Down phase, the animal will return back to its statring position. The seconds for this are rest if an animal receives damage.", MessageType.None, true);
            }
        }

        EditorGUILayout.Space();

        self.wanderRange = EditorGUILayout.IntSlider ("Wander Range", self.wanderRange, 1, 500);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("Wander Range controls the radius in which the animal will wander. It will not wander out of its Wander Range, unless it's fleeing.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        self.wanderRangeColor = EditorGUILayout.ColorField("Wander Range Color", self.wanderRangeColor);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("The Wander Range is a radius that the AI will wander in from its originally placed spot. It will not wander further than this radius.", MessageType.None, true);
        }

        if (self.aggression == 1)
        {
            EditorGUILayout.Space();

            self.freezeSecondsMin = EditorGUILayout.Slider ("Min Freeze Seconds", (float)self.freezeSecondsMin, 0.25f, 3.0f);
            self.freezeSecondsMax = EditorGUILayout.Slider ("Max Freeze Seconds", (float)self.freezeSecondsMax, 0.5f, 8.0f);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("This controls the min and max seconds it takes for the animals to react to a predator or player triggering the animal to flee.", MessageType.None, true);
            }

            /*
            EditorGUILayout.Space();
            self.fleeRange = EditorGUILayout.IntSlider ("Flee Range", self.fleeRange, 1, 100);
            self.fleeRangeColor = EditorGUILayout.ColorField("Flee Range Color", self.fleeRangeColor);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("The Flee Range is a radius that the AI will flee in from its current placed spot. It may wander further than this radius, if being chased.", MessageType.None, true);
            }
            */
        }

        EditorGUILayout.Space();

        self.grazeLengthMin = EditorGUILayout.IntSlider ("Graze Length Min", self.grazeLengthMin, 1, 100);
        self.grazeLengthMax = EditorGUILayout.IntSlider ("Graze Length Max", self.grazeLengthMax, 1, 100);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("The graze lengths are generated with the min and max values entered above. This also plays a role in how often the waypoints are changed. If the AI is unable to reach its waypoint within its generated graze length time, a new waypoint will be generated.", MessageType.None, true);
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Movement Options", EditorStyles.boldLabel);

        EditorGUILayout.Space();

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("Here you can adjust the speeds that your AI will use. This AI system uses a NavMeshAgent, which is applied automatically. These speeds will change the NavMeshAgent's speed when a AI goes into flee mode.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        self.walkSpeed = EditorGUILayout.Slider ("Walk Speed", (float)self.walkSpeed, 0.5f, 10.0f);
        self.runSpeed = EditorGUILayout.Slider ("Run Speed", (float)self.runSpeed, 3.0f, 15.0f);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("These control how fast the animals will walk and run.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        self.turnSpeed = EditorGUILayout.IntSlider ("Turn Speed", self.turnSpeed, 1, 2000);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("The Turn Speed determins how fast your AI will rotate to its waypoint/destination when a waypoint is generated.", MessageType.None, true);
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Animation Options", EditorStyles.boldLabel);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("Here you can setup your AI's animations. You simple type the name of the animation you'd like to use below and the system will use them for the selected animations.", MessageType.None, true);
        }

        EditorGUILayout.Space();

        self.useAnimations = EditorGUILayout.Toggle ("Use Animations?",self.useAnimations);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("If the animal does not use animations, animations can be disabled here. However, they will be disabled automatically if no animation component is found on the current model.", MessageType.None, true);
        }

        if (self.useAnimations)
        {

            EditorGUILayout.Space();

            bool idleAnimation  = !EditorUtility.IsPersistent (self);
            self.idleAnimation = (AnimationClip)EditorGUILayout.ObjectField ("Idle Animation", self.idleAnimation, typeof(AnimationClip), idleAnimation);

            if (self.preyOrPredator == 2)
            {
                EditorGUILayout.Space();

                bool idleBattleAnimation  = !EditorUtility.IsPersistent (self);
                self.idleBattleAnimation = (AnimationClip)EditorGUILayout.ObjectField ("Idle (Aggressive) Animation", self.idleBattleAnimation, typeof(AnimationClip), idleBattleAnimation);

                if (showHelpOptions == true)
                {
                    EditorGUILayout.HelpBox("If an animal doesn't have an aggressive idle animation, you can just use your basic idle animation.", MessageType.None, true);
                }
            }

            EditorGUILayout.Space();

            self.totalGrazeAnimations = EditorGUILayout.IntSlider ("Total Graze Animations", self.totalGrazeAnimations, 1, 3);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("Total Graze Animations determins how many graze animations your AI will use when wandering. These animations will be picked at random. These can also be Idle animations, if desired. There is a max of 3.", MessageType.None, true);
            }

            EditorGUILayout.Space();

            bool graze1Animation  = !EditorUtility.IsPersistent (self);
            self.graze1Animation = (AnimationClip)EditorGUILayout.ObjectField ("Graze 1 Animation", self.graze1Animation, typeof(AnimationClip), graze1Animation);

            if (self.totalGrazeAnimations == 2 || self.totalGrazeAnimations == 3)
            {
                bool graze2Animation  = !EditorUtility.IsPersistent (self);
                self.graze2Animation = (AnimationClip)EditorGUILayout.ObjectField ("Graze 2 Animation", self.graze2Animation, typeof(AnimationClip), graze2Animation);
            }

            if (self.totalGrazeAnimations == 3)
            {
                bool graze3Animation  = !EditorUtility.IsPersistent (self);
                self.graze3Animation = (AnimationClip)EditorGUILayout.ObjectField ("Graze 3 Animation", self.graze3Animation, typeof(AnimationClip), graze3Animation);
            }

            EditorGUILayout.Space();

            bool walkAnimation  = !EditorUtility.IsPersistent (self);
            self.walkAnimation = (AnimationClip)EditorGUILayout.ObjectField ("Walk Animation", self.walkAnimation, typeof(AnimationClip), walkAnimation);

            bool runAnimation  = !EditorUtility.IsPersistent (self);
            self.runAnimation = (AnimationClip)EditorGUILayout.ObjectField ("Run Animation", self.runAnimation, typeof(AnimationClip), runAnimation);

            //EditorGUILayout.LabelField("Death Animation Name", EditorStyles.miniLabel);
            //self.deathAnimationName = EditorGUILayout.TextArea(self.deathAnimationName, GUILayout.MaxHeight(75));

            EditorGUILayout.Space();

            bool hitAnimation  = !EditorUtility.IsPersistent (self);
            self.hitAnimation = (AnimationClip)EditorGUILayout.ObjectField ("Hit Animation", self.hitAnimation, typeof(AnimationClip), hitAnimation);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("The hit animation that is played when the animal receives damage.", MessageType.None, true);
            }

            EditorGUILayout.Space();

            if (self.preyOrPredator == 2)
            {
                self.useRunAttackAnimations = EditorGUILayout.Toggle ("Use Run Attack Animations?",self.useRunAttackAnimations);

                if (showHelpOptions == true)
                {
                    EditorGUILayout.HelpBox("If the animal has run attack animation, it can be set here. It will then be played when a predator is attacking a target while running.", MessageType.None, true);
                }
            }

            EditorGUILayout.Space();

            if (self.useRunAttackAnimations)
            {
                bool runAttackAnimation  = !EditorUtility.IsPersistent (self);
                self.runAttackAnimation = (AnimationClip)EditorGUILayout.ObjectField ("Run Attack Animation", self.runAttackAnimation, typeof(AnimationClip), runAttackAnimation);
            }

            EditorGUILayout.Space();

            if (self.preyOrPredator == 2)
            {
                self.totalAttackAnimations = EditorGUILayout.IntSlider ("Total Attack Animations", self.totalAttackAnimations, 1, 6);

                if (showHelpOptions == true)
                {
                    EditorGUILayout.HelpBox("Here you control how many attack animations your predator uses. There are a max of 6. Each will be used randomly when the animal is attacking.", MessageType.None, true);
                }

                EditorGUILayout.Space();

                bool attackAnimation1  = !EditorUtility.IsPersistent (self);
                self.attackAnimation1 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 1", self.attackAnimation1, typeof(AnimationClip), attackAnimation1);

                if (self.totalAttackAnimations == 2)
                {
                    bool attackAnimation2  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation2 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 2", self.attackAnimation2, typeof(AnimationClip), attackAnimation2);
                }

                if (self.totalAttackAnimations == 3)
                {
                    bool attackAnimation2  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation2 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 2", self.attackAnimation2, typeof(AnimationClip), attackAnimation2);

                    bool attackAnimation3  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation3 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 3", self.attackAnimation3, typeof(AnimationClip), attackAnimation3);
                }

                if (self.totalAttackAnimations == 4)
                {
                    bool attackAnimation2  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation2 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 2", self.attackAnimation2, typeof(AnimationClip), attackAnimation2);

                    bool attackAnimation3  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation3 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 3", self.attackAnimation3, typeof(AnimationClip), attackAnimation3);

                    bool attackAnimation4  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation4 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 4", self.attackAnimation4, typeof(AnimationClip), attackAnimation4);
                }

                if (self.totalAttackAnimations == 5)
                {
                    bool attackAnimation2  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation2 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 2", self.attackAnimation2, typeof(AnimationClip), attackAnimation2);

                    bool attackAnimation3  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation3 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 3", self.attackAnimation3, typeof(AnimationClip), attackAnimation3);

                    bool attackAnimation4  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation4 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 4", self.attackAnimation4, typeof(AnimationClip), attackAnimation4);

                    bool attackAnimation5  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation5 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 5", self.attackAnimation5, typeof(AnimationClip), attackAnimation5);
                }

                if (self.totalAttackAnimations == 6)
                {
                    bool attackAnimation2  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation2 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 2", self.attackAnimation2, typeof(AnimationClip), attackAnimation2);

                    bool attackAnimation3  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation3 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 3", self.attackAnimation3, typeof(AnimationClip), attackAnimation3);

                    bool attackAnimation4  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation4 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 4", self.attackAnimation4, typeof(AnimationClip), attackAnimation4);

                    bool attackAnimation5  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation5 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 5", self.attackAnimation5, typeof(AnimationClip), attackAnimation5);

                    bool attackAnimation6  = !EditorUtility.IsPersistent (self);
                    self.attackAnimation6 = (AnimationClip)EditorGUILayout.ObjectField ("Attack Animation 6", self.attackAnimation6, typeof(AnimationClip), attackAnimation6);
                }
            }
            EditorGUILayout.Space();

            self.walkAnimationSpeed = EditorGUILayout.Slider ("Walk Animation Speed", (float)self.walkAnimationSpeed, 0.5f, 2.0f);
            self.runAnimationSpeed = EditorGUILayout.Slider ("Run Animation Speed", (float)self.runAnimationSpeed, 0.5f, 2.0f);

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("These control the actual speed that the animations play.", MessageType.None, true);
            }
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Tag Options", EditorStyles.boldLabel);

        if (self.aggression == 1)
        {
            EditorGUILayout.LabelField("Flee Tag Name", EditorStyles.miniLabel);
            self.playerTagName = EditorGUILayout.TextArea(self.playerTagName, GUILayout.MaxHeight(75));

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("The Flee Tag is the tag that triggers the AI's to flee. This is usually your player's tag.", MessageType.None, true);
            }
        }

        EditorGUILayout.Space();

        if (self.preyOrPredator == 2)
        {
            EditorGUILayout.LabelField("Prey Tag Name", EditorStyles.miniLabel);
            self.preyTagName = EditorGUILayout.TextArea(self.preyTagName, GUILayout.MaxHeight(75));

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("The tag name of animals that are Prey.", MessageType.None, true);
            }
        }

        EditorGUILayout.Space();

        if (self.preyOrPredator == 1)
        {
            EditorGUILayout.LabelField("Predator Tag Name", EditorStyles.miniLabel);
            self.predatorTagName = EditorGUILayout.TextArea(self.predatorTagName, GUILayout.MaxHeight(75));

            if (showHelpOptions == true)
            {
                EditorGUILayout.HelpBox("The tag name of animals that are Predators. This will also cause prey animals to flee.", MessageType.None, true);
            }
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Effect Options", EditorStyles.boldLabel);

        EditorGUILayout.Space();

        self.useDustEffect = EditorGUILayout.Toggle ("Use Dust Effect?",self.useDustEffect);

        if (showHelpOptions == true)
        {
            EditorGUILayout.HelpBox("Use Dust Effect determins if your player uses a dust effect when running.", MessageType.None, true);
        }

        if (self.useDustEffect)
        {
            EditorGUILayout.Space();

            bool dustEffect = !EditorUtility.IsPersistent (self);
            self.dustEffect = (ParticleSystem)EditorGUILayout.ObjectField ("Dust Effect", self.dustEffect, typeof(ParticleSystem), dustEffect);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(self);
        }

        serializedObject.ApplyModifiedProperties ();
    }