World.Update C# (CSharp) Method

Update() public method

public Update ( ) : void
return void
    void Update()
    {
        createPlayer();
        if (Input.GetKeyUp(KeyCode.Space))
        {
            Debug.Log("KeyCode.Space");
            KBEngine.Event.fireIn("jump");
        }
        else if (Input.GetMouseButton (0))
        {
            // 射线选择,攻击
            if(Camera.main)
            {
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit))
                {
                    Debug.DrawLine (ray.origin, hit.point);
                    UnityEngine.GameObject gameObj = hit.collider.gameObject;
                    if(gameObj.name.IndexOf("terrain") == -1)
                    {
                        string[] s = gameObj.name.Split(new char[]{'_' });

                        if(s.Length > 0)
                        {
                            int targetEntityID = Convert.ToInt32(s[s.Length - 1]);
                            KBEngine.Event.fireIn("useTargetSkill", (Int32)1, (Int32)targetEntityID);
                        }
                    }
                }
            }
        }
    }

Usage Example

示例#1
0
        public void ShipHitByProjectileFFA()
        {
            // DO NOT MOVE THIS TEST AT ALL. MAKE TESTS BELOW THIS ONE OR ELSE FAILURE OCCURS. (Because of the global IDs.)
            World tester = new World(750, new List <Star>()
            {
                new Star(new Vector2D(4, 6), 0.01, 25)
            }, 4U, 300U, false);

            tester.AddShip(new Vector2D(100, 100), new Vector2D(1, 0), "meme", tester.GetShotFireDelay(), 0.6, 4.0, 5, 25);
            tester.AddShip(new Vector2D(130, 100), new Vector2D(1, 0), "meme", tester.GetShotFireDelay(), 0.6, 4.0, 5, 25);

            for (int updateIdx = 0; updateIdx < 5; updateIdx++)
            {
                tester.Update();
            }

            tester.ProcessCommand(26, 'F');

            for (int updateIdx = 0; updateIdx < 5; updateIdx++)
            {
                tester.Update();
                tester.Cleanup();
            }

            Assert.IsTrue(tester.GetShips()[27].GetHP() == 4);
        }
All Usage Examples Of World::Update