コード例 #1
0
        /// <summary>
        ///     Avoids the lapin.
        /// </summary>
        /// <param name="_lapinAgent">The _lapin agent.</param>
        /// <returns></returns>
        internal bool AvoidLapin(LapinAgent _lapinAgent)
        {
            var squareDistanceToLapin = SquareDistanceTo(_lapinAgent);

            if (squareDistanceToLapin < SQUARE_DISTANCE_MIN)
            {
                var diffX = (_lapinAgent.PosX - PosX) / Math.Sqrt(squareDistanceToLapin);
                var diffY = (_lapinAgent.PosY - PosY) / Math.Sqrt(squareDistanceToLapin);

                speedX = SpeedX - diffX / 4;
                speedY = SpeedY - diffY / 4;
                Normalize();
                return(true);
            }

            return(false);
        }
コード例 #2
0
        /// <summary>
        ///     Avoids the renard.
        /// </summary>
        /// <param name="_lapinAgent">The _lapin agent.</param>
        /// <returns></returns>
        internal bool AvoidRenard(LapinAgent _lapinAgent)
        {
            var squareDistanceToRenard = SquareDistanceTo(_lapinAgent);

            if (squareDistanceToRenard < SQUARE_DISTANCE_MIN)
            {
                Debug.WriteLine("dedans");
                var diffX = (_lapinAgent.PosX - PosX) / Math.Sqrt(squareDistanceToRenard);
                var diffY = (_lapinAgent.PosY - PosY) / Math.Sqrt(squareDistanceToRenard);

                speedX = SpeedX - diffX / 4;
                speedY = SpeedY - diffY / 4;
                Normalize();
                return(true);
            }

            return(false);
        }
コード例 #3
0
        /// <summary>
        ///     Nears the specified _lapin.
        /// </summary>
        /// <param name="_lapin">The _lapin.</param>
        /// <returns></returns>
        private bool Near(LapinAgent _lapin)
        {
            var squareDistance = SquareDistanceTo(_lapin);

            return(squareDistance < SQUARE_DISTANCE_MAX && squareDistance > SQUARE_DISTANCE_MIN);
        }
コード例 #4
0
 /// <summary>
 ///     Deletes the lapin agent.
 /// </summary>
 /// <param name="lapinList">The lapin list.</param>
 /// <param name="lapin">The lapin.</param>
 protected void deleteLapinAgent(LapinAgent[] lapinList, LapinAgent lapin)
 {
     lapinList.ToList().Remove(lapin);
 }