本文整理汇总了C#中Ball类的典型用法代码示例。如果您正苦于以下问题:C# Ball类的具体用法?C# Ball怎么用?C# Ball使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ball类属于命名空间,在下文中一共展示了Ball类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerEnter
void OnTriggerEnter(Collider c)
{
if(!activated)
{
ball = c.gameObject.GetComponent<Ball>();
timer = timerLimit;
activate();
//get the GrameObject and Component for the GridManager
GameObject grid = GameObject.Find("GridManager");
GridManager manager = grid.GetComponent<GridManager>();
//cast a ray from the camera, through the powerup, to the Grid-Plane
Ray r = new Ray(Camera.main.transform.localPosition, transform.localPosition - Camera.main.transform.localPosition);
Plane p = new Plane(new Vector3(0, 0, -1), grid.transform.localPosition);
float f;
p.Raycast(r, out f);
//convert the ray-plane intersection into grid coordinates
int gridHalfWidth = (int)(manager.gridWidth * manager.cubeXOffset / 2);
int gridHalfHeight = (int)(manager.gridHeight * manager.cubeYOffset / 2);
int gridPosX = (int)(((r.direction * f).x + gridHalfWidth) / manager.cubeXOffset);
int gridPosY = manager.gridHeight - (int)(((r.direction * f).y + gridHalfHeight) / manager.cubeYOffset);
//send a grid pulse from this location
manager.gridPulseFromLocation(gridPosX, gridPosY);
//Setting visibility to false, powerup is destroyed only after its time is over.
gameObject.renderer.enabled = false;
}
}
示例2: Awake
public void Awake()
{
if (ball == null)
{
ball = (Ball)target;
}
}
示例3: Start
void Start()
{
Player1Score = 0;
Player2Score = 0;
ball = FindObjectOfType<Ball>();
}
示例4: Action
public void Action(Team myTeam, Team enemyTeam, Ball ball, MatchInfo matchInfo)
{
var pl1 = myTeam.Players.First(pl => pl.PlayerType == PlayerType.RightDefender);
myTeam.DevMessage = string.Format("speed {0}", pl1.Velocity.Length);
if (maxReached)
{
if (pl1.Velocity.Length > 0.05)
{
pl1.ActionWait();
return;
}
myTeam.DevMessage += "\r\n0.05 minReached";
maxReached = false;
point = pl1.Position.X < Field.Borders.Center.X ? Field.EnemyGoal : Field.MyGoal;
}
if (pl1.Velocity.Length > 3 * 0.95)
{
myTeam.DevMessage += "\r\n0.95 maxReached";
maxReached = true;
prevVelocity = 0;
pl1.ActionWait();
}
else
{
pl1.ActionGo(point);
prevVelocity = pl1.Velocity.Length;
}
}
示例5: Walls
public Walls(World world, Rectangle screenBounds, Ball ball, Paddle paddle)
{
_world = world;
_screenBounds = screenBounds;
_ball = ball;
_paddle = paddle;
}
示例6: Frame
public Frame(int frameNumber, Ball ball1, Ball ball2, Ball ball3)
{
this.FrameNumber = frameNumber;
this.Ball_1 = ball1;
this.Ball_2 = ball2;
this.Ball_3 = ball3;
}
示例7: BallHit
public override void BallHit(Ball _BH)
{
//Als de bal door het goal gaat; verhoog de score en aantal goals.
GameObject.Find("_ScoreManager").GetComponent<ScoreCounter>().scoreToAdd -= 1000f;
GameObject.Find("_GoalManager").GetComponent<GoalCounter>().goalToAddRobot += 1f;
base.BallHit(_BH);
}
示例8: HitLocation
public string HitLocation(Ball ball)
{
string _location = "noHit";
//treffer von unten
if (ball.Bottom > this._Bottom)
{
_location = "bottom";
}
//treffer von oben
else if (ball.Top < this._Top )
{
_location = "top";
}
//treffer von links
else if (ball.Left < this._Left)
{
_location = "left";
}
//treffer von rechts
else if (ball.Right > this._Right)
{
_location = "right";
}
return _location;
}
示例9: Pitch
public Pitch(Team my, Team enemy, Ball ball, MatchInfo info)
{
My = my;
Enemy = enemy;
Ball = ball;
Info = info;
}
示例10: BuildInitialFloors
public void BuildInitialFloors()
{
ball = GameObject.FindObjectOfType<Ball>();
RemovePowerUps(); // remove any previous power ups
var floors = GameObject.FindGameObjectsWithTag("floor");
for (var i = 0; i < floors.Length; i++)
{
Destroy(floors[i]);
}
var firstFloor = GameObject.Instantiate(floor);
var size = Random.Range(3.5f, 5.0f);
firstFloor.transform.localScale = new Vector3(size, 1.0f, size) * aspect;
firstFloor.transform.position = new Vector3(0, 0, 0);
firstFloor.transform.rotation = Quaternion.Euler(new Vector3(0, 90, 0));
lastScale = firstFloor.transform.localScale;
lastPosition = firstFloor.transform.position;
for (var i = 0; i < 30; i++)
{ GetNewFloor(); }
ball = GameObject.FindObjectOfType<Ball>();
}
示例11: TestIntersect1pxOverlapBot
public void TestIntersect1pxOverlapBot()
{
//Preconfig
Vector position1 = new Vector(0f, 50f);
Vector target1 = new Vector(50f, 50f);
int radius2 = 20;
Vector center2 = new Vector(20, 49);
Vector ballSpeed = new Vector(0, -5);
Vector hitPoint;
bool isIntersec = false;
//Creation
Line parent = new Line();
Ball ball = new Ball();
BoundingContainer bCont = new BoundingContainer(parent);
BoundingContainer bCont2 = new BoundingContainer(ball);
BoundingLine bL1 = new BoundingLine(position1, target1);
BoundingCircle bC2 = new BoundingCircle(radius2, center2);
bCont.AddBoundingBox(bL1);
bCont2.AddBoundingBox(bC2);
ball.Velocity = ballSpeed;
parent.Location = (new Vector(0, 0));
//Operation
isIntersec = bC2.Intersect(bL1, out hitPoint);
//Assertion
Assert.IsTrue(isIntersec);
Assert.AreEqual(new Vector(40,50), hitPoint);
}
示例12: Awake
public void Awake()
{
_spriteStates = new Dictionary<GoalkeeperState, Vector3>();
_random = new SystemRandom(DateTime.Now.Millisecond);
// Get the transform and renderer;
_transform = GetComponent<Transform>();
_renderer = GetComponent<SpriteRenderer>();
// Get the zones.
_leftZone = GameObject.Find("Left-Zone").GetComponent<GoalZone>();
_centerZone = GameObject.Find("Center-Zone").GetComponent<GoalZone>();
_rightZone = GameObject.Find("Right-Zone").GetComponent<GoalZone>();
// Get the ball.
_ball = GameObject.Find("Ball").GetComponent<Ball>();
// Initialize all sprite states.
_spriteStates.Add(GoalkeeperState.Playing, new Vector3(0, 0, 0));
_spriteStates.Add(GoalkeeperState.CatchLeft, new Vector3(-4, 0, 0));
_spriteStates.Add(GoalkeeperState.CatchRight, new Vector3(4, 0, 0));
_spriteStates.Add(GoalkeeperState.CatchCenter, new Vector3(0, 0, 0));
_spriteStates.Add(GoalkeeperState.MissLeft, new Vector3(-4, 0, 0));
_spriteStates.Add(GoalkeeperState.MissCenter, new Vector3(0, 0, 0));
_spriteStates.Add(GoalkeeperState.MissRight, new Vector3(4, 0, 0));
// Set the default state.
SetGoalkeeperState(GoalkeeperState.Playing);
}
示例13: ChooseDirection
public static Vector ChooseDirection(Player player, Ball ball)
{
var k1 = Line.K0(ball.Position, Field.MyGoal.Top);
var k2 = Line.K0(ball.Position, Field.MyGoal.Bottom);
var kball = ball.Velocity.Y / ball.Velocity.X;
var lineball = Line.One(ball.Position, ball.Position + ball.Velocity);
if ( ball.Owner == null
&& lineball.K >= Math.Min(k1, k2)
&& lineball.K <= Math.Max(k1, k2))
{
var nball = Line.Normal(lineball, player.Position);
var intpos = Line.Cross(lineball, nball);
if (Field.Borders.Contains(intpos)) return intpos;
return Line.Cross(lineball, Line.One(Field.MyGoal.Top, Field.MyGoal.Bottom));
}
var line = Line.One(ball.Position, Field.MyGoal.Center);
var n1 = Line.Normal(line, Field.MyGoal.Top);
var n2 = Line.Normal(line, Field.MyGoal.Bottom);
var a = Line.Cross(line, n1);
var b = Line.Cross(line, n2);
if (ball.GetDistanceTo(a) <= ball.GetDistanceTo(b))
return a;
return b;
}
示例14: AssistedShotVector
public Vector3 AssistedShotVector (Ball ball, Vector3 intendedDirectionNormalized)
{
Vector3 ballPos = ball.transform.position;
Vector3 leftPosDir = (leftPos.position - ballPos).normalized;
Vector3 rightPosDir = (rightPos.position - ballPos).normalized;
float eulerSwingY = Quaternion.LookRotation (intendedDirectionNormalized, Vector3.forward).eulerAngles.y;
float eulerLeftY = Quaternion.LookRotation (leftPosDir, Vector3.forward).eulerAngles.y;
float eulerRightY = Quaternion.LookRotation (rightPosDir, Vector3.forward).eulerAngles.y;
//Workaround to be able to compare angles
eulerSwingY = eulerSwingY < 180 ? eulerSwingY + 360 : eulerSwingY;
eulerLeftY = eulerLeftY < 180 ? eulerLeftY + 360 : eulerLeftY;
eulerRightY = eulerRightY < 180 ? eulerRightY + 360 : eulerRightY;
if (eulerSwingY < eulerRightY && eulerSwingY > eulerLeftY) {
} else if (eulerSwingY >= eulerRightY) {
eulerSwingY = Mathf.Lerp(eulerSwingY, eulerRightY, assistanceByDeviation.Evaluate(Mathf.Abs(eulerSwingY - eulerRightY)));
} else if (eulerSwingY <= eulerLeftY) {
eulerSwingY = Mathf.Lerp(eulerSwingY, eulerLeftY, assistanceByDeviation.Evaluate(Mathf.Abs(eulerSwingY - eulerLeftY)));
}
ball.rotationObject.eulerAngles = new Vector3(0, eulerSwingY, 0);
return ball.rotationObject.forward;
}
示例15: CheckCollision
private void CheckCollision(Ball b, List<Obstacle> ObsFrame)
{
while (true)
{
}
}