本文整理汇总了C#中OTSprite.RotateTowards方法的典型用法代码示例。如果您正苦于以下问题:C# OTSprite.RotateTowards方法的具体用法?C# OTSprite.RotateTowards怎么用?C# OTSprite.RotateTowards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OTSprite
的用法示例。
在下文中一共展示了OTSprite.RotateTowards方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Attack
void Attack()
{
timeSinceLastShot = 0.0f;
//fire a player projectile towards an enemy ship
GameObject bullet = OT.CreateObject("PlayerCannonProjectile");
myProjectile = bullet.GetComponent<OTSprite>();
myProjectile.renderer.enabled = true;
// Pick a target, and fire at it
Vector2 target = Targets.PickRandomEnemyTarget().position;
//We don't want the slugs to be very accurate, so offset the x and y by between (-2,2)
float offsetX = Random.value*4.0f-2.0f;
float offsetY = Random.value*4.0f-2.0f;
target = new Vector2(target.x+offsetX,target.y+offsetY);
myProjectile.position = sprite.position;
myProjectile.RotateTowards(target);
//Assign the projectile its atributes.
PlayerCannonProjectile pcp = (PlayerCannonProjectile)myProjectile.GetComponent(typeof(PlayerCannonProjectile));
pcp.damage = damage;
pcp.speed = projectileSpeed;
pcp.isFlak = false;
pcp.target = target;
pcp.isFlakShell = false;
pcp.isSuperFlak = true;
pcp.shellFlightTime = 0.5f;
}
示例2: Attack
void Attack()
{
timeSinceLastShot = 0.0f;
//fire a player beam towards an enemy ship
GameObject beam = OT.CreateObject("PlayerBeam");
myProjectile = beam.GetComponent<OTSprite>();
myProjectile.renderer.enabled = false; //Beams appear after a short time in flight
// Pick a target, and fire at it
// TODO add target picking code for slug
Vector2 target = Targets.PickRandomEnemyTarget().position;
//We don't want the beams to be perfectly accurate, so offset the x and y by between (-1,1)
float offsetX = Random.value*2.0f-1.0f;
float offsetY = Random.value*2.0f-1.0f;
target = new Vector2(target.x+offsetX,target.y+offsetY);
myProjectile.position = sprite.position;
myProjectile.RotateTowards(target);
//Assign the projectile its atributes.
PlayerBeam pb = (PlayerBeam)myProjectile.GetComponent(typeof(PlayerBeam));
pb.damage = damage;
pb.maxFlightTime = flightTime;
pb.flightTime = 0.0f;
pb.isStun = true;
pb.stunDuration = stunDuration;
pb.isLaser = false;
}
示例3: Attack
void Attack()
{
//Determine if firing by picking a random number
if (Random.Range(0,101) <= shotCoefficient)
{
//Generate a projectile
GameObject bullet = OT.CreateObject("EnemyProjectile");
myProjectile = bullet.GetComponent<OTSprite>();
myProjectile.renderer.enabled = true;
// Pick a target, and fire at it
Vector2 target = Targets.PickRandomTargetFromAll().position;
myProjectile.position = sprite.position;
myProjectile.RotateTowards(target);
//Assign the projectile its atributes.
EnemyProjectile ep = (EnemyProjectile)myProjectile.GetComponent(typeof(EnemyProjectile));
ep.speed = projectileSpeed;
ep.damage = projectileDamage;
ep.attackType = attackType;
//Make shot unavailable
timeSinceLastShot = 0.0f;
}
}
示例4: Attack
void Attack()
{
shotInterval+= Time.deltaTime;
if (shotCount == 0) //Get a new target each burst
{
// Pick a target, and fire at it
target = Targets.PickRandomEnemyTarget().position;
//We don't want the slugs to be very accurate, so offset the x and y by between (-4,4)
float offsetX = Random.value*8.0f-4.0f;
float offsetY = Random.value*8.0f-4.0f;
target = new Vector2(target.x+offsetX,target.y+offsetY);
}
else //Give the burst some accuracy variance
{
float offsetX = Random.value*4.0f-2.0f;
float offsetY = Random.value*4.0f-2.0f;
target = new Vector2(target.x+offsetX,target.y+offsetY);
}
if (shotInterval > recoilTime)
{
//fire a player projectile towards an enemy ship
GameObject bullet = OT.CreateObject("PlayerCannonProjectile");
myProjectile = bullet.GetComponent<OTSprite>();
myProjectile.renderer.enabled = true;
myProjectile.position = sprite.position;
myProjectile.RotateTowards(target);
//Assign the projectile its atributes.
PlayerCannonProjectile pcp = (PlayerCannonProjectile)myProjectile.GetComponent(typeof(PlayerCannonProjectile));
pcp.damage = damage;
pcp.speed = projectileSpeed;
//increment the shotCount
shotCount++;
shotInterval = 0.0f;
}
if (shotCount >= burstCount)
{
timeSinceLastShot = 0.0f;
shotCount = 0;
}
}
示例5: Attack
void Attack()
{
//Determine if firing by picking a random number
if (Random.Range(0,101) <= shotCoefficient)
{
//This ship shoots 5 slugs almost at once, so set the shot coefficient to 100 to garauntee that
shotCoefficient = 100;
//Generate a projectile
GameObject bullet = OT.CreateObject("EnemyProjectile");
myProjectile = bullet.GetComponent<OTSprite>();
myProjectile.renderer.enabled = true;
// Pick a random target, and fire at it
// TODO add target picking code
float targetX = Random.value*90.0f-45.0f;
Vector2 target = new Vector2(targetX,-40.0f);
myProjectile.position = sprite.position;
myProjectile.RotateTowards(target);
//Assign the projectile its atributes.
EnemyProjectile ep = (EnemyProjectile)myProjectile.GetComponent(typeof(EnemyProjectile));
ep.speed = projectileSpeed;
ep.damage = projectileDamage;
ep.attackType = attackType;
shotCount++;
if (shotCount > 5)
{
shotCount = 1;
shotAvailable = false;
timeSinceLastShot = 0.0f;
shotCoefficient = 5;
}
}
}
示例6: BeamAttack
void BeamAttack()
{
//Determine if firing by picking a random number
if (Random.Range(0,101) <= shotCoefficient)
{
for (int i = 0; i<3;i++)
{
//Generate a projectile
GameObject bullet = OT.CreateObject("EnemyBeam");
myProjectile = bullet.GetComponent<OTSprite>();
myProjectile.renderer.enabled = false;
Vector2 target = Targets.PickRandomTargetFromAll().position;
myProjectile.position = sprite.position;
myProjectile.RotateTowards(target);
//Assign the projectile its atributes.
EnemyBeam ep = (EnemyBeam)myProjectile.GetComponent(typeof(EnemyBeam));
ep.damage = beamDamage;
ep.attackType = AttackType.Beam;
//Make shot unavailable
timeSinceLastBeamShot = 0.0f;
}
}
}
示例7: BombAttack
void BombAttack()
{
//Determine if firing by picking a random number
if (Random.Range(0,101) <= shotCoefficient)
{
for (int i = 0; i<3;i++)
{
//Generate a projectile
float offsetX = i*1.4f - 0.7f;
GameObject bullet = OT.CreateObject("EnemyProjectile");
myProjectile = bullet.GetComponent<OTSprite>();
myProjectile.renderer.enabled = true;
Vector2 target = new Vector2(sprite.position.x+offsetX,-50.0f);
myProjectile.position = new Vector2(sprite.position.x+offsetX,sprite.position.y-1.0f);
myProjectile.RotateTowards(target);
//Assign the projectile its atributes.
EnemyProjectile ep = (EnemyProjectile)myProjectile.GetComponent(typeof(EnemyProjectile));
ep.speed = projectileSpeed;
ep.damage = bombDamage;
ep.attackType = AttackType.Bomb;
//Make shot unavailable
timeSinceLastBombShot = 0.0f;
}
}
}
示例8: Attack
void Attack()
{
//Determine if firing by picking a random number
if (Random.Range(0,101) <= shotCoefficient)
{
if (attackType == AttackType.Slug)
{
//Generate a projectile
GameObject bullet = OT.CreateObject("EnemyProjectile");
myProjectile = bullet.GetComponent<OTSprite>();
myProjectile.renderer.enabled = true;
// Pick a target, and fire at it
// TODO add target picking code for slug
Vector2 target = GameObject.Find("City").GetComponent<OTSprite>().position;
myProjectile.position = sprite.position;
myProjectile.RotateTowards(target);
//Assign the projectile its atributes.
EnemyProjectile ep = (EnemyProjectile)myProjectile.GetComponent(typeof(EnemyProjectile));
ep.speed = projectileSpeed;
ep.damage = projectileDamage;
ep.attackType = attackType;
//Make shot unavailable
shotAvailable = false;
timeSinceLastShot = 0.0f;
}
else if (attackType == AttackType.Beam)
{
//Generate a projectile
GameObject beam = OT.CreateObject("EnemyBeam");
myProjectile = beam.GetComponent<OTSprite>();
myProjectile.renderer.enabled = false; //Beams don't get rendered until they are in flight for a little bit
// TODO add target picking code for beam
Vector2 target = Targets.PickRandomTargetFromAll().position;
myProjectile.position = sprite.position;
myProjectile.RotateTowards(target);
//Assign the projectile its atributes.
EnemyBeam eb = (EnemyBeam)myProjectile.GetComponent(typeof(EnemyBeam));
eb.damage = projectileDamage;
eb.attackType = attackType;
//Make shot unavailable
shotAvailable = false;
timeSinceLastShot = 0.0f;
}
else //bomber
{
//Generate a projectile... TODO: Create EnemyBomb
GameObject bullet = OT.CreateObject("EnemyProjectile");
myProjectile = bullet.GetComponent<OTSprite>();
myProjectile.renderer.enabled = true;
//Bombs drop straight down
Vector2 target = new Vector2(sprite.position.x,-50.0f);
myProjectile.position = sprite.position;
myProjectile.RotateTowards(target);
//Assign the projectile its atributes.
EnemyProjectile ep = (EnemyProjectile)myProjectile.GetComponent(typeof(EnemyProjectile));
ep.speed = projectileSpeed;
ep.damage = projectileDamage;
ep.attackType = attackType;
//Make shot unavailable
shotAvailable = false;
timeSinceLastShot = 0.0f;
}
}
}