当前位置: 首页>>代码示例>>C#>>正文


C# Vector3.Equals方法代码示例

本文整理汇总了C#中Vector3.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Equals方法的具体用法?C# Vector3.Equals怎么用?C# Vector3.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector3的用法示例。


在下文中一共展示了Vector3.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

	// Update is called once per frame
	void Update () {
        oldStart = start;
		start = transform.position;
        finish = start + new Vector3(0, 15);
        if (isFire)
        {
            CD -= Time.deltaTime;
            if (CD <= 0)
            {
                GetComponent<LineRenderer>().enabled = true;
                GetComponent<LineRenderer>().sortingLayerName = "Bullets";
                //GetComponent<LineRenderer>().SetPosition(0, start);
                //GetComponent<LineRenderer>().SetPosition(1, finish);
                GetComponent<LineRenderer>().SetPosition(0, Vector3.zero);
                GetComponent<LineRenderer>().SetPosition(1, new Vector3(0, 15));
                if (!start.Equals(oldStart))
                {
                    GameObject newGlow = Instantiate(afterglow);
                    newGlow.GetComponent<LineRenderer>().SetPosition(0, start);
                    newGlow.GetComponent<LineRenderer>().SetPosition(1, finish);
                }
                targets = Physics2D.RaycastAll(start, Vector2.up,100,LayerMask.GetMask("Enemy"));
                if (targets!=null)
                    foreach (RaycastHit2D item in targets)
                    {
                        if (item.collider.tag == "Enemy")
                        {
                            item.collider.SendMessage("ApplyDamage", 1f + power * 0.2f);
                        }

                    }
            }
        }
        else
        {
            GetComponent<LineRenderer>().enabled = false;
            CD = MaxCD;
        }
	}
开发者ID:cyberimp,项目名称:Dark-Invaders,代码行数:40,代码来源:LaserGunController.cs

示例2: EqualityTest

        public void EqualityTest( float x1, float y1, float z1, float x2, float y2, float z2, bool expected )
        {
            Vector3 vector1 = new Vector3( x1, y1, z1 );
            Vector3 vector2 = new Vector3( x2, y2, z2 );

            Assert.AreEqual( vector1 == vector2, expected );
            Assert.AreEqual( vector1 != vector2, !expected );

            Assert.AreEqual( vector1.Equals( vector2 ), expected );
            Assert.AreEqual( vector1.Equals( (object) vector2 ), expected );
        }
开发者ID:CanerPatir,项目名称:framework,代码行数:11,代码来源:Vector3Test.cs

示例3: DifferentAreNotEqual

            public void DifferentAreNotEqual()
            {
                var v1 = new Vector3(10, 10, 10);
                var v2 = new Vector3(1, 1, 1);

                Assert.IsFalse(v1.Equals(v2), "Vector with different values should not be equal");
            }
开发者ID:SvDvorak,项目名称:Mono.GameMath,代码行数:7,代码来源:Vector3Test.cs

示例4: WVector3

 public WVector3(Vector3 v)
 {
     if(v.Equals(null)) {
         throw new ArgumentNullException();
     }
     Value = v;
 }
开发者ID:Thomsch,项目名称:EVA,代码行数:7,代码来源:WVector3.cs

示例5: OnServerAddPlayer

    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    {
        Vector3 playerSpawnPos = new Vector3(0.0F, 0.0F, 0.0F);
        Vector3 spawnA = new Vector3(0.0F, 0.0F, 0.0F);
        Vector3 spawnB = new Vector3(0.0F, 0.0F, 0.0F);

        GameObject[] spawns = GameObject.FindGameObjectsWithTag("spawn");
        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");

        string target = "Spawn_A";
        Quaternion rotation = Quaternion.identity;

        if (hostConnection != -1 && conn.connectionId != hostConnection) {
            target = "Spawn_B";
            rotation = Quaternion.Euler(rotation.eulerAngles + new Vector3(0.0F, 180.0F, 0.0F));
        }
        else {
            hostConnection = conn.connectionId;
        }

        foreach (GameObject spawn in spawns ) {
            if (spawn.name == "Spawn_A") spawnA = spawn.transform.position;
            else spawnB = spawn.transform.position;
        }

        if (target == "Spawn_A") playerSpawnPos = spawnA;
        if (playerSpawnPos.Equals(new Vector3(0.0F, 0.0F, 0.0F)) || target == "Spawn_B") playerSpawnPos = spawnB;

        GameObject player = (GameObject)GameObject.Instantiate(playerPrefab, playerSpawnPos, rotation);
        NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
    }
