Пример #1
0
    public void AddFace(FACE face, int x, int y, int z, Vector3 vertexScale, Vector2 uvScale, Vector2 uvOffset, byte shape = 0)
    {
        int f = (int)face;

        // get the template for this cube
        Vector3[] vertices = (shape!=0) ? BlockTemplate.ShapedVertices(f, shape) : BlockTemplate.vertices[f];
        Vector4[] tangents = BlockTemplate.tangents[f];
        Vector3[] normals  = BlockTemplate.normals[f];
        Vector2[] uv 	   = BlockTemplate.uv[f];

        //store the original vertex index
        int origin = _vertices.Count;

        for (int i=0;i<vertices.Length; i++)
        {
            _vertices.Add(Vector3.Scale(Vector3.Scale(vertices[i], vertexScale) + new Vector3(x,y,z), Block.SIZE));
            _tangents.Add(tangents[i]);
            _normals.Add(normals[i]);
            _uvs.Add(Vector2.Scale(uv[i], uvScale) + uvOffset);
        }

        //fetch a template face
        int[] triangles = BlockTemplate.face;
        for (int i=0; i<triangles.Length; i++)
        {
            _triangles.Add(origin + triangles[i]);
        }
    }
Пример #2
0
    public void addFace(FACE face, int x, int y, int z, BlockType type)
    {
        //get the template vertices needed to draw this face
        Vector3[] vertices = BlockTemplate.vertices[(int)face];

        //get the uv mapping for this block/face combination
        Vector2[] uv = BlockTypes.getUV(type, face);
        //Vector2[] uv = BlockTemplate.uv;
        //store the original vertex index
        int origin = _vertices.Count;

        for (int i=0;i<vertices.Length; i++)
        {
            Vector3 vertex = Vector3.Scale(vertices[i] + new Vector3(x,y,z), Block.SIZE);

            //translate and scale the vertex to the position of this block
            _vertices.Add(vertex);
            _uvs.Add(uv[i]);
        }

        //get a template face
        int[] triangles = BlockTemplate.face;
        for (int i=0; i<triangles.Length; i++)
        {
            //translate this index to point to the vertices we just added
            _triangles.Add(origin + triangles[i]);
        }
    }
Пример #3
0
    ///<summary>改变面向<summary>
    public void SwapFace(FACE face)
    {
        if (this.face != face)
        {
            this.face    = face;
            spt.sprite2D = scp.spts[new Point(step_ary[step], FaceInt) + id];
            timer        = 0;
        }
        else
        {
            float rate = (100f / aimMove.v) * 0.5f + 0.5f;

            if (timer > 0.25f * rate)
            {
                timer = 0;
                step++;

                if (step >= step_ary.Length)
                {
                    step = 0;
                }

                spt.sprite2D = scp.spts[new Point(step_ary[step], FaceInt) + id];
            }
            else
            {
                timer += Game.RealDeltaTime(true);
            }
        }
    }
Пример #4
0
        public void Test_Left()
        {
            FACE   expected = FACE.WEST;
            Pacman p        = new Pacman();

            p.PlacePacman("4", "4", "NORTH");
            p.Left();
            Assert.AreEqual(expected, p.CurrentFace);
        }
Пример #5
0
 public ExtractFaces(GameObject gameObject, FACE face)
 {
     this.gameObject = gameObject;
     if (face == FACE.X)
     {
         modifyMeshCube();
     }
     faceToExtract = face;
 }
Пример #6
0
        private void Init()
        {
            double limit    = Math.Round(this.weight * 100);
            FACE   unbiased = this.weightedSide == FACE.HEADS ? FACE.TAILS : FACE.HEADS;

            for (int i = 1; i <= 100; i++)
            {
                faces.Add(i <= limit ? this.weightedSide : unbiased);
            }
        }
Пример #7
0
 void Facing(FACE face)
 {
     if (this.face != face)
     {
         Vector3 v3 = this.transform.localEulerAngles;
         v3.y = (face == FACE.LEFT)?180:0;
         this.transform.localEulerAngles = v3;
         this.face = face;
     }
 }
