Inheritance: MonoBehaviour
Example #1
1
        public Pyramid(World world, Vector2 position, int count, float density)
        {
            Vertices rect = PolygonTools.CreateRectangle(0.5f, 0.5f);
            PolygonShape shape = new PolygonShape(rect, density);

            Vector2 rowStart = position;
            rowStart.Y -= 0.5f + count * 1.1f;

            Vector2 deltaRow = new Vector2(-0.625f, 1.1f);
            const float spacing = 1.25f;

            // Physics
            _boxes = new List<Body>();

            for (int i = 0; i < count; i++)
            {
                Vector2 pos = rowStart;

                for (int j = 0; j < i + 1; j++)
                {
                    Body body = BodyFactory.CreateBody(world);
                    body.BodyType = BodyType.Dynamic;
                    body.Position = pos;
                    body.CreateFixture(shape);
                    _boxes.Add(body);

                    pos.X += spacing;
                }
                rowStart += deltaRow;
            }

            //GFX
            _box = new Sprite(ContentWrapper.PolygonTexture(rect, "Square", ContentWrapper.Blue, ContentWrapper.Gold, ContentWrapper.Black, 1f));
        }
Example #2
1
        /// <summary>
        /// Create a new game screen. Should be done every time there is a new game.
        /// </summary>
        /// <param name="theScreenEvent"></param>
        /// <param name="contentManager"></param>
        public GameScreen(EventHandler theScreenEvent,ContentManager contentManager)
            : base(theScreenEvent)
        {
            bScoreWasAdded = false;

            this.contentManager = contentManager;
            dlDoubleJumpTimer = new DanLabel(1150, 20, 100, 50);

            //Init our intrepid hero
            csHero = new ControlledSprite();

            bg = new LayeredBackground();

            djeJumpEffect = new DoubleJumpEffect();

            altimeter = new Altimeter(); // Make a camera for the screen with an altimeter
            cCamera = new Camera(50, 100, 600, 520, altimeter);

            blocks = new List<Sprite>();
            Sprite sp = new Sprite();
            blocks.Add(sp);
            sp = new Sprite();
            blocks.Add(sp);
            sp = new Sprite();
            blocks.Add(sp);
            sp = new Sprite();
            blocks.Add(sp);
            sp = new Sprite();
            blocks.Add(sp);

            // REVIST Set up the Arcing Block Manager with the difficulty
            arcingBlockManager = new ArcingBlockManager(cCamera, blocks, contentManager, 500, 300, 150, "Sprites/block2");
        }
Example #3
0
    // Use this for initialization
    void Start()
    {
        string personaje = PlayerPrefs.GetString("personaje");
        int contador = 0;
        foreach (var item in sprite)
        {
            if (item.name.ToUpper() == personaje.ToUpper())
            {
                character_sprite = item;
                if (SceneManager.GetActiveScene().name != "_Menu_principal")
                {
                    GetComponent<SphereCollider>().center = colliderMod[contador];
                }
            }
            contador++;
        }

        player = GameObject.FindGameObjectWithTag("Player");
        if (player != null)
        if (this != null)
        {
            SpriteRenderer player_transform = player.GetComponent<SpriteRenderer>();
            player_transform.sprite = character_sprite;
        }

        if (transform.name == "Image")
        {
            transform.GetComponent<Image>().sprite = character_sprite;
        }
    }
Example #4
0
	IEnumerator Flip(Sprite startImage, Sprite endImage, int cardIndex)

	{
		spriteRenderer.sprite = startImage;

		float time = 0f;
		while (time <= 2f) 
		{
			float scale = scaleCurve.Evaluate (time);
			time += Time.deltaTime / duration;

			Vector3 localScale = transform.localScale;
			localScale.x = scale;
			transform.localScale = localScale;

			if (time >= 0.5f) 
			{
				spriteRenderer.sprite = endImage;
			}

			yield return new WaitForFixedUpdate ();
		}

		if (cardIndex == -1) {
			model.ToggleFace (false);
		} 
		else 
		{
			model.cardIndex = cardIndex;
			model.ToggleFace (true);
		}
	}
