示例#1
0
        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);
        }
        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;
        }