本文整理汇总了C#中GameObject.AddScript方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.AddScript方法的具体用法?C# GameObject.AddScript怎么用?C# GameObject.AddScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObject
的用法示例。
在下文中一共展示了GameObject.AddScript方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGuardGO
public static GameObject CreateGuardGO(ContentManager content, GraphicsDevice gd, List<Vector2> points)
{
if (guardTexture == null)
{
guardTexture = content.Load<Texture2D>("Guard");
}
GameObject guard = new GameObject();
guard.AddTransform();
guard.AddAnimation(guardTexture, new Vector2(20f, 34f));
guard.AddScript(new GuardScript(guard, points));
guard.Animation.AddAnimation("Idle", 1, 1);
guard.Animation.AddAnimation("Run", 0, 4);
guard.AddDynamicRigidBody(new Vector2(20f, 34f));
guard.Animation.Play("Idle");
guard.AddRenderer(gd, SpriteTransparency.Transparent);
return guard;
}
示例2: CreateShankGO
public static GameObject CreateShankGO(ContentManager content, GraphicsDevice gd, PlayerScript playerScript)
{
if (shankTexture == null)
{
shankTexture = content.Load<Texture2D>("Pickups/Shank");
}
GameObject shank = new GameObject();
shank.AddTransform();
shank.AddStaticSprite(shankTexture);
shank.AddRenderer(gd, SpriteTransparency.Transparent);
shank.AddDynamicRigidBody(new Vector2(10f, 12f));
shank.RigidBody.Body.CollidesWith = CollisionCats.WorldCategory;
ShankScript script = new ShankScript(shank, playerScript);
shank.AddScript(new ShankScript (shank, playerScript));
shank.AddTrigger(new Vector2(10f, 12f));
shank.Trigger.CollidesWith = CollisionCats.PlayerCategory;
shank.Trigger.OnEnter += new FarseerPhysics.Dynamics.OnCollisionEventHandler(script.OnEnter);
return shank;
}
示例3: CreateTysonGO
public static GameObject CreateTysonGO(ContentManager manager, GraphicsDevice gd, PlayerScript playerScript)
{
if (tysonSprite == null)
{
tysonSprite = manager.Load<Texture2D>("Characters/MikeTyson");
}
GameObject tyson = new GameObject();
tyson.AddTransform();
tyson.AddAnimation(tysonSprite, new Vector2(60f, 119f));
tyson.Animation.AddAnimation("Idle", 0, 4);
tyson.Animation.AddAnimation("Die", 1, 3, false);
tyson.Animation.Play("Idle");
tyson.AddRenderer(gd, SpriteTransparency.Transparent);
tyson.AddTrigger(new Vector2(80f, 119f));
tyson.Trigger.CollidesWith = CollisionCats.PlayerCategory;
ShankTargetScript tysonScript = new ShankTargetScript(tyson, playerScript);
tyson.AddScript(tysonScript);
tyson.Trigger.OnEnter += new FarseerPhysics.Dynamics.OnCollisionEventHandler(tysonScript.OnEnter);
tyson.Trigger.OnStay += new FarseerPhysics.Dynamics.OnSeparationEventHandler(tysonScript.OnStay);
return tyson;
}
示例4: LoadContent
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
RigidBody.DebugLoadContent(GraphicsDevice, Content);
DialogueRenderer.Instance.Initialize(Content, GraphicsDevice);
manager = new GameObjectManager();
GameObject camera = new GameObject();
camera.AddTransform();
//camera.Transform.Parent = player.Transform;
camera.Transform.Position = new Vector2(0f, 30f);
camera.Transform.Z = 80f;
camera.AddCamera(GraphicsDevice.Viewport, true);
camera.AddScript(new CameraScript(camera));
manager.AddGameObject(camera);
GameObject splash = SplashScript.CreateSplashGO(Content, GraphicsDevice);
splash.Transform.Translate(new Vector3(-3000f, 0f, 10));
manager.AddGameObject(splash);
//GameObject cameraBounds = GameObject.CreateStaticGO(GraphicsDevice, Content.Load<Texture2D>("DebugCameraBounds"), SpriteTransparency.Transparent);
//cameraBounds.Transform.Z = 0f;
//cameraBounds.Transform.Parent = camera.Transform;
//manager.AddGameObject(cameraBounds);
// Main area
GameObject mainLevel = WorldGen.CreateWorldGO(GraphicsDevice, Content, "Levels/LevelMainMid", "Levels/LevelMain");
mainLevel.RigidBody.Body.Friction = 4f;
manager.AddGameObject(mainLevel);
GameObject mainLevelBack = GameObject.CreateStaticGO(GraphicsDevice, Content.Load<Texture2D>("Levels/LevelMainBack"), SpriteTransparency.Opaque);
mainLevelBack.Transform.Z -= 25f;
manager.AddGameObject(mainLevelBack);
GameObject mainLevelFront = GameObject.CreateStaticGO(GraphicsDevice, Content.Load<Texture2D>("Levels/LevelMainFront"), SpriteTransparency.Transparent);
mainLevelFront.Transform.Z = 5f;
manager.AddGameObject(mainLevelFront);
// Vent area
GameObject vents = WorldGen.CreateWorldGO(GraphicsDevice, Content, "Levels/VentsMid", "Levels/Vents");
vents.RigidBody.Body.Friction = 0f;
vents.Transform.Position = new Vector2(2000f, 0f);
manager.AddGameObject(vents);
GameObject ventsTop1 = GameObject.CreateStaticGO(GraphicsDevice, Content.Load<Texture2D>("Levels/VentsTop1"), SpriteTransparency.Transparent);
ventsTop1.Transform.Translate(new Vector3(2000f, 0f, 40f));
manager.AddGameObject(ventsTop1);
GameObject ventsTop2 = GameObject.CreateStaticGO(GraphicsDevice, Content.Load<Texture2D>("Levels/VentsTop2"), SpriteTransparency.Transparent);
ventsTop2.Transform.Translate(new Vector3(2000f, 0f, 30f));
manager.AddGameObject(ventsTop2);
// Fans
GameObject fan1 = FanScript.CreateFanGO(Content, GraphicsDevice);
manager.AddGameObject(fan1);
fan1.Transform.Translate(new Vector3(1855f, 180f, 0f));
GameObject fan2 = FanScript.CreateFanGO(Content, GraphicsDevice);
manager.AddGameObject(fan2);
fan2.Transform.Translate(new Vector3(2272f, 256f, 0f));
GameObject fan3 = FanScript.CreateFanGO(Content, GraphicsDevice);
manager.AddGameObject(fan3);
fan3.Transform.Translate(new Vector3(2016f, -208f, 0f));
GameObject player = PlayerScript.CreatePlayerGO(Content, GraphicsDevice);
player.Transform.Translate(new Vector3(-200f, -40f, 1f));
//player.Transform.Translate(new Vector3(2385f, -420f, 1f));
manager.AddGameObject(player);
camera.Transform.Parent = player.Transform;
PlayerScript playerScript = player.GetComponent<PlayerScript>();
GameObject teleporter1 = TeleporterScript.CreateTeleporterGO(Content, playerScript, new Vector2(1604f, -332f), true);
teleporter1.Transform.Translate(new Vector2(250f, -230f));
manager.AddGameObject(teleporter1);
GameObject teleporter2 = TeleporterScript.CreateTeleporterGO(Content, playerScript, new Vector2(-400f, 140f), false);
teleporter2.Transform.Translate(new Vector2(1746f, 396f));
manager.AddGameObject(teleporter2);
GameObject teleporter3 = TeleporterScript.CreateTeleporterGO(Content, playerScript, new Vector2(2140f, 120f), true);
teleporter3.Transform.Translate(new Vector2(330f, 140f));
manager.AddGameObject(teleporter3);
GameObject teleporter4 = TeleporterScript.CreateTeleporterGO(Content, playerScript, new Vector2(600f, 140f), false);
teleporter4.Transform.Translate(new Vector2(2450f, 340f));
manager.AddGameObject(teleporter4);
GameObject teleporter5 = TeleporterScript.CreateTeleporterGO(Content, playerScript, new Vector2(1604f, -332f), true);
teleporter5.Transform.Translate(new Vector2(800f, 140f));
manager.AddGameObject(teleporter5);
GameObject teleporter6 = TeleporterScript.CreateTeleporterGO(Content, playerScript, new Vector2(600f, -230f), false);
teleporter6.Transform.Translate(new Vector2(2385f, -420f));
manager.AddGameObject(teleporter6);
GameObject tyson = ShankTargetScript.CreateTysonGO(Content, GraphicsDevice, playerScript);
tyson.Transform.Translate(new Vector2(775f, 180f));
manager.AddGameObject(tyson);
//GameObject laser = LaserScript.CreateLaserGO(Content, GraphicsDevice);
//manager.AddGameObject(laser);
//.........这里部分代码省略.........
示例5: CreatePlayerGO
public static GameObject CreatePlayerGO(ContentManager content, GraphicsDevice gd)
{
if (characterSprite == null)
{
characterSprite = content.Load<Texture2D>("Characters/MainCharacter");
}
GameObject playerGO = new GameObject();
playerGO.AddTransform();
playerGO.AddAudio();
playerGO.Audio.AddSFX("Pickup", content.Load<SoundEffect>("Sounds/PlayerSounds/Pickup"));
playerGO.Audio.AddSFX("Shank", content.Load<SoundEffect>("Sounds/PlayerSounds/Shank"));
playerGO.AddAnimation(characterSprite, new Vector2(28f, 30f));
playerGO.Animation.AddAnimation("Idle", 0, 1);
playerGO.Animation.AddAnimation("Run", 0, 4);
playerGO.Animation.AddAnimation("Hide", 2, 1);
playerGO.Animation.AddAnimation("Stab", 3, 1);
playerGO.Animation.AddAnimation("Stealth", 1, 4);
playerGO.Animation.AddAnimation("Elevator", 5, 1);
playerGO.Animation.AddAnimation("VentIdle", 4, 1);
playerGO.Animation.AddAnimation("VentCrawl", 4, 4);
playerGO.AddRenderer(gd, SpriteTransparency.Transparent);
playerGO.AddDynamicRigidBody(new Vector2(28f, 30f));
playerGO.RigidBody.CollisionCategory = CollisionCats.PlayerCategory;
playerGO.AddScript(new PlayerScript(playerGO));
return playerGO;
}