RayCollision() public method

public RayCollision ( Vector3 startPosition, Vector3 rayDirection, float distance, int searchGranularity, Vector3 &hitPoint, Vector3 &buildPoint ) : bool
startPosition Vector3
rayDirection Vector3
distance float
searchGranularity int
hitPoint Vector3
buildPoint Vector3
return bool
Beispiel #1
0
        public void RenderPlayerNames(GraphicsDevice graphicsDevice)
        {
            // If we don't have _P, grab it from the current gameInstance.
            // We can't do this in the constructor because we are created in the property bag's constructor!
            if (_P == null)
            {
                _P = gameInstance.propertyBag;
            }

            foreach (Player p in _P.playerList.Values)
            {
                if (p.Alive && p.ID != _P.PlayerContainer.PlayerMyId)
                {
                    // Figure out what text we should draw on the player - only for teammates and nearby enemies
                    string playerText   = "";
                    bool   continueDraw = false;
                    if (p.ID != _P.PlayerContainer.PlayerMyId && p.Team == _P.PlayerContainer.PlayerTeam)
                    {
                        continueDraw = true;
                    }
                    else
                    {
                        Vector3 diff = (p.Position - _P.PlayerContainer.PlayerPosition);
                        float   len  = diff.Length();
                        diff.Normalize();
                        if (len <= 15)
                        {
                            Vector3 hit   = Vector3.Zero;
                            Vector3 build = Vector3.Zero;
                            blockEngine.RayCollision(_P.PlayerContainer.PlayerPosition + new Vector3(0f, 0.1f, 0f), diff, len, 25, ref hit, ref build);
                            if (hit == Vector3.Zero) //Why is this reversed?
                            {
                                continueDraw = true;
                            }
                        }
                    }
                    if (continueDraw)//p.ID != _P.playerMyId && p.Team == _P.playerTeam)
                    {
                        playerText = p.Handle;
                        if (p.Ping > 0)
                        {
                            playerText = "*** " + playerText + " ***";
                        }

                        p.SpriteModel.DrawText(_P.PlayerContainer.PlayerCamera.ViewMatrix,
                                               _P.PlayerContainer.PlayerCamera.ProjectionMatrix,
                                               p.Position - Vector3.UnitY * 1.5f,
                                               playerText, p.Team == PlayerTeam.Blue ? _P.blue : _P.red);//Defines.IM_BLUE : Defines.IM_RED);
                    }
                }
            }
        }
Beispiel #2
0
        // Returns true if the player is able to use a bank right now.
        public bool AtBankTerminal()
        {
            // Figure out what we're looking at.
            Vector3 hitPoint   = Vector3.Zero;
            Vector3 buildPoint = Vector3.Zero;

            if (!blockEngine.RayCollision(playerPosition, playerCamera.GetLookVector(), 2.5f, 25, ref hitPoint, ref buildPoint))
            {
                return(false);
            }

            // If it's a valid bank object, we're good!
            BlockType blockType = blockEngine.BlockAtPoint(hitPoint);

            if (blockType == BlockType.BankRed && playerTeam == PlayerTeam.Red)
            {
                return(true);
            }
            if (blockType == BlockType.BankBlue && playerTeam == PlayerTeam.Blue)
            {
                return(true);
            }
            return(false);
        }