Example #5
0
	public ShieldEffect (string n, int dur, int shield, Sprite icon = null)
		: base(n, dur, 1, icon)
	{
		maxShield = shield;
		shieldAmount = maxShield;
		description = "Damage Shield " + shieldAmount.ToString();
	}
Example #6
0
        public Vic(int newCycles, int newLines, int[][] newPipeline, int newCyclesPerSec, int hblankStart, int hblankEnd, int vblankStart, int vblankEnd)
        {
            {
                this.hblankStart = hblankStart;
                this.hblankEnd = hblankEnd;
                this.vblankStart = vblankStart;
                this.vblankEnd = vblankEnd;

                totalCycles = newCycles;
                totalLines = newLines;
                pipeline = newPipeline;
                cyclesPerSec = newCyclesPerSec;

                bufWidth = TimingBuilder_ScreenWidth(pipeline[0], hblankStart, hblankEnd);
                bufHeight = TimingBuilder_ScreenHeight(vblankStart, vblankEnd, newLines);

                buf = new int[bufWidth * bufHeight];
                bufLength = buf.Length;

                sprites = new Sprite[8];
                for (int i = 0; i < 8; i++)
                    sprites[i] = new Sprite();

                bufferC = new int[40];
                bufferG = new int[40];
            }
        }
Example #7
0
        public void FireShot(
            Vector2 location,
            Vector2 velocity,
            bool playerFired)
        {
            Sprite thisShot = new Sprite(
                location,
                Texture,
                InitialFrame,
                velocity);

            thisShot.Velocity *= shotSpeed;

            for (int x = 1; x < FrameCount; x++)
            {
                thisShot.AddFrame(new Rectangle(
                    InitialFrame.X + (InitialFrame.Width * x),
                    InitialFrame.Y,
                    InitialFrame.Width,
                    InitialFrame.Height));
            }
            thisShot.CollisionRadius = CollisionRadius;
            Shots.Add(thisShot);

            if (playerFired)
            {

                SoundManager.PlayPlayerShot();
            }
            else
            {

                SoundManager.PlayEnemyShot();
            }
        }
Example #8
0
 public override void LoadAssets()
 {
     mouthLeft = resourceFactory.Create(this, "MouthLeft-WeNeedThisTaste").GetComponent<Sprite>();
     mouthRight = resourceFactory.Create(this, "MouthRight-WeNeedThisTaste").GetComponent<Sprite>();
     mouthLeft.visible(false);
     mouthRight.visible(false);
 }
Example #9
0
        public LevelMenyState(Game1 game, Sprite spriteSheet)
            : base(game)
        {
            this.spriteSheet = spriteSheet;
            font = game.Content.Load<SpriteFont>("menyFont");

            knappar = new List<Clickable>();

            Random random = new Random();

            LevelMenyExitKnapp levelExit = new LevelMenyExitKnapp(game, spriteSheet, new Vector2(410, 550));
            levelExit.Initialize();

            Level1 lv1 = new Level1(game, spriteSheet, random);
            Level1Knapp level1knapp = new Level1Knapp(game, spriteSheet, new Vector2(200, 200), lv1);
            level1knapp.Initialize();
            lv1.AddLevelButton(level1knapp);

            Level2 lv2 = new Level2(game, spriteSheet, random);
            Level2Knapp level2knapp = new Level2Knapp(game, spriteSheet, new Vector2(300, 200), lv2);
            level2knapp.Initialize();
            lv2.AddLevelButton(level2knapp);

            Level3 lv3 = new Level3(game, spriteSheet, random);
            Level3Knapp level3knapp = new Level3Knapp(game, spriteSheet, new Vector2(400, 200), lv3);
            level3knapp.Initialize();
            lv3.AddLevelButton(level3knapp);

            Level4 lv4 = new Level4(game, spriteSheet, random);
            Level4Knapp level4knapp = new Level4Knapp(game, spriteSheet, new Vector2(500, 200), lv4);
            level4knapp.Initialize();
            lv4.AddLevelButton(level4knapp);

            Level5 lv5 = new Level5(game, spriteSheet, random);
            Level5Knapp level5knapp = new Level5Knapp(game, spriteSheet, new Vector2(600, 200), lv5);
            level5knapp.Initialize();
            lv5.AddLevelButton(level5knapp);

            Level6 lv6 = new Level6(game, spriteSheet, random);
            Level6Knapp level6knapp = new Level6Knapp(game, spriteSheet, new Vector2(700, 200), lv6);
            level6knapp.Initialize();
            lv6.AddLevelButton(level6knapp);

            LevelTest lvTest = new LevelTest(game, spriteSheet, random);
            TestLevelKnapp levelTestknapp = new TestLevelKnapp(game, spriteSheet, new Vector2(800, 600), lvTest);
            levelTestknapp.Initialize();
            lvTest.AddLevelButton(levelTestknapp);

            knappar.Add(level1knapp);
            knappar.Add(level2knapp);
            knappar.Add(level3knapp);
            knappar.Add(level4knapp);
            knappar.Add(level5knapp);
            knappar.Add(level6knapp);
            knappar.Add(levelTestknapp);

            knappar.Add(levelExit);

            textTimer = 0;
        }
