/// <summary> /// Luo aivot ja asettaa ne seuraamaan yhtä tai useampaa kohdetta. /// </summary> /// <param name="targets">Seurattavat oliot. Voit antaa olioiden lisäksi myös tageja.</param> public FollowerBrain(params object[] targets) : base() { ObjectsToFollow = new List <IGameObject>(); TagsToFollow = new List <string>(); DistanceToTarget = new DoubleMeter(double.PositiveInfinity, 0, double.PositiveInfinity); FollowComparer = CreateDistanceComparer(20); DistanceFar = double.PositiveInfinity; DistanceClose = 100.0; StopWhenTargetClose = false; FarBrain = Brain.None; if (targets == null) { return; } for (int i = 0; i < targets.Length; i++) { if (targets[i] is IGameObject) { ObjectsToFollow.Add((IGameObject)targets[i]); } else if (targets[i] is string) { TagsToFollow.Add((string)targets[i]); } else { throw new ArgumentException(string.Format("Target type not recognized: {0} ({1})", targets[i].ToString(), targets[i].GetType().Name)); } } }
private void InitPosition() { Position = new DoubleMeter(0, 0, 0); posTimer = new Timer(); posTimer.Interval = 0.01; posTimer.Timeout += new Action(IncrementPosition); Position.UpperLimit += EffectPlayed; }
/// <summary> /// Alustaa uuden ajastinluokan. /// </summary> public Timer() { SecondCounter = new DoubleMeter(0); Times = new IntMeter(1); Times.MinValue = 1; Times.MaxValue = 1; Enabled = false; }
private void InitPosition() { Position = new DoubleMeter(0, 0, Game.AudioOutput.GetDuration(handle)); posTimer = new Timer(); posTimer.Interval = 0.01; posTimer.Timeout += new Action(IncrementPosition); Position.UpperLimit += EffectPlayed; }
internal DoubleMeterAddOperation(DoubleMeter meter, double change, double seconds) { this.meter = meter; double dt = findDt(seconds); this.dx = dt * change / seconds; int times = (int)(seconds / dt); timer = new Timer(); timer.Times.LowerLimit += OnFinished; timer.Interval = dt; timer.Timeout += Tick; timer.Start(times); }