public Decoration(Vector3 location, Vector3 scale, bool existsIn2d, bool existsIn3d, Billboarding bb, SpriteSheet sprite) : base() {
			_location = location;
			_scale = scale;
			_existsIn3d = existsIn3d;
			_existsIn2d = existsIn2d;
			_mesh = mesh;
			_texture = texture;
			_sprite = sprite;
			_cycleNum = 0;
			_frameNum = 0;
			_is3dGeo = false;
            _hascbox = false;
			_billboards = bb;
			_animDirection = 1;
		}
示例#2
0
        /// <summary>
        /// Creates a new Sprite.
        /// </summary>
        /// <param name="tex">The texture to use.</param>
        /// <param name="col">The sprite's color.</param>
        /// <param name="offs">The sprite's offsets.</param>
        /// <param name="rot">The sprite's rotation.</param>
        /// <param name="ang">The sprite's angle.</param>
        /// <param name="pitch">The sprite's pitch.</param>
        /// <param name="scale">The sprite's scale.</param>
        /// <param name="bb">The sprite's billboarding mode.</param>
        /// <exception cref="ArgumentNullException">Tex is null.</exception>
        public Sprite(Texture tex, Color col, Vector2 offs, double rot, double ang, double pitch, Vector2 scale, Billboarding bb)
        {
            if (tex == null)
            {
                throw new ArgumentNullException("tex", "The texture of a Sprite cannot be null. Use Sprite.EmptySprite instead!");
            }

            this.Texture   = tex;
            this.Color     = col;
            this.Offset    = offs;
            this.Rotation  = rot;
            this.Angle     = ang;
            this.Pitch     = pitch;
            this.Scale     = scale;
            this.Billboard = bb;
        }
		public Obstacle(Vector3 location, Vector3 scale, Vector3 pbox, bool existsIn2d, bool existsIn3d, bool collidesIn2d, bool collidesIn3d,
							Billboarding bb, SpriteSheet sprite) : base() {
			_location = location;
			_scale = scale;
            _pbox = pbox;
			_existsIn3d = existsIn3d;
			_existsIn2d = existsIn2d;
			_mesh = null;
			_texture = null;
			_sprite = sprite;
			_cycleNum = 0;
			_frameNum = 0;
			_frame3d = 0;
			_is3dGeo = false;
			_hascbox = false;
            canSquish = false;
			_collidesIn2d = collidesIn2d;
			_collidesIn3d = collidesIn3d;
			_billboards = bb;
			_animDirection = 1;
		}
		/*
		 * draw - Uses OpenGL to render this sprite.  Requires that
		 *		  the modelview matrix has been properly set up previously
		 *		  to scale and translate to proper location, but pops matrix
		 *		  to remove those transformations.
		 *		  
		 *		  Takes as parameters a cycle number (indicating which animation
		 *		  cycle is to be drawn) and a frame number (indicating which frame
		 *		  the animation is on).
		 *		  
		 *		  Returns the frameNumber passed, possibly modding it first
		 *		  to bring it back into the expected range.
		 */
		public double draw(bool viewIs3d, Billboarding bb, int cycleNumber = 0, double frameTime = 0.0) {
			if(texID == -1) {
				texID = GL.GenTexture();
				allSprites.Add(this);
			}

			GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Clamp);
			GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Clamp);
			GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
			GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
			GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Replace);
            
            if (cycleNumber < 0) cycleNumber = 1;
			int frameNum = (int)(frameTime * framesPerSecond);
			if(frameNum >= tex[cycleNumber].Length) {
				frameTime %= tex[cycleNumber].Length / framesPerSecond;
				frameNum %= tex[cycleNumber].Length;
			} else while(frameNum < 0) {
				frameTime += tex[cycleNumber].Length / framesPerSecond;
				frameNum = (int)(frameTime * framesPerSecond);
			}

			GL.BindTexture(TextureTarget.Texture2D, texID);
			if(frameNum != prevFrameNum || cycleNumber != prevCycleNum) {
				GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, texw, texh, 0, PixelFormat.Rgba, PixelType.UnsignedByte, tex[cycleNumber][frameNum]);
				prevFrameNum = frameNum;
				prevCycleNum = cycleNumber;
			}

			GL.Scale(1, -1, 1);
			if(bb == Billboarding.Lock3d || (viewIs3d && bb == Billboarding.Yes)) {
				GL.Rotate(270, Vector3d.UnitY);
			}
			quad.Render();

			return frameTime;
		}
		public Effect(PlayState ps, Vector3 location, Vector3 scale, bool existsIn2d, bool existsIn3d, Billboarding bb, SpriteSheet sprite)
			: base(location, scale, existsIn2d, existsIn3d, bb, sprite) {
				this.playstate = ps;
				timeElapsed = 0.0;
		}
示例#6
0
 private void Start()
 {
     agent        = GetComponent <NavMeshAgent>();
     billboarding =
         UnityUtil.FindComponentInChildrenWithTag <Billboarding>(gameObject, PcControl.PlayerAnimationTag);
 }