开发者ID:misterplatt,项目名称:Shackle-170,代码行数:31,代码来源:spt_NetworkManager_setSpawn.cs

示例6: CreateAimedTransform

        /// <summary>
        /// Creates a rotation matrix that will aim from one point to another. The resulting
        /// matrix can be used to make objects face a certain direction.
        /// </summary>
        /// <param name="from">The source point.</param>
        /// <param name="to">The destination point.</param>
        /// <returns>The aimed matrix.</returns>
        public static Matrix CreateAimedTransform(Vector3 from, Vector3 to)
        {
            // get a normalized vector from 'from' to 'to'
            Vector3 aimVector = to - from;
            aimVector.Normalize();

            // get a vector to the left (no roll)
            Vector3 leftVector = new Vector3(-aimVector.Y, aimVector.X, 0);
            if (!leftVector.Equals(Vector3.Zero))
                leftVector.Normalize();
            else
                leftVector = Vector3.Backward;

            // get the up vector
            Vector3 upVector = Vector3.Cross(aimVector, leftVector);
            upVector.Normalize();

            // create the matrix
            Matrix transform = Matrix.Identity;
            transform.Up = aimVector;
            transform.Backward = upVector;
            transform.Left = leftVector;

            // set the translation to the from position
            transform.Translation = from;

            // return the new matrix
            return transform;
        }
开发者ID:andrewstrauch,项目名称:The-Scarab-Gauntlet,代码行数:36,代码来源:MatrixUtil.cs

示例7: powerupGone

	public void powerupGone(Vector3 pos){
		for (int i = 0; i < itemSpawnPoints.Length; i++) {
			if(pos.Equals(itemSpawnPoints[i])){
				item[i] = false;
				break;
			}
		}
	}
开发者ID:GlowLimeGamesWinterBreak,项目名称:WinterBreak,代码行数:8,代码来源:SpawnItems.cs

示例8: FindVert

        public UInt16 FindVert(Vector3 v)
        {
            UInt16 index = (UInt16)Geometry.Vertecies.FindIndex(delegate(Vector3 p) { return v.Equals(p); });
            if (index >= 0)
                return index;

            Geometry.Vertecies.Add(v);
            return (UInt16)(Geometry.Vertecies.Count - 1);
        }
开发者ID:JeffM2501,项目名称:CSC370,代码行数:9,代码来源:Mesh.cs

