public static void onRightClick(Vector2 position) { Player player = GameManager.getLocalPlayer(); Ray ray = Camera.main.ScreenPointToRay(position); RaycastHit hit; if (Physics.Raycast(ray, out hit, 5)) { GameObject o = hit.transform.gameObject; if (o.tag.Equals("Block")) { Location loc = new Location((ray.direction * 0.01f) + hit.point); Block clickedBlock = loc.getBlock(); Location diff = loc.subtract(clickedBlock.getLocation()); Direction direction = Direction.DOWN; if (diff.getX() >= 0.99f) { direction = Direction.EAST; } else if (diff.getX() <= 0.01f) { direction = Direction.WEST; } if (diff.getY() >= 0.99f) { direction = Direction.UP; } else if (diff.getY() <= 0.01f) { direction = Direction.DOWN; } if (diff.getZ() >= 0.99f) { direction = Direction.NORTH; } else if (diff.getZ() <= 0.01f) { direction = Direction.SOUTH; } onPlayerRightClickBlock(player, clickedBlock, direction); return; } else if (o.tag.Equals("Item")) { EntityUltility entityUltility = o.GetComponent <EntityUltility>(); onPlayerRightClickItem(player, (Item)entityUltility.entity); return; } } }
public void OnCollisionEnter(Collision collision) { if (entity != null) { if (collision.gameObject.tag.Equals("Item")) { EntityUltility eu = collision.gameObject.GetComponent <EntityUltility>(); if (eu.entity.isInitiated() && eu.entity.isRemoved() == false) { entity.OnCollisionEnter(collision, eu); } } } }
public override void OnCollisionEnter(Collision collision, EntityUltility eu) { if (eu.entity.isRemoved() == false) { if (eu.entity is Item) { Item item = (Item)eu.entity; if (item.getType() == getType()) { merge(item); } } } }
public void spawn(GameObject prefab) { GameObject o = GameManager.spawnPrefab(prefab, location, reuseableGameObject, customName: recycleCustomName); ultility = o.GetComponent <EntityUltility>(); if (ultility == null) { ultility = o.AddComponent <EntityUltility>(); } rigidbody = o.GetComponent <Rigidbody>(); ultility.entity = this; o.transform.eulerAngles = rotation; gameObject = o; track(); }
public virtual void OnCollisionEnter(Collision collision, EntityUltility eu) { }