Пример #8
0
        public static FaceId ToFaceId(this FACE face, bool mono)
        {
            if (face == FACE.None)
            {
                return(new FaceId(0, 0, mono));
            }

            var id = (int)face;

            return(new FaceId((id / 16) + 1, (byte)(id % 16), mono));
        }
Пример #9
0
	void Facing(FACE face)
	{
		if(this.face!=face)
		{
			Vector3 v3=this.transform.localEulerAngles;
			v3.y=(face==FACE.LEFT)?180:0;
			this.transform.localEulerAngles=v3;
			this.face=face;
		}
	

	}
Пример #10
0
    public void SetFace(FACE dir, ESCell face)
    {
        _faces[(int)dir] = face;

        foreach (ESCell f in _faces)
        {
            if (f == null)
            {
                return;
            }
        }

        _isInitialized = true;
    }
Пример #11
0
        public FACE GetFace <FACE>() where FACE : FBFace
        {
            if (Face == null)
            {
                return(null);
            }

            FACE face = Face as FACE;

            if (face == null)
            {
                throw new InvalidCastException("Face is not a " + typeof(FACE));
            }

            return(face);
        }
Пример #12
0
 public MODEL(int x, int y, int z, int rx, int ry, int rz, int minx, int miny, int maxx, int maxy, int velocity)
 {
     points        = new VECTOR[NUM_VERTS];
     faces         = new FACE[NUM_FACES];
     this.x        = x;
     this.y        = y;
     this.z        = z;
     this.rx       = rx;
     this.ry       = ry;
     this.rz       = rz;
     this.minx     = minx;
     this.miny     = miny;
     this.maxx     = maxx;
     this.maxy     = maxy;
     aim           = new VECTOR();
     this.velocity = velocity;
 }
Пример #13
0
    /* MESH COLLIDER */
    public void AddFace(FACE face, int x, int y, int z, Vector3 vertexScale, byte shape = 0)
    {
        int f = (int)face;

        // get the template for this cube
        Vector3[] vertices = (shape!=0) ? BlockTemplate.ShapedVertices(f, shape) : BlockTemplate.vertices[f];

        //store the original vertex index
        int origin = _vertices.Count;

        for (int i=0;i<vertices.Length; i++) {
            _vertices.Add(Vector3.Scale(Vector3.Scale(vertices[i], vertexScale) + new Vector3(x,y,z), Block.SIZE));
        }

        //fetch a template face
        int[] triangles = BlockTemplate.face;
        for (int i=0; i<triangles.Length; i++) {
            _triangles.Add(origin + triangles[i]);
        }
    }
Пример #14
0
        public override PJ Init()
        {
            fwd = e_forward;
            inv = e_inverse;

            // Determine the cube face from the center of projection.
            if (phi0 >= Proj.HALFPI - Proj.FORTPI / 2.0)
            {
                face = FACE.TOP;
            }
            else if (phi0 <= -(Proj.HALFPI - Proj.FORTPI / 2.0))
            {
                face = FACE.BOTTOM;
            }
            else if (Math.Abs(lam0) <= Proj.FORTPI)
            {
                face = FACE.FRONT;
            }
            else if (Math.Abs(lam0) <= Proj.HALFPI + Proj.FORTPI)
            {
                face = (lam0 > 0.0?FACE.RIGHT:FACE.LEFT);
            }
            else
            {
                face = FACE.BACK;
            }

            // Fill in useful values for the ellipsoid <-> sphere shift
            // described in [LK12].
            if (es != 0)
            {
                a_squared           = a * a;
                b                   = a * Math.Sqrt(1.0 - es);
                one_minus_f         = 1.0 - (a - b) / a;
                one_minus_f_squared = one_minus_f * one_minus_f;
            }

            return(this);
        }
