コード例 #1
0
ファイル: FollowerBrain.cs プロジェクト: Anttifer/Jypeli
        /// <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));
                }
            }
        }
コード例 #2
0
ファイル: SoundEffect.cs プロジェクト: Anttifer/Jypeli
 private void InitPosition()
 {
     Position             = new DoubleMeter(0, 0, 0);
     posTimer             = new Timer();
     posTimer.Interval    = 0.01;
     posTimer.Timeout    += new Action(IncrementPosition);
     Position.UpperLimit += EffectPlayed;
 }
コード例 #3
0
 /// <summary>
 /// Alustaa uuden ajastinluokan.
 /// </summary>
 public Timer()
 {
     SecondCounter  = new DoubleMeter(0);
     Times          = new IntMeter(1);
     Times.MinValue = 1;
     Times.MaxValue = 1;
     Enabled        = false;
 }
コード例 #4
0
 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;
 }
コード例 #5
0
ファイル: MeterAddOperation.cs プロジェクト: Anttifer/Jypeli
        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);
        }