示例#1
0
 /** Push the sprites from this cluster into the set */
 public void Render(nGraphicsPipe pipe, List<nSprite> sprites)
 {
     foreach (var m in _mobiles) {
     m.Sprites = m.Parent.Render(pipe);
     if (m.Sprites != null)
       sprites.AddRange(m.Sprites);
       }
 }
示例#2
0
        /** If you wrap this with another class you MUST call render each frame */
        public nSprite[] Render(nGraphicsPipe pipe)
        {
            if (_data == null)
            _data = new nSprite[1] { pipe.Sprite() };

              if (Data.Invalid) {
            _data[0].Load(Data);
            Data.Reset();
              }

              return _data;
        }
示例#3
0
        /**
         * Creates a new orthographic camera
         * <p>
         * Notice that you must 'enable' this camera by setting
         * 'Active' to true, and 'Audio' to true if you want it to
         * be the primary audio listener.
         * <p>
         * The camera is placed at (0, 0, -1) looking down the Z-axis.
         * <p>
         * There MUST be a camera on the scene already to be able create
         * this type of camera, and it inherits all the properties of the
         * main camera; although some of them are reset.
         */
        public nCamera(double height)
        {
            var original = GameObject.FindWithTag("MainCamera");
              _cam = (Camera) UnityEngine.Camera.Instantiate(
            original.camera,
            new Vector3(0, 0, -1),
            Quaternion.FromToRotation(
              new Vector3(0, 0, 0),
              new Vector3(0, 0, 1)
            )
              );
              _cam.orthographicSize = (float) height / 2;
              _cam.orthographic = true;
              _cam.backgroundColor = Color.black;
              _cam.depth = 0;
              _cam.enabled = false;
              _cam.GetComponent<AudioListener>().enabled = false;

              _pipe = new nGraphicsPipe();
              _cam.gameObject.AddComponent<nRenderer>();
              _cam.gameObject.GetComponent<nRenderer>().Pipe = _pipe;

              original.camera.enabled = false;
        }
示例#4
0
 /** Regenerate all the sprites in the cluster */
 public nSprite[] Render(nGraphicsPipe pipe)
 {
     _sprites.Clear();
       for (var j = 0; j < _drawables.Count; ++j) {
     var items = _drawables[j].Render(pipe);
     _sprites.AddRange(items);
       }
       foreach (var c in _clusters) {
     c.Render(pipe, _sprites);
       }
       var rtn = _sprites.ToArray();
       return rtn;
 }
示例#5
0
        public nSprite[] Render(nGraphicsPipe pipe)
        {
            /* We can't reuse our sprites if we're changing sizes; reset them */
              if (_size.Invalid)
            _data = null;

              if (Rebuild()) {
            var pos = _camera.ScreenBounds;
            var wide = (int)Math.Ceiling (pos.width / Size [0]);
            var high = (int)Math.Ceiling (pos.height / Size [1]);

            /* Always add one extra tile in every direction, to account for offset */
            wide += 2;
            high += 2;

            /* new set of sprites */
            if (_data == null) {
              _data = new nSprite[wide * high];
              for (var i = 0; i < _data.Length; ++i) {
            _data [i] = pipe.Sprite ();
              }
            }

            for (var x = 0; x < wide; ++x) {
              for (var y = 0; y < high; ++y) {

            /* Tile coordinates */
            var xMin = pos.x + Size [0] * x;
            var xMax = xMin + Size [0];
            var yMin = pos.y + Size [1] * y;
            var yMax = yMin + Size [1];

            /* Apply offset for hidden bits */
            xMin -= Size[0];
            xMax -= Size[0];
            yMin -= Size[1];
            yMax -= Size[1];

            /* Set sprite to cover entire size of window */
            var s = _data [y * wide + x];
            s.Depth = _depth;
            s.Texture = Texture;
            s.Color.Set (Color);
            //s.Points.Set (new float[8] {xMax, yMax, xMax, yMin, xMin, yMin, xMin, yMax});
            s.Points.Set (new float[8] {xMax, yMax, xMin, yMax, xMin, yMin, xMax, yMin});
              }
            }
            Reset ();
              }

              /* Moved is a special case; don't rebuild if all we did was shuffle a little */
              if (_offset.Invalid) {

            /* Offset cannot be larger than the size of the tile */
            var ox = _offset[0] % Size[0];
            var oy = _offset[1] % Size[1];

            for (int i = 0; i < _data.Length; ++i) {
              _data[i].Position[0] = ox;
              _data[i].Position[1] = oy;
              if (_uv != null) {
            _data[i].UV.Set (_uv);
              }
            }
            _uv = null;
            _offset.Reset();
              }
              return _data;
        }