Пример #15
0
    public void AddFace(FACE face, int x, int y, int z, BlockType type, byte light = 0, byte shape = 0)
    {
        int f = (int)face;

        byte color = light;

        //get the template vertices needed to draw this face
        Vector3[] vertices = BlockTemplate.vertices[f];
        Vector4[] tangents = BlockTemplate.tangents[f];
        Vector3[] normals = BlockTemplate.normals[f];
        Vector2[] uv = BlockTypes.GetUV(type, f);

        //store the original vertex index
        int origin = _vertices.Count;

        for (int i=0;i<vertices.Length; i++)
        {
            //translate and scale the vertex to the position of this block
            Vector3 vertex = Vector3.Scale(vertices[i] + new Vector3(x,y,z), Block.SIZE);

            _vertices.Add(vertex);

            _colors32.Add(new Color32(color, color, color, 255));

            _tangents.Add(tangents[i]);
            _normals.Add(normals[i]);
            _uvs.Add(uv[i]);
        }

        //get a template face
        int[] triangles = BlockTemplate.face;
        for (int i=0; i<triangles.Length; i++)
        {
            //translate this index to point to the vertices we just added
            _triangles.Add(origin + triangles[i]);
        }
    }
Пример #16
0
    public void addFace(FACE face, int x, int y, int z, Vector3 vertexScale, Vector2 uvScale)
    {
        //get the template vertices needed to draw this face
        Vector3[] vertices = BlockTemplate.vertices[(int)face];
        //get a template uv (the given texture will be drawn on each face)
        Vector2[] uv = BlockTemplate.uv;

        //store the original vertex index
        int origin = _vertices.Count;

        for (int i=0;i<vertices.Length; i++)
        {
            _vertices.Add(Vector3.Scale(Vector3.Scale(vertices[i], vertexScale) + new Vector3(x,y,z), Block.SIZE));

            _uvs.Add(Vector2.Scale(uv[i], uvScale));
        }

        //fetch a template face
        int[] triangles = BlockTemplate.face;
        for (int i=0; i<triangles.Length; i++)
        {
            _triangles.Add(origin + triangles[i]);
        }
    }
Пример #17
0
 public Coin(double weight)
 {
     this.weight       = IsValidWeight(weight) ? weight : DEFAULT_PROBABILITY;
     this.weightedSide = DEFAULT_SIDE;
     Init();
 }
Пример #18
0
 public Coin()
 {
     this.weight       = DEFAULT_PROBABILITY;
     this.weightedSide = DEFAULT_SIDE;
     Init();
 }
Пример #19
0
    public void SetFace(FACE dir, TYPE type)
    {
        ESCell face = _faces[(int)dir];

        face.SetCellType(type);
    }
Пример #20
0
 public ESCell GetFace(FACE dir)
 {
     return(_faces[(int)dir]);
 }
Пример #21
0
        public double getExpectedProbability(FACE face, int consecutiveCount)
        {
            double probability = face == this.weightedSide ? this.weight : 1 - this.weight;

            return(Math.Pow(probability, consecutiveCount));
        }
Пример #22
0
	///<summary>改变面向<summary>
	public void SwapFace(FACE face)
	{
		if(this.face!=face)
		{
			this.face=face;
			spt.sprite2D=scp.spts[new Point(step_ary[step],FaceInt)+id];
			timer=0;

		}
		else
		{
			float rate=(100f/aimMove.v)*0.5f+0.5f;

			if(timer>0.25f*rate)
			{
				timer=0;
				step++;

				if(step>=step_ary.Length)
				{
					step=0;
				}

				spt.sprite2D=scp.spts[new Point(step_ary[step],FaceInt)+id];
			}else timer+=Game.RealDeltaTime(true);
		}


	}
