本文整理汇总了C#中Sprite.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.GetType方法的具体用法?C# Sprite.GetType怎么用?C# Sprite.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.GetType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Collision
public override void Collision(Sprite otherSprite)
{
// Platform platform = (Platform)otherSprite;
System.Type type = otherSprite.GetType();
if (type.ToString().Equals("GameOne.Platform"))
{
Platform platform = (Platform)otherSprite;
if (velocity.Y > 0 && position.Y > platform.collisionRect.Top - this.spriteSheet.scale * (this.spriteSheet.currentSegment.frameSize.Y - this.collisionOffset.south) && this.collisionRect.Bottom + platform.collisionRect.Top > 2)
{
velocity.Y = -1;
onGround = true;
position.Y = platform.collisionRect.Top - spriteSheet.scale * (spriteSheet.currentSegment.frameSize.Y - collisionOffset.south) + 1;
}
}
else if (type.ToString().Equals("GameOne.VegetaPlayer") || type.ToString().Equals("GameOne.GokuPlayer"))
{
Random random = new Random();
position.X = (float) random.Next(1048);
position.Y = 0;
}
}
示例2: activate
public override void activate(Sprite collider)
{
if (collider.GetType() == typeof(Clyde))
{
clydeTouching = true;
}
else if (collider.GetType() == typeof(Bunny))
{
bunnyTouching = true;
}
if (bunnyTouching && clydeTouching && level.inventory.containsKey(color))
{
//we won
level.isComplete = true;
Console.Out.WriteLine("we won");
}
}
示例3: AddSprite
public void AddSprite(Sprite newSprite)
{
if (newSprite.GetType() == typeof(Poop))
{
((Poop)(newSprite)).sprite = contentManager.Load<Texture2D>(@"Sprites/Poop");
spriteList.Insert(0,newSprite);
}
else
{
spriteList.Insert(0,newSprite);
}
}
示例4: GetObjects
/// <summary>
/// Returns a list of object in an area specified by the search pattern.
/// SearchPattern.Touching -> you are in direct contact with an object
/// </summary>
public static IEnumerable<Sprite> GetObjects(Sprite origin, SearchPattern pattern)
{
var objectsFound = new List<Sprite>();
foreach (var obj in allObjects)
{
// Exclude the searching object from the list of found objects
if (obj.GetType().Name != origin.GetType().Name)
{
Point overlap = OverLap(origin.Rectangle, obj.Rectangle);
if (pattern == SearchPattern.Touching)
{
if (overlap.X <= tileSize / 4 && overlap.Y <= tileSize / 4)
{
objectsFound.Add(obj);
}
}
else if (pattern == SearchPattern.Right)
{
if (overlap.Y <= 0 && origin.Rectangle.Right < obj.Rectangle.Left && NoWallsBetween(origin, obj))
{
objectsFound.Add(obj);
}
}
else if (pattern == SearchPattern.Left && NoWallsBetween(origin, obj))
{
if (overlap.Y <= 0 && origin.Rectangle.Left > obj.Rectangle.Right && NoWallsBetween(origin, obj))
{
objectsFound.Add(obj);
}
}
else if (pattern == SearchPattern.Up)
{
if (overlap.X <= 0 && origin.Rectangle.Top > obj.Rectangle.Bottom && NoWallsBetween(origin, obj))
{
objectsFound.Add(obj);
}
}
else if (pattern == SearchPattern.Down)
{
if (overlap.X <= 0 && origin.Rectangle.Bottom < obj.Rectangle.Top && NoWallsBetween(origin, obj))
{
objectsFound.Add(obj);
}
}
}
}
return objectsFound;
}
示例5: init
//Warning: this script can only run once, or big trouble will comes.
public void init(int amount,List<Skill> skills)
{
Sprite tempType = new Sprite();
tempType = Resources.Load("null", tempType.GetType()) as Sprite;
if (!tempType)
Debug.Log("Load null Failed.");
skill = new skill_info[amount];
for (int i = 0; i < amount; i++)
{
skill[i].skillid = i;
skill[i].skill_script = skills[i];
skill[i].skillicon = tempType;
}
Invoke("NameUpdate", 1.0f);
}
示例6: Collision
/*
* Called when this sprite has collided with something else.
*/
public override void Collision(Sprite otherSprite)
{
// Platform platform = (Platform)otherSprite;
System.Type type = otherSprite.GetType();
if (type.ToString().Equals("GameOne.Platform"))
{
Platform platform = (Platform)otherSprite;
if (velocity.Y > 0 && position.Y > platform.collisionRect.Top - this.spriteSheet.scale * (this.spriteSheet.currentSegment.frameSize.Y - this.collisionOffset.south) && this.collisionRect.Bottom + platform.collisionRect.Top > 2)
{
velocity.Y = -1;
onGround = true;
position.Y = platform.collisionRect.Top - spriteSheet.scale * (spriteSheet.currentSegment.frameSize.Y - collisionOffset.south) + 1;
}
}
else if (type.ToString().Equals("GameOne.Gohan"))
{
currentPoints++;
}
else if (type.ToString().Equals("GameOne.Frieza"))
{
if(isSS){
cancelSS = true;
currentPoints += 2;
}
else if (currentPoints > 0)
{
currentPoints--;
}
}
}
示例7: allNonSpriteSheet
private bool allNonSpriteSheet(Sprite spr)
{
return spr.GetType() != typeof(SpriteSheet);
}
示例8: Collision
/*
* Called when this sprite has collided with something else.
*/
public override void Collision(Sprite otherSprite)
{
if (otherSprite.GetType().ToString().Equals("GameOne.Enemy"))
{
position.X = 0;
position.Y = 645 - collisionOffset.south;
reverseGravity = false;
}
if (!reverseGravity)
CollisionNoReverseGravity(otherSprite);
else
CollisionReverseGravity(otherSprite);
}
示例9: CollisionReverseGravity
private void CollisionReverseGravity(Sprite otherSprite)
{
Boolean myFlag = false;
if (otherSprite.GetType().ToString().Equals("GameOne.Platform") || otherSprite.GetType().ToString().Equals("GameOne.TronPlatform"))
{
if (collisionRect.Right <= (otherSprite.collisionRect.Left + 5))
{
position.X += -5f;
velocity.X += -1f;
onGround = false;
myFlag = true;
}
if (collisionRect.Left >= (otherSprite.collisionRect.Right - 5))
{
position.X += 5f;
velocity.X += 1f;
onGround = false;
myFlag = true;
}
if (collisionRect.Bottom <= (otherSprite.collisionRect.Top + 50) && myFlag == false && velocity.Y > 0f)
{
velocity.Y = 0f;
onGround = false;
myFlag = true;
}
if (collisionRect.Top + 50 >= otherSprite.collisionRect.Bottom && velocity.Y <= 0f && myFlag == false)
{
velocity.Y = 0f;
onGround = true;
}
}
}
示例10: LoadSprite
/** 提取指定的路径的sprite */
public static Sprite LoadSprite(string vResPath)
{
Sprite s = new Sprite();
Sprite vSprite = Resources.Load(vResPath , s.GetType() ) as Sprite;
return vSprite;
}
示例11: IsAwayFromObjects
private static bool IsAwayFromObjects(Sprite origin)
{
foreach (Sprite obj in allObjects)
{
if (obj is ILiving)
{
if (!(obj as ILiving).IsAlive)
{
continue;
}
}
if (obj.GetType().Name != origin.GetType().Name)
{
Point overlap = OverLap(origin.Rectangle, obj.Rectangle);
if (overlap.X <= 0 && overlap.Y <= 0)
{
return false;
}
}
}
return true;
}