Example #10
0
 public static bool KolizjaDlaOkregow(Sprite a, Sprite b)
 {
     float d = Odleglosc(a.pozycja, b.pozycja);
     if ((a.teksturaPodstawowa.Height * a.wielkoscObiektu.Y + +b.teksturaPodstawowa.Height * b.wielkoscObiektu.Y) / 2 > d)
         return true;
     return false;
 }
 public Button(Sprite sprite)
     : base()
 {
     m_buttonSprite = sprite;
     m_transform = m_buttonSprite.Transform;
     m_aabb = new AABB(m_transform, m_buttonSprite.Dimensions);
 }
Example #12
0
 public Shield(string pname, float pweight, float pdefense, Sprite psprite)
 {
     itemName = pname;
     weight = pweight;
     sprite = psprite;
     defense = pdefense;
 }
Example #13
0
	public void Pointed()
	{

		flag = Resources.Load<Sprite> (EarthManager.Instance.info_flag_path);

		Image tempImage=image.GetComponent<Image> ();

		tempImage.sprite = flag;

		//tempImage.sprite.texture
		//Text temp = GetComponent<Text> ();
		Text temp = title.GetComponent<Text> ();
		temp.text = EarthManager.Instance.title;

		temp = country.GetComponent<Text> ();
		temp.text = EarthManager.Instance.country;

		temp = area.GetComponent<Text> ();
		temp.text = EarthManager.Instance.area;

		temp = contents.GetComponent<Text> ();
		temp.text = EarthManager.Instance.contents;

		InformationCanvas.SetActive (true);
	}
Example #14
0
 public SpaceJunk(float x, float y, BitmapTexture2D texture, float scale)
 {
     Sprite = new Sprite(texture, scale);
     Sprite.UseCentreAsOrigin = true;
     Sprite.X = x;
     Sprite.Y = y;
 }
Example #15
0
 public SpaceJunk(float x, float miny, float maxy, BitmapTexture2D texture, float scale)
 {
     Sprite = new Sprite(texture, scale);
     Sprite.UseCentreAsOrigin = true;
     Sprite.X = x;
     Sprite.Y = Program.Rand.NextSingle() * (maxy - miny) + miny;
 }
Example #16
0
    public virtual void Init(Grid grid, int x, int y, float scale = 1, Sprite asset = null)
    {
        sfx = AudioManager.instance;

        container = transform.Find("Sprites");
        outline = transform.Find("Sprites/Outline").GetComponent<SpriteRenderer>();
        img = transform.Find("Sprites/Sprite").GetComponent<SpriteRenderer>();
        shadow = transform.Find("Sprites/Shadow").GetComponent<SpriteRenderer>();
        shadow.gameObject.SetActive(false);

        label = transform.Find("Label").GetComponent<TextMesh>();
        label.GetComponent<Renderer>().sortingLayerName = "Ui";
        label.gameObject.SetActive(Debug.isDebugBuild);

        this.grid = grid;
        this.x = x;
        this.y = y;
        this.asset = asset;

        this.walkable = true;

        transform.localPosition = new Vector3(x, y, 0);

        SetAsset(asset);
        SetImages(scale, Vector3.zero, 0);
        SetSortingOrder(0);

        visible = false;
        explored = false;
    }