Пример #23
0
        protected override void _Read(BinaryReader reader)
        {
            Offset = (uint)reader.BaseStream.Position;

            Identifier = reader.ReadUInt32();
            if (!IsValid(Identifier))
            {
                return;
            }

            Size            = reader.ReadUInt32();
            FirstNodeOffset = reader.ReadUInt32();
            TextureCount    = reader.ReadUInt32();

            //Read texture entries if there are any
            for (uint i = 0; i < TextureCount; i++)
            {
                TextureEntries.Add(new TextureEntry(reader));
            }
            foreach (TextureEntry entry in TextureEntries)
            {
                entry.ReadTextureID(reader);
            }

            //If we are not at the first node yet, we still have an node offset table to read
            if (reader.BaseStream.Position != FirstNodeOffset)
            {
                NodeOffsetTableSize = reader.ReadUInt32();
                for (int i = 0; i < NodeOffsetTableSize; i++)
                {
                    NodeOffsetTable.Add(reader.ReadUInt32());
                }
            }

            //Read first node and as an result create the whole node tree structure
            reader.BaseStream.Seek(Offset + FirstNodeOffset, SeekOrigin.Begin);
            RootNode = new MT7Node(reader, null);


            //Search for optional extra sections until EOF
            while (reader.BaseStream.Position < reader.BaseStream.Length - 4)
            {
                uint identifier = reader.ReadUInt32();
                if (FACE.IsValid(identifier))
                {
                    reader.BaseStream.Seek(-4, SeekOrigin.Current);
                    FACE = new FACE(reader);
                }
                else if (CLSG.IsValid(identifier))
                {
                    reader.BaseStream.Seek(-4, SeekOrigin.Current);
                    CLSG = new CLSG(reader);
                }
                else if (TXT7.IsValid(identifier))
                {
                    reader.BaseStream.Seek(-4, SeekOrigin.Current);
                    TXT7 = new TXT7(reader);
                }
            }

            //Filling the texture entries with the actual textures
            if (TXT7 != null)
            {
                foreach (TextureEntry entry in TextureEntries)
                {
                    entry.Texture = TXT7.GetTexture(entry.TextureID);
                }
            }

            if (SearchTexturesOneDirUp)
            {
                FileStream fileStream = (FileStream)reader.BaseStream;
                string     dir        = Path.GetDirectoryName(Path.GetDirectoryName(fileStream.Name));
                TextureDatabase.SearchDirectory(dir);
            }

            if (MT7.UseTextureDatabase)
            {
                foreach (TextureEntry entry in TextureEntries)
                {
                    if (entry.Texture != null)
                    {
                        continue;
                    }

                    TEXN texture = TextureDatabase.FindTexture(entry.TextureID.Data);
                    if (texture == null)
                    {
                        Console.WriteLine("Couldn't find texture: {0}", entry.TextureID.Name);
                        continue;
                    }
                    entry.Texture           = new Texture();
                    entry.Texture.TextureID = new TextureID(texture.TextureID);
                    entry.Texture.Image     = texture.Texture;
                }
            }


            //Populate base class textures
            foreach (TextureEntry entry in TextureEntries)
            {
                if (entry.Texture == null)
                {
                    entry.Texture           = new Texture();
                    entry.Texture.TextureID = entry.TextureID;
                }
                Textures.Add(entry.Texture);
            }

            //Resolve the textures in the faces
            RootNode.ResolveFaceTextures(Textures);
        }
Пример #24
0
 void SetFace(FACE face)
 {
     currentMats[1]       = Faces[(int)face];
     SMRenderer.materials = currentMats;
 }
Пример #25
0
        public override PJ Init()
        {
            fwd=e_forward;
            inv=e_inverse;

            // Determine the cube face from the center of projection.
            if(phi0>=Proj.HALFPI-Proj.FORTPI/2.0) face=FACE.TOP;
            else if(phi0<=-(Proj.HALFPI-Proj.FORTPI/2.0)) face=FACE.BOTTOM;
            else if(Math.Abs(lam0)<=Proj.FORTPI) face=FACE.FRONT;
            else if(Math.Abs(lam0)<=Proj.HALFPI+Proj.FORTPI) face=(lam0>0.0?FACE.RIGHT:FACE.LEFT);
            else face=FACE.BACK;

            // Fill in useful values for the ellipsoid <-> sphere shift
            // described in [LK12].
            if(es!=0)
            {
                a_squared=a*a;
                b=a*Math.Sqrt(1.0-es);
                one_minus_f=1.0-(a-b)/a;
                one_minus_f_squared=one_minus_f*one_minus_f;
            }

            return this;
        }
Пример #26
0
 public static FaceId ToFaceId(this FACE face) => face.ToFaceId(false);
