本文整理汇总了C#中Paddle类的典型用法代码示例。如果您正苦于以下问题:C# Paddle类的具体用法?C# Paddle怎么用?C# Paddle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Paddle类属于命名空间,在下文中一共展示了Paddle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:deyantodorov,项目名称:TelerikAcademy,代码行数:33,代码来源:Ball.cs
示例2: Start
void Start()
{
paddle = FindObjectOfType<Paddle>();
rigidbody2D = GetComponent<Rigidbody2D>();
audioSource = GetComponent<AudioSource>();
paddleToBallVector = this.transform.position - paddle.transform.position;
}
开发者ID:agalue,项目名称:BlockBreaker,代码行数:7,代码来源:Ball.cs
示例3: Start
private void Start()
{
paddle = GameObject.FindObjectOfType<Paddle>();
audioSource = GetComponent<AudioSource>();
offset = transform.position - paddle.transform.position;
print(offset.y);
}
开发者ID:nateman42,项目名称:Block-Breaker,代码行数:7,代码来源:Ball.cs
示例4: Start
void Start()
{
levelManager = GameObject.FindObjectOfType<LevelManager>();
ball = GameObject.FindObjectOfType<Ball>();
textLife = GameObject.FindObjectOfType<Text>();
paddle = GameObject.FindObjectOfType<Paddle>();
}
开发者ID:Qhoros,项目名称:Unity,代码行数:7,代码来源:LoseCollider.cs
示例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();
}
开发者ID:SurpriseTRex,项目名称:phreakout,代码行数:32,代码来源:BreakoutGame.cs
示例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);
}
开发者ID:whztt07,项目名称:DeltaEngine,代码行数:7,代码来源:PaddleTests.cs
示例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();
}
开发者ID:CodetopiaLLC,项目名称:ExamplesXNA4x,代码行数:33,代码来源:Game1.cs
示例8: Start
// Use this for initialization
void Start()
{
paddle = GameObject.FindObjectOfType<Paddle>();
paddleToBallVector = (this.transform.position) - (paddle.transform.position);
print (paddleToBallVector);
}
开发者ID:IMACH,项目名称:BlockBreaker,代码行数:8,代码来源:Ball.cs
示例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);
}
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:38,代码来源:TimedPaddleBehaviour.cs
示例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;
}
开发者ID:TylerDevers,项目名称:Block_Breaker,代码行数:10,代码来源:Ball.cs
示例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;
}
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:29,代码来源:DeflectorBehaviour.cs
示例12: Start
// Use this for initialization
void Start()
{
paddle = GameObject.FindObjectOfType<Paddle>();
paddleToBallVector = this.transform.position - paddle.transform.position;
//print (paddleToBallVector.y);
BallReset();
}
开发者ID:finian826,项目名称:Block-Buster,代码行数:9,代码来源:Ball.cs
示例13: BallReset
public void BallReset()
{
if (hasStarted){
hasStarted = false;
paddle = GameObject.FindObjectOfType<Paddle>();
this.transform.position = paddle.transform.position + paddleToBallVector;
}
}
开发者ID:finian826,项目名称:Block-Buster,代码行数:8,代码来源:Ball.cs
示例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);
}
开发者ID:onyxhat,项目名称:Unity_Course,代码行数:9,代码来源:Ball.cs
示例15: Start
// Use this for initialization
void Start()
{
paddle = GameObject.FindObjectOfType<Paddle>();
paddleToBallVector = this.transform.position - paddle.transform.position;
startGame = false;
//print(paddleToBallVector);
}
开发者ID:NachyoChez,项目名称:BookWork,代码行数:9,代码来源:Ball.cs
示例16: Start
void Start()
{
paddle = GameObject.FindObjectOfType<Paddle>();
paddleToBallVector = transform.position - paddle.transform.position;
sounds = GetComponents<AudioSource>();
Hit = sounds[0];
Bounce = sounds[1];
}
开发者ID:schan1992,项目名称:box,代码行数:8,代码来源:Ball.cs
示例17: Start
//private Vector2 tweak;
// Use this for initialization
void Start()
{
paddle = GameObject.FindObjectOfType<Paddle>();
paddleToBallVector = this.transform.position - paddle.transform.position;
//tweak = new Vector2(Random.Range(0f, 0.2f), Random.Range(0f, 0.2f));
}
开发者ID:Undead2k,项目名称:udemy_blockbreaker,代码行数:10,代码来源:ball.cs
示例18: Start
void Start()
{
rb = GetComponent<Rigidbody2D> ();
boingSound = GetComponent<AudioSource> ();
paddle = GameObject.FindObjectOfType<Paddle> ();
paddleToBallVector = transform.position - paddle.transform.position;
}
开发者ID:Punie,项目名称:BlockBreaker,代码行数:8,代码来源:Ball.cs
示例19: Start
// Use this for initialization
void Start()
{
paddle = GameObject.FindObjectOfType<Paddle>();
bonus = GameObject.FindObjectOfType<Bonus>();
paddleToBallVector = this.transform.position - paddle.transform.position;
booingAudio = GetComponent<AudioSource>();
SetNormalTail();
swapMaterial = gameObject.GetComponent<TrailRenderer>().materials[0];
}
开发者ID:Qhoros,项目名称:Unity,代码行数:10,代码来源:Ball.cs
示例20: Start
void Start()
{
TouchMonitor.Register(onTouch);
if (mode == Modes.Master) {
playerPaddle = rightPaddle;
remotePaddle = leftPaddle;
} else {
playerPaddle = leftPaddle;
remotePaddle = rightPaddle;
}
}
开发者ID:pyrobot,项目名称:plong,代码行数:11,代码来源:Controller.cs
注:本文中的Paddle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论