private void DeleteItem(ItemBase obj) { ItemTest test = obj as ItemTest; Debug.Log("删除了 : " + test.txt_Title.text); ItemManager.Instance.Enqueue(test); }
private void DrawLink(int3 cellIndex, ItemTest target) { var position = _spatialHashing.GetPositionVoxel(cellIndex, true); Gizmos.color = Color.red; Gizmos.DrawLine(position, target.Position); }
private void Start() { Random.InitState(123456789); var copy = new Bounds(_worldBounds.Center, _worldBounds.Size * 4F); _spatialHashing = new SpatialHash <ItemTest>(copy, new float3(10F), Allocator.Persistent); for (int i = 0; i < _spawnCount; i++) { var g = GameObject.CreatePrimitive(PrimitiveType.Cube); if (_useRaycast == false) { g.AddComponent <HashTeleport>(); } Destroy(g.GetComponent <BoxCollider>()); g.transform.position = new Vector3(Random.Range(_worldBounds.Min.x + 1, _worldBounds.Max.x), Random.Range(_worldBounds.Min.y + 1, _worldBounds.Max.y), Random.Range(_worldBounds.Min.z + 1, _worldBounds.Max.z)); var item = new ItemTest() { ID = i, Position = g.transform.position }; Profiler.BeginSample("SpatialHasing Add"); _spatialHashing.Add(ref item); Profiler.EndSample(); _listItemGameobject.Add(g); _listItem.Add(item); } }
// Start is called before the first frame update void Start() { ItemTest sword = new ItemTest("Sword", 1); ItemTest bread = new ItemTest("Bread", 2); ItemTest cape = new ItemTest("cape", 3); ItemTest fish = new ItemTest("fish", 4); print("Item Count: " + ItemTest.itemCount); //only way to access the static data is directly though the class. //Example: //ItemTest.itemCount = 4; }
void RegisterPlayer(string _ID) { IDs = _ID; transform.name = "Character" + _ID; Character = Player.transform.FindChild("Character" + _ID).gameObject; Healthbarcanvas = Character.transform.FindChild("Healthbar canvas").gameObject; HealthBarBackground = Healthbarcanvas.transform.FindChild("Health background").gameObject; HealthIndicator = HealthBarBackground.transform.FindChild("Health indicator").gameObject; Healthbar = HealthIndicator.GetComponent <Image>(); ThunderArrow = Character.GetComponent <ThunderArrow>(); Attackrange = Character.transform.FindChild("AttackRange").gameObject; AttackTrigger = Attackrange.GetComponent <AttackTrigger>(); ItemTest = Character.GetComponent <ItemTest>(); inventorycanvas = Player.transform.FindChild("Canvas").gameObject; tooltip = inventorycanvas.transform.FindChild("Tooltip").gameObject; INVcancas = inventorycanvas.GetComponent <Canvas>(); Battletextmanager = Player.transform.FindChild("BattleTextManager").gameObject; scrolltextmanager = Battletextmanager.GetComponent <scrolltextmanager>(); Inventory = Player.transform.FindChild("Inventory").gameObject; showinv = inventorycanvas.GetComponent <showinv>(); inv = Inventory.GetComponent <Inventory>(); statscanvas = Player.transform.FindChild("Canvas - stats - map").gameObject; StatsPanel = statscanvas.transform.FindChild("Stats Panel").gameObject; Statsloader = StatsPanel.GetComponent <Statsloader>(); Camera = Player.transform.FindChild("Camera").gameObject; if (SceneManager.GetActiveScene().name != "Multiplayer Arena") { Teleporter = GameObject.Find("teleporter"); teleporter = Teleporter.GetComponent <Teleporter>(); teleporter.SetCharacter(_ID); shop = GameObject.Find("Shop"); shopdamage = shop.GetComponent <shopdamage>(); shopdamage.shopset(_ID); } CameraControler = Camera.GetComponent <CameraControler>(); PlayerAttack = Character.GetComponent <PlayerAttack>(); Tooltip = tooltip.GetComponent <Tooltip>(); ThunderArrow.Starting(_ID); AttackTrigger.setattack(_ID); scrolltextmanager.Set(_ID); inv.Houi(_ID); showinv.setupinventory(_ID); PlayerAttack.SetAttack(_ID); Statsloader.SetupStats(_ID); CameraControler.SetCamera(_ID); Tooltip.settooltip(_ID); inv.fillinventory(); }
private void ShowItem(List <TestData> dataList) { ItemManager.Instance.ClearParent(content); foreach (TestData item in dataList) { ItemTest tmp = ItemManager.Instance.Dequeue <ItemTest>(); tmp.transform.SetParent(content); tmp.transform.SetAsLastSibling(); tmp.clickAction = ClickItem; tmp.deleteAction = DeleteItem; tmp.SetContent(item.title, item.content, item.time); } }
private void Update() { if (Input.GetKeyDown(KeyCode.Space)) { ItemManager.Instance.ClearParent(content); ItemTest tmp = ItemManager.Instance.Dequeue <ItemTest>(); tmp.transform.SetParent(content); tmp.transform.SetAsLastSibling(); tmp.clickAction = ClickItem; tmp.deleteAction = DeleteItem; tmp.SetContent("111", "111", "111"); ItemTest2 tmp1 = ItemManager.Instance.Dequeue <ItemTest2>(); tmp1.transform.SetParent(content); tmp1.transform.SetAsLastSibling(); tmp1.SetContent("哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈"); } }
private static void AssertItem(ItemTest item, HeaderTestMirror headerMirror, ItemTestMirror itemMirror) { Assert.Equal(item.Id, itemMirror.Id); Assert.Equal(item.StringField, itemMirror.StringField); Assert.Equal(headerMirror, itemMirror.Header); }
private void OnDrawGizmos() { if (Application.isPlaying == false) { return; } if (Time.realtimeSinceStartup - _timeLastRefresh > _refreshTime) { RefreshLinks(); } foreach (var l in _links) { DrawCell(l.Key); foreach (var item in l.Value) { DrawLink(l.Key, item); } } if (_useRaycast) { var startRayPosition = _startRay.position; var startCellBound = new Bounds(_spatialHashing.GetPositionVoxel(_spatialHashing.GetIndexVoxel(startRayPosition), true), _spatialHashing.CellSize); Gizmos.color = Color.yellow; Gizmos.DrawLine(startRayPosition, _endRay.position); ItemTest hit = new ItemTest(); var ray = new Ray(startRayPosition, _endRay.position - startRayPosition); if (_spatialHashing.RayCast(ray, ref hit, (_endRay.position - _startRay.position).magnitude)) { Gizmos.color = Color.blue; Gizmos.DrawCube(hit.GetCenter(), hit.GetSize() * 3F); } _voxelTraversed.Clear(); var me = this; _voxelRay.RayCast(ref me, ray.origin, ray.direction, (_endRay.position - _startRay.position).magnitude); Gizmos.color = new Color(0.88F, 0.6F, 0.1F, 0.4F); foreach (var voxel in _voxelTraversed) { var position = _spatialHashing.GetPositionVoxel(voxel, true); Gizmos.DrawCube(position, _spatialHashing.CellSize); } var rayOffsetted = new Ray(ray.origin - (Vector3)(ray.direction * _spatialHashing.CellSize), ray.direction); startCellBound.GetEnterPositionAABB(rayOffsetted, 1 << 25, out var enterPoint); Gizmos.color = Color.white; Gizmos.DrawCube(enterPoint, Vector3.one * 0.3F); startCellBound.GetExitPosition(rayOffsetted, 1 << 25, out var exitPoint); Gizmos.color = Color.white; Gizmos.DrawCube(exitPoint, Vector3.one * 0.3F); } }
private void ClickItem(ItemBase obj) { ItemTest test = obj as ItemTest; Debug.Log("点击了 : " + test.txt_Title.text); }
/*__________________________________________________________________________________________*/ private void TestItems() { //ItemsDo items = new ItemsDo(); //items.LoadData(); ItemTest testitem = new ItemTest(); testitem.TestLoad(); }