示例9: ScalarDivision

		public void ScalarDivision()
		{
			Vector3 ScalarMultiplicationArgument = new Vector3(5.0f, 4.0f, 3.0f);
			Assert.IsTrue(ScalarMultiplicationArgument / 2 == new Vector3(2.5f, 2.0f, 1.5f));
			Assert.IsTrue(2 / ScalarMultiplicationArgument == new Vector3(2.5f, 2.0f, 1.5f));

			Vector3 Point3 = new Vector3(12, 18, 24);
			Point3 /= 6;
			Assert.IsTrue(Point3.Equals(new Vector3(2, 3, 4), .01f));
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:10,代码来源:Vector3DTests.cs

示例10: FixedUpdate

    void FixedUpdate()
    {
        targetPosition = GetComponent<BubbleExplorer>().targetPosition;

        if (!targetPosition.Equals(lastTargetPosition))
        {
            lastTargetPosition = targetPosition;
            PathRequestManager.RequestPath(transform.position, targetPosition, OnPathFound);
           // ListPathRequestManager.RequestPath(transform.position, targetPosition, grid.unwalkable, new List<Node>(),OnPathFound);
            path = null;
        }
        else {
            if (path != null && Vector3.Distance(transform.position, targetPosition) > 0.05f)
            {
                if (Vector3.Distance(transform.position, currentWayPoint + height) < 0.05f)
                {
                    targetIndex++;
                    currentWayPoint = path[targetIndex];
                }

                if (!recheckPath())
                {
                    PathRequestManager.RequestPath(transform.position, targetPosition, OnPathFound);

                    //ListPathRequestManager.RequestPath(transform.position, targetPosition, grid.unwalkable,grid.dynamicUnwalkable, OnPathFound);
                    path = null;
                }
                else {

                    float angle = Vector3.Angle(transform.forward, (currentWayPoint) + height - transform.position);

                    bool posDir = (Vector3.Angle(transform.right, (currentWayPoint) + height - transform.position) > 90);
                    int rot = Mathf.RoundToInt(angle / rotationUnit);

                    if (rot > maxRotationSpeed)
                    {
                        rot = maxRotationSpeed;
                    }
                    Quaternion deltaRotation;
                    if (posDir)
                    {
                        deltaRotation = Quaternion.Euler(0.0f, -(rot * rotationUnit), 0.0f);
                    }
                    else {
                        deltaRotation = Quaternion.Euler(0.0f, (rot * rotationUnit), 0.0f);
                    }
                    rb.MoveRotation(rb.rotation * deltaRotation);
                    if (Mathf.Abs(angle) < rotationDirectionDifference)
                    {
                        transform.position = Vector3.MoveTowards(transform.position, currentWayPoint + height, movementSpeed * Time.deltaTime);
                    }
                }
            }
        }
    }
开发者ID:zmedgyes,项目名称:Unity,代码行数:55,代码来源:Unit.cs

示例11: JsConsole

        public JsConsole(Game1 game, Vector3 pos, Vector3 dir)
            : base()
        {
            this.game = game;
            this.pos = pos;
            minigame = game.minigame;
            instance = new MgInstance(game, minigame);
            ship = game.ship;
            this.dir = dir;
            successAtActivate = -1;

            interactRange = new CircleCollider(this.pos + dir * 16, 3);
            interestRange = new CircleCollider(this.pos + dir * 16, 20);

            model = new JsConsoleModel(this, game);
            game.modelManager.addObject(model);
            nodePos = new Vector2((int)((this.pos.X / 30) + 0.5f), (int)((this.pos.Z / 30) + 0.5f));

            destroying = false;

            cardCount = 0;
            consolePos = pos + dir * 15;
            consolePos.Y = 4.5f;

            cols = new List<OOBB>();
            cols.Add(new OOBB(consolePos + dir*1, dir, 5, 1, dir));
            cols.Add(new OOBB(consolePos + dir*-1, dir, 5, 1, -dir));
            cols.Add(new OOBB(consolePos + Vector3.Cross(dir, Vector3.Up) * -2f, dir, 2, 1, Vector3.Cross(-dir, Vector3.Up)));
            cols.Add(new OOBB(consolePos + Vector3.Cross(-dir, Vector3.Up) * -2f, dir, 2, 1, Vector3.Cross(dir, Vector3.Up)));

            cols.Add(new OOBB(pos + dir * 13, dir, 30, 1, dir));

            if(dir.Equals(Vector3.Left) || dir.Equals(Vector3.Right))
            {
                forcefield = new ForcefieldDrill(game, pos + dir * 13, 1);
            }
            else
            {
                forcefield = new ForcefieldDrill(game, pos + dir * 13, 0);
            }
            game.modelManager.addAdditive(forcefield);
        }
开发者ID:Thinny-Hendrix,项目名称:MoonCow,代码行数:42,代码来源:JsConsole.cs

示例12: TestOne

        static bool TestOne(double Tx, double Ty, double Tz, double Rx, double Ry, double Rz, double Sx, double Sy, double Sz)
        {
            Vector3 UnitVectorY = new Vector3(0.0f, 1.0f, 0.0f);
            Vector3 v1 = new Vector3();
	        v1 = UnitVectorY;
            Matrix4X4 NormalMatrix = Matrix4X4.Identity;
            Matrix4X4 InverseMatrixFromNormalMatrix = Matrix4X4.Identity;
            Matrix4X4 InverseMatrixCalculated = Matrix4X4.Identity;

	        NormalMatrix.PrepareMatrix(Tx, Ty, Tz, Rx, Ry, Rz, Sx, Sy, Sz);
	        NormalMatrix.TransformVector(ref v1);

            InverseMatrixFromNormalMatrix.SetToInverse(NormalMatrix);
            InverseMatrixFromNormalMatrix.TransformVector(ref v1);

	        // make sure they are the same within an error range
            Assert.IsTrue(v1.Equals(UnitVectorY, .01f));

            NormalMatrix.TransformVector(ref v1);

	        InverseMatrixCalculated.PrepareInvMatrix(-Tx, -Ty, -Tz, -Rx, -Ry, -Rz, 1.0f/Sx, 1.0f/Sy, 1.0f/Sz);
            InverseMatrixCalculated.TransformVector(ref v1);

	        // make sure they are the same within an error range
            Assert.IsTrue(v1.Equals(UnitVectorY, .001f));

	        // And just a bit more checking [7/26/2001] LBB
	        // and now just check that TransformVector is always working
	        NormalMatrix.PrepareMatrix(Tx, Ty, Tz, Rx, Ry, Rz, Sx, Sy, Sz);
            NormalMatrix.TransformVector3X3(ref v1);
	        InverseMatrixCalculated.PrepareInvMatrix(-Tx, -Ty, -Tz, -Rx, -Ry, -Rz, 1.0f/Sx, 1.0f/Sy, 1.0f/Sz);
            InverseMatrixCalculated.TransformVector3X3(ref v1);
            Assert.IsTrue(v1.Equals(UnitVectorY, .001f));

	        NormalMatrix.PrepareMatrix(Tx, Ty, Tz, Rx, Ry, Rz, Sx, Sy, Sz);
            NormalMatrix.TransformVector3X3(ref v1);
            InverseMatrixCalculated.SetToInverse(NormalMatrix);
            InverseMatrixCalculated.TransformVector3X3(ref v1);
            Assert.IsTrue(v1.Equals(UnitVectorY, .001f));

	        return true;
        }
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:42,代码来源:Matrix4x4Tests.cs

示例13: ScalarMultiplication

		public void ScalarMultiplication()
		{
			Vector3 ScalarMultiplicationArgument = new Vector3(5.0f, 4.0f, 3.0f);
			Assert.IsTrue(ScalarMultiplicationArgument * -.5 == -new Vector3(2.5f, 2.0f, 1.5f));
			Assert.IsTrue(-.5 * ScalarMultiplicationArgument == -new Vector3(2.5f, 2.0f, 1.5f));
			Assert.IsTrue(5 * ScalarMultiplicationArgument == new Vector3(25.0f, 20.0f, 15.0f));

			Vector3 Point3 = new Vector3(2, 3, 4);
			Point3 *= 6;
			Assert.IsTrue(Point3.Equals(new Vector3(12, 18, 24), .01f));
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:11,代码来源:Vector3DTests.cs

示例14: setColor

	void setColor(Vector3 seb) {
		if (seb.Equals(Vector3.zero)) {
			if (getViewCount(VIS_DIST) != 0) {
				gameObject.GetComponent<Renderer>().material.color = Color.white;
			} else {
				gameObject.GetComponent<Renderer>().material.color = Color.blue;
			}
		} else {
			gameObject.GetComponent<Renderer>().material.color = Color.red;
		}
	}
开发者ID:benmsisson,项目名称:flock-test,代码行数:11,代码来源:Flock.cs

示例15: OffsetPoints

	public static Vector3[] OffsetPoints (this Vector3[] points, Vector3 offset)
	{
		if (offset.Equals (Vector3.zero))
			return points;
		// Make a flat clone of the original array
		var ofsPoints = Enumerable.Repeat (Vector3.zero, points.Length).ToArray ();
		Array.Copy (points, ofsPoints, points.Length);
		for (int i = 0; i < ofsPoints.Length; i++) {
			ofsPoints[i] = ofsPoints[i] + offset;
		}
		return ofsPoints;
	}
开发者ID:MaDDoXbr,项目名称:https---github.com-magneticservices-Palomar,代码行数:12,代码来源:Vec3Tools.cs


注:本文中的Vector3.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。