Пример #27
0
 public Coin(double weight, FACE face)
 {
     this.weight       = IsValidWeight(weight) ? weight : DEFAULT_PROBABILITY;
     this.weightedSide = face;
     Init();
 }
Пример #28
0
    // Update is called once per frame
    void Update()
    {
        if (this.GetComponent <PlayerAttack>().isDead)
        {
            PlayDeathSound();
            canMove = false;
            this.GetComponent <PlayerAttack>().hitbox.GetComponent <BoxCollider2D>().enabled = false;
            anim.SetBool("Dead", true);

            if (this.GetComponent <PlayerAttack>().hasDeathEnded)
            {
                sr.enabled = false;
                Destroy(this);
                GameObject.Find("LoseCanvas").GetComponent <Canvas>().enabled = true;
            }
        }
        else
        {
            float dt = Time.fixedDeltaTime;

            h = Input.GetAxis("Horizontal");
            v = Input.GetAxis("Vertical");

            if (h < 0)
            {
                moveState = MOVEMENT.LEFT;
                facing    = FACE.LEFT;
                anim.SetBool("Left", true);
                anim.SetBool("Right", false);
                anim.SetBool("Down", false);
                anim.SetBool("Up", false);
                anim.SetBool("Idle", false);
            }
            else if (h > 0)
            {
                moveState = MOVEMENT.RIGHT;
                facing    = FACE.RIGHT;
                anim.SetBool("Left", false);
                anim.SetBool("Right", true);
                anim.SetBool("Down", false);
                anim.SetBool("Up", false);
                anim.SetBool("Idle", false);
            }
            else if (v < 0)
            {
                moveState = MOVEMENT.DOWN;
                facing    = FACE.DOWN;
                anim.SetBool("Left", false);
                anim.SetBool("Right", false);
                anim.SetBool("Down", true);
                anim.SetBool("Up", false);
                anim.SetBool("Idle", false);
            }
            else if (v > 0)
            {
                moveState = MOVEMENT.UP;
                facing    = FACE.UP;
                anim.SetBool("Left", false);
                anim.SetBool("Right", false);
                anim.SetBool("Down", false);
                anim.SetBool("Up", true);
                anim.SetBool("Idle", false);
            }
            else
            {
                moveState = MOVEMENT.NONE;
                anim.SetBool("Left", false);
                anim.SetBool("Right", false);
                anim.SetBool("Down", false);
                anim.SetBool("Up", false);
                anim.SetBool("Idle", true);
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                audioSource.PlayOneShot(swordSlash);
                switch (facing)
                {
                case FACE.LEFT:
                    anim.SetTrigger("LeftAttack");
                    break;

                case FACE.RIGHT:
                    anim.SetTrigger("RightAttack");
                    break;

                case FACE.DOWN:
                    anim.SetTrigger("DownAttack");
                    break;

                case FACE.UP:
                    anim.SetTrigger("UpAttack");
                    break;

                default:
                    break;
                }
            }
        }
    }
Пример #29
0
 int GetIndex(int _x, int _y, FACE _face)
 {
     return(0);
 }
Пример #30
0
 public void AddFace(FACE face, int x, int y, int z, Vector3 vertexScale, Vector2 uvScale, byte shape = 0)
 {
     AddFace(face, x, y, z, vertexScale, uvScale, Vector2.zero, shape);
 }
Пример #31
0
    /// <summary>
    /// returns the uv mapping for the given block type and face combination
    /// </summary>
    public static Vector2[] getUV(BlockType type, FACE face)
    {
        int t = (int)type;
        int f = (int)face;

        //if less than 6 faces was specified default 0
        if (uvOffset[t].Length < 6) f = 0;

        //get the template uv
        Vector2[] template = BlockTemplate.uv;

        Vector2[] uv = new Vector2[template.Length];
        Vector2 offset = uvOffset[t][f];

        //translate the template uv coordinates by the offset
        for (int i=0; i<template.Length; i++)
        {
            uv[i].x = (template[i].x + offset.x);
            uv[i].y = (template[i].y + offset.y);
        }

        return uv;
    }