Example #17
0
        public TgcDrawText(Device d3dDevice)
        {
            textSprite = new Sprite(d3dDevice);

            //Fuente default
            dxFont = new Microsoft.DirectX.Direct3D.Font(d3dDevice, VERDANA_10);
        }
Example #18
0
 public SpriteComponent(Sprite sprite, Texture2D texture)
 {
     Name = sprite.Id;
     Texture = texture;
     Origin = new Vector2(sprite.OriginX ?? sprite.W/2, sprite.OriginY ?? sprite.H/2);
     TextureRect = new Rectangle(sprite.X, sprite.Y, sprite.W, sprite.H);
 }
        public DamageComponent(Sprite owner, int hitPoints, params string[] immuneTo)
        {
            // ...

            killActions.Add("stomp", s =>
                {
                    s.Graphics.State = "flattened"; // or whatever
                    s.AddTimer(seconds: 2.0f, action: sp => sp.Owner.RemoveSprite(sp));
                });

            killActions.Add("knock_off", s =>
            {
                s.Graphics.Orientation = GraphicsOrientation.UpsideDown;
                s.Velocity = GameServices.ISOStandardKnockOffVelocity;
                s.State = SpriteState.Inert;
            });

            killActions.Add("vaporize", s =>
            {
                s.Owner.RemoveSprite(s);
                s.Owner.CreateEffect("fireballPuff", s.Position);
                SoundManager.PlaySoundEffect("vaporize");
            });

            killActions.Add("default", s => s.Owner.RemoveSprite(s));
        }
Example #20
0
        //Method to Initiliaze
        public static void Instantiate()
        {
            //Initialize the buttongroup
            buttons = new ButtonGroup();

            background = new Sprite();
        }
        public override void LoadContent()
        {
            base.LoadContent();

            World.Gravity = Vector2.Zero;

            _border = new Border(World, Lines, Framework.GraphicsDevice);
            for (int i = 0; i < 3; i++)
            {
                _breakableCookie[i] = Framework.Content.Load<BodyContainer>("Pipeline/FarseerBreakableBody")["Cookie"].CreateBreakable(World);
                _breakableCookie[i].Strength = 120f;
                _breakableCookie[i].MainBody.Position = new Vector2(-20.33f + 15f * i, -5.33f);
            }

            _breakableSprite = new List<Sprite>();
            List<Texture2D> textures = ContentWrapper.BreakableTextureFragments(_breakableCookie[0], "Cookie");
            for (int i = 0; i < _breakableCookie[0].Parts.Count; i++)
            {
                AABB bounds;
                Transform transform;
                _breakableCookie[0].Parts[i].Body.GetTransform(out transform);
                _breakableCookie[0].Parts[i].Shape.ComputeAABB(out bounds, ref transform, 0);
                Vector2 origin = ConvertUnits.ToDisplayUnits(_breakableCookie[0].Parts[i].Body.Position - bounds.LowerBound);
                _breakableSprite.Add(new Sprite(textures[i], origin));
            }
            _completeSprite = new Sprite(ContentWrapper.GetTexture("Cookie"), Vector2.Zero);
        }
Example #22
0
        public override DataObject Copy(Sprite parent)
        {
            var newBrick = new ChangeSizeByNBrick(parent);
            newBrick.size = size;

            return newBrick;
        }
Example #23
0
    void Start()
    {
        Texture2D texture = Resources.Load("testimg3",typeof(Texture2D)) as Texture2D;
        s	= new Sprite(texture);
        s.id	= "s";
        Stage.instance.addChild(s);
        s.x		= 300;
        s.y		= 300;
        s1	= new Sprite(texture);
        s1.id	= "s1";
        s.addChild(s1);
        s1.scaleX	= .5f;
        s1.x	= 150;
        s1.y	= 50;
        //s1.width	= 50;
        //s1.height	= 50;
        Debug.Log(s1.width+"/"+s1.height);
        s2	= new SelectableItem(texture);
        s2.id	= "s2";
        s1.addChild(s2);
        s2.x	= 250;
        s2.y	= 100;

        s3	= new Sprite(texture);
        s2.addChild(s3);
        s3.scaleX	= .3f;
        s3.scaleY	= .3f;
        s.addEventListner(MouseEvent.MOUSE_DOWN,new EventDispatcher.CallBack(clickHandler));
        s.addEventListner(GuiEvent.ENTER_FRAME,new EventDispatcher.CallBack(enterFrameHandler));
    }
Example #24
0
        public override DataObject Copy(Sprite parent)
        {
            var newBrick = new ChangeYByBrick(parent);
            newBrick.yMovement = yMovement;

            return newBrick;
        }
Example #25
0
 public void refresh(PLAYER_SELECT_CARD_RESULT result_type, Sprite card1, Sprite card2)
 {
     this.result_type_from_server = result_type;
     Debug.Log(this.slots.Count);
     this.slots[0].sprite = card1;
     this.slots[1].sprite = card2;
 }
 public void AddPoints(IEnumerable<Point> points, Sprite sprite)
 {
     foreach (Point point in points) {
         _points[point] = sprite;
         _wasChanged = true;
     }
 }
Example #27
0
        public override void Render(Sprite sprite)
        {
            Rectangle rect = new Rectangle(0, 0, 1280, 720);
            if (currentFrame >= frames.Length)
            {
                if (delay > 1.25f)
                {
                    sprite.Draw(frames[frames.Length - 1], rect, ColorValue.White);
                    ColorValue color = ColorValue.White;
                    color.A = (byte)(byte.MaxValue * (1 - MathEx.Saturate((delay - 1.25f) / 1.25f)));
                    sprite.Draw(blackBg, rect, color);
                }
                else
                {
                    ColorValue color = ColorValue.White;
                    color.A = (byte)(byte.MaxValue * MathEx.Saturate(delay / 1.25f));
                    sprite.Draw(blackBg, rect, color);
                }


                delay -= 0.04f;
            }
            else
            {
                sprite.Draw(frames[currentFrame], rect, ColorValue.White);
            }
        }
Example #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Platform"/> class.
 /// </summary>
 /// <param name="description">The platform description.</param>
 /// <param name="physicsWorld">The physics world.</param>
 /// <param name="spriteBatch">The sprite batch to use for rendering.</param>
 /// <param name="contentManager">The game's content manager.</param>
 public Platform(PlatformDescription description, ref World physicsWorld, SpriteBatch spriteBatch, ContentManager contentManager)
 {
     this.spriteOffsets = new List<Vector2>();
     this.sprite = new Sprite();
     this.InitializeAndLoadSprites(spriteBatch, contentManager, description);
     this.SetUpPhysics(ref physicsWorld, description);
 }
Example #29
0
 void Update()
 {
     if(Isvired)
     {
         gameObject.GetComponent<Image>().sprite = MyImage;
         switch(MyCard)
         {
             case 1:
                 MyImage = IdImage[0];
             break;
             case 2:
                 MyImage = IdImage[1];
             break;
             case 3:
                 MyImage = IdImage[2];
             break;
             case 4:
                 MyImage = IdImage[3];
             break;
             case 5:
                 MyImage = IdImage[4];
             break;
             case 6:
                 MyImage = IdImage[5];
             break;
         }
     }
     else
     {
         gameObject.GetComponent<Image>().sprite = Resources.Load("Sprites/Default",typeof(Sprite)) as Sprite;
     }
 }
Example #30
0
        /// <summary>
        /// 
        /// </summary>
        protected override void LoadContent()
        {
            Sprite road = new Sprite(Simulator.Content.Load<Texture2D>("Road"));
            road.Position = new Vector2(640, 360);

            Statistics statistics = new Statistics();
        }