Esempio n. 1
0
        /// <summary>
        /// Fire a bullet in the shape of a line that instantly hits the target.
        /// </summary>
        protected void FireHitScan()
        {
            Raycast   ray = new Raycast(CurrentPlayer.Position, CurrentPlayer.MoveTarget, 1024.0);
            RayResult res = CurrentPlayer.CurrentGame.FindEnemyOnRay(ray);

            if (res.Hit != null)
            {
                if (res.Hit is Enemy)
                {
                    res.Hit.TakeDamage(CurrentPlayer.EquippedTool.Damage);
                }
            }
        }
Esempio n. 2
0
        public RayResult FindEnemyOnRay(Raycast ray)
        {
            RayResult res = new RayResult();

            foreach (Enemy e in Enemies)
            {
                res = ray.Intersects(e);
                if (res.Hit != null)
                {
                    Console.WriteLine(res.Hit.ToString());
                    return(res);
                }
            }
            Console.WriteLine("Pos: " + res.Position.ToString());
            Console.WriteLine("Hit: null");
            return(res);
        }