示例#6
0
        void Start()
        {
            _controller = Pongstar.Get<GameController>();
              var model = _controller.UI();
              var sm = _controller.Score();
              if (sm != null)
            _score = sm.As<Score>();

              /* Fudge score for tests */
              else {
            _score = new Score();
            _score.Update(53223 + nRand.Int(100, 50), "Lucky");
            _score.Winner = WinState.PLAYER;
              }

              /* Add to high scores? */
              _controller.UpdateScore(_score.Points);
              _highscores = _controller.HighScores().Scores;

              /* Win noise~ */
              model.Game.Audio = new nAudio(this.gameObject);
              Ps.Model.Actions.Game.SetupAudio(model.Game.Audio);
              if (_score.Winner == WinState.AI)
            model.Game.Audio.Play(Ps.Model.Actions.Game.WIN_LOSE_CHANNEL, Ps.Model.Actions.Game.LOSE_SOUND, 1f);
              else
            model.Game.Audio.Play(Ps.Model.Actions.Game.WIN_LOSE_CHANNEL, Ps.Model.Actions.Game.WIN_SOUND, 1f);

              /* Background~ */
              _f = new Field(null, model.Camera);

              /* setup camera */
              if (_pipe == null) {
            model.Camera.Active = true;
            _pipe = model.Camera.Pipe;
            _pipe.Drawables.Add(_f.Display);

            _c = new Collectables(model.Game);
            _pipe.Drawables.Add(_c.Display);
              }

              _ready = true;
        }
示例#7
0
        public nSprite[] Render(nGraphicsPipe pipe)
        {
            if (_data == null) {
            _data = new nSprite[4];
            for (var i = 0; i < _data.Length; ++i) {
              _data[i] = pipe.Sprite ();
              _data[i].Depth = _depth;
            }
            _data[0].Points.Set(LineSegment(_points[0], _points[1] + _thickness / 2.0f, _points[2], _points[3] - _thickness / 2.0f));
            _data[1].Points.Set(LineSegment(_points[2], _points[3], _points[4], _points[5]));
            _data[2].Points.Set(LineSegment(_points[4], _points[5] - _thickness / 2.0f, _points[6], _points[7] + _thickness / 2.0f));
            _data[3].Points.Set(LineSegment(_points[6], _points[7], _points[0], _points[1]));
              }

              /* Rebuild content? */
              if (Redraw()) {
            foreach (var item in _data) {
              item.Color.Set(_color);
              item.Rotation = _rotation;
              item.Position.Set(_position);
              item.Texture = (Texture) Resources.Load("Line.jpg");
            }
              }

              return _data;
        }
示例#8
0
 public nSprite[] Render(nGraphicsPipe pipe)
 {
     if (_sprites == null)
     CreateSegments(pipe);
       return _sprites;
 }
示例#9
0
 /** Create the segment buffer */
 private void CreateSegments(nGraphicsPipe pipe)
 {
     _sprites = new nSprite[_segmentCount];
       for (int i = 0; i < _segmentCount; ++i) {
     var s = pipe.Sprite();
     s.Depth = 28f;
     s.Texture = (Texture) Resources.Load("rainbow");
     s.Color.Set(new float[4] { 1f, 1f, 1f, 1f });
     s.UV.Set(new float[8] { 1, 1, 1, 0, 0, 0, 0, 1 });
     _sprites[i] = s;
       }
 }
示例#10
0
 public nSprite[] Render(nGraphicsPipe pipe)
 {
     if (Invalid) return null;
       if (_sprites == null) {
     _sprites = new nSprite[1];
     _sprites[0] = pipe.Sprite();
     _sprites[0].Points.Set(new nGQuad(Size).Points);
     _sprites[0].Texture = (Texture) Resources.Load("Line");
     _sprites[0].Position.Set(Position);
     _sprites[0].Color.Set(Color);
     _sprites[0].Depth = nRand.Float(4f, 1f);
       }
       return _sprites;
 }
示例#11
0
 public nSprite[] Render(nGraphicsPipe pipe)
 {
     if (Invalid) return null;
       if (_sprites == null) {
     _sprites = new nSprite[1];
     _sprites[0] = pipe.Sprite();
     _sprites[0].Points.Set(new nGQuad(Size[0], Size[1]).Points);
     _sprites[0].Texture = (Texture) Resources.Load("points500");
     _sprites[0].Position.Set(Position);
     _sprites[0].Depth = nRand.Float(3f, 1f);
     _sprites[0].Color.Set(new float[4] {
       nRand.Float(0f, 1f, 0f),
       nRand.Float(0f, 1f, 0f),
       nRand.Float(0f, 1f, 0f),
       1f
     });
       }
       return _sprites;
 }
示例#12
0
        void Start()
        {
            _controller = Pongstar.Get<GameController>();
              var model = _controller.Start(this.gameObject);

              /* setup camera */
              if (_pipe == null) {
            model.Camera.Active = true;
            _pipe = model.Camera.Pipe;
              }

              /* setup drawables */
              _pipe.Drawables.Clear();
              foreach (var c in model.Items) {
            _pipe.Drawables.Add(c);
              }
        }
示例#13
0
 public nSprite[] Render(nGraphicsPipe pipe)
 {
     if (_sprites == null) {
     _sprites = new nSprite[1] {
       pipe.Sprite()
     };
       }
       return _sprites;
 }