本文整理汇总了C#中Paddle类的典型用法代码示例。如果您正苦于以下问题:C# Paddle类的具体用法?C# Paddle怎么用?C# Paddle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Paddle类属于命名空间,在下文中一共展示了Paddle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveBall
public void MoveBall(Paddle playerOne, Paddle playerTwo)
{
Top += directionTop;
Left += directionLeft;
if (Top <= 1)
{
directionTop *= -1;
}
if (Left >= playerTwo.Left && Top >= playerTwo.Top && Top <= playerTwo.Top + playerTwo.Height)
{
directionLeft *= -1;
}
if (Top >= 399)
{
directionTop *= -1;
}
if (Left <= playerOne.Left + playerOne.Width && Top >= playerOne.Top && Top <= playerOne.Top + playerTwo.Height)
{
directionLeft *= -1;
}
if (Left == 499 || Left == 1)
{
directionLeft = 0;
directionTop = 0;
BallOutOfField = true;
}
}
示例2: Start
void Start()
{
paddle = FindObjectOfType<Paddle>();
rigidbody2D = GetComponent<Rigidbody2D>();
audioSource = GetComponent<AudioSource>();
paddleToBallVector = this.transform.position - paddle.transform.position;
}
示例3: Start
private void Start()
{
paddle = GameObject.FindObjectOfType<Paddle>();
audioSource = GetComponent<AudioSource>();
offset = transform.position - paddle.transform.position;
print(offset.y);
}
示例4: Start
void Start()
{
levelManager = GameObject.FindObjectOfType<LevelManager>();
ball = GameObject.FindObjectOfType<Ball>();
textLife = GameObject.FindObjectOfType<Text>();
paddle = GameObject.FindObjectOfType<Paddle>();
}
示例5: Start
void Start()
{
FutileParams fParams = new FutileParams(true, true, true, true);
fParams.AddResolutionLevel(1366, 1, 1, "");
fParams.origin = new Vector2(0.5f, 0.5f);
Futile.instance.Init(fParams);
Futile.atlasManager.LoadAtlas("Atlases/Breakout");
BreakoutBackground bg = new BreakoutBackground(1.4f, 1);
_player = new Paddle();
bricks = new List<Brick>();
Brick b1 = new Brick();
b1.x = -Futile.screen.halfWidth/2;
b1.y = -Futile.screen.halfHeight/2;
Brick b2 = new Brick();
b2.x = Futile.screen.halfWidth/2;
b2.y = -Futile.screen.halfHeight/2;
Brick b3 = new Brick();
b3.x = -Futile.screen.halfWidth / 2;
b3.y = Futile.screen.halfHeight / 2;
Brick b4 = new Brick();
b4.x = Futile.screen.halfWidth / 2;
b4.y = Futile.screen.halfHeight / 2;
bricks.Add(b1);
bricks.Add(b2);
bricks.Add(b3);
bricks.Add(b4);
_ball = new Ball();
}
示例6: AssertPaddleMovesLeftCorrectly
private void AssertPaddleMovesLeftCorrectly(Paddle paddle)
{
Assert.AreEqual(0.5f, paddle.Position.X);
AdvanceTimeAndUpdateEntities(0.1f);
Assert.Less(paddle.Position.X, 0.5f);
Assert.Greater(paddle.Position.Y, 0.75f);
}
示例7: InitGameObjects
// game-related init tasks
public void InitGameObjects()
{
// create an instance of our ball
m_ball = new Ball();
// set the size of the ball
m_ball.Width = 15.0f;
m_ball.Height = 15.0f;
// create 2 instances of our paddle
m_paddle1 = new Paddle();
m_paddle2 = new Paddle();
// set the size of the paddles
m_paddle1.Width = 15.0f;
m_paddle1.Height = 100.0f;
m_paddle2.Width = 15.0f;
m_paddle2.Height = 100.0f;
// map the digits in the image to actual numbers
m_ScoreRect = new Rectangle[10];
for (int i = 0; i < 10; i++)
{
m_ScoreRect[i] = new Rectangle(
i * 45, // X
0, // Y
45, // Width
75); // Height
}
ResetGame();
}
示例8: Start
// Use this for initialization
void Start()
{
paddle = GameObject.FindObjectOfType<Paddle>();
paddleToBallVector = (this.transform.position) - (paddle.transform.position);
print (paddleToBallVector);
}
示例9: BehaviourAdded
/// <summary>
/// sealed override, responsible for most of the bulk of the work of the TimedBehaviour.
/// </summary>
/// <param name="toPaddle"></param>
/// <param name="gamestate"></param>
public override sealed void BehaviourAdded(Paddle toPaddle, BCBlockGameState gamestate)
{
//call base implementation
base.BehaviourAdded(toPaddle, gamestate);
//check if we are SingleInstance. If so, that means that there can only be one instance at a time, which may not be surprising given the name.
if (SingleInstance())
{
//check for existing instances of our class. If found, add our delay time to them.
foreach (var iterate in (from p in toPaddle.Behaviours where p != this select p))
{
if (iterate.GetType() == GetType())
{
//if same type, change delay, and break from routine.
(iterate as TimedPaddleBehaviour).ChangeDelayTime(gamestate, _BehaviourTime, true);
//make sure this instance get's removed, too! we are redundant now.
gamestate.NextFrameCalls.Enqueue
(new BCBlockGameState.NextFrameStartup(() => toPaddle.Behaviours.Remove(this)));
return;
}
}
}
//if we are either not singleinstance or we are single instance but there are no existing behaviours of our type attached,
//do the stuff to add us.
DelayIdentifier = gamestate.DelayInvoke(_BehaviourTime, TimeDelayRoutine, new object[] {gamestate});
//if we have ability music, we play it now. Use the SoundManager's capacity to handle temporary music, which works rather well.
if (_AbilityMusic != "") BCBlockGameState.Soundman.PlayTemporaryMusic(_AbilityMusic, 1.0f, true);
//hook Death function. If the paddle dies, obviously the time delay will break out early, so we will need to stop the temporary music ourself.
toPaddle.OnDeath += new Func<Paddle, bool>(toPaddle_OnDeath);
//call abstract method for initialization.
TimedBehaviourInitialize(toPaddle, gamestate);
}
示例10: Start
//private Brick isBreakable;
// Use this for initialization
void Start () {
//game object allows me to find objects of type Paddle without setting Paddle as public.
//this prevents me from needing to drag the paddle script in as a component, they are now linked programatically
paddle= GameObject.FindObjectOfType<Paddle>();
paddleToBallVector = this.transform.position - paddle.transform.position;
}
示例11: getPowerup
public override bool getPowerup(BCBlockGameState gstate,Paddle onPaddle, GamePowerUp gpower)
{
if(onPaddle==null) return false;
//don't accept it.
//reject it with great prejudice.
//move the location temporarily.
PointF oldposition = gpower.Location;
SizeF oldsize = gpower.Size;
gpower.Location = PointF.Empty;
//draw to a temporary bitmap.
Bitmap drawtothis = new Bitmap(16, 16);
Graphics useg = Graphics.FromImage(drawtothis);
useg.Clear(Color.Transparent);
gpower.Draw(useg);
//reset position.
gpower.Location = oldposition;
gpower.Size = oldsize;
//get average.
var averagedpixel = Color.FromArgb((int)((from p in drawtothis.getPixels() select p.ToArgb()).Average()));
ExplosionEffect ee = new ExplosionEffect(gpower.Location, 72);
ee.ExplosionColor = averagedpixel;
ee.DamageBlocks = false;
ee.DamagePaddle = false;
gstate.Defer(() => gstate.GameObjects.AddLast(ee));
//move gpower to above the paddle, and invert the Y speed.
gpower.Location = new PointF(gpower.Location.X, onPaddle.BlockRectangle.Top - gpower.getRectangle().Height - 1);
gpower.Velocity = new PointF(gpower.Velocity.X, -Math.Abs(gpower.Velocity.Y)*1.1f);
return true;
}
示例12: Start
// Use this for initialization
void Start()
{
paddle = GameObject.FindObjectOfType<Paddle>();
paddleToBallVector = this.transform.position - paddle.transform.position;
//print (paddleToBallVector.y);
BallReset();
}
示例13: BallReset
public void BallReset()
{
if (hasStarted){
hasStarted = false;
paddle = GameObject.FindObjectOfType<Paddle>();
this.transform.position = paddle.transform.position + paddleToBallVector;
}
}
示例14: Start
// Use this for initialization
void Start()
{
//Filter load private resources
paddle = GameObject.FindObjectOfType<Paddle> ();
paddleToBallVector = this.transform.position - paddle.transform.position;
Debug.Log ("P2B Vector: " + paddleToBallVector);
}
示例15: Start
// Use this for initialization
void Start()
{
paddle = GameObject.FindObjectOfType<Paddle>();
paddleToBallVector = this.transform.position - paddle.transform.position;
startGame = false;
//print(paddleToBallVector);
}