public void AssignRespawnPlaces() { for (int i = 0; i < GameController.inst.respawnPlaceNames.Length; i++) { BaseObjectParams objectParams = new BaseObjectParams { name = GameController.inst.respawnPlaceNames[i], }; GameController.inst.respawnObjectPlaces[i] = new BaseObject(); GameController.inst.respawnObjectPlaces[i].AssignObject(objectParams); } }
public void CreateObstacleObject() { var objectPosition = GameController.inst.respawnObjectPlaces[index].gameObject.transform.position; BaseObjectParams objectParams = new BaseObjectParams { path = Const.MODELS_PATH + "Obstacle_objects/", file = "Obstacle_" + index, name = "Obstacle_" + index, position = objectPosition, rotation = Quaternion.Euler(0f, 0f, 0f), scale = new Vector3(1f, 1f, 1f), component = typeof(ObstacleObjectComponent) }; CreateObject(objectParams); gameComponent.onUpdate.AddListener(OnComponentUpdate); gameComponent.onStart.AddListener(OnStart); }
public void AssignBackgroundObject() { BaseObjectParams objectParams = new BaseObjectParams { name = GameController.backgroundObjectName, component = typeof(BackgroundObjectComponent) }; AssignObject(objectParams); gameComponent.objectParams.Add("isDragged", false); gameComponent.objectParams.Add("mouseDownPosition", new Vector3()); gameComponent.onMouseDown.AddListener(() => { Vector3 mouse = Input.mousePosition; Ray castPoint = Camera.main.ScreenPointToRay(mouse); gameComponent.objectParams["mouseDownPosition"] = castPoint.origin; }); gameComponent.onMouseDrag.AddListener(() => { gameComponent.objectParams["isDragged"] = true; }); gameComponent.onMouseUp.AddListener(() => { Vector3 mouseDownPosition = (Vector3)gameComponent.objectParams["mouseDownPosition"]; Vector3 mouse = Input.mousePosition; Ray castPoint = Camera.main.ScreenPointToRay(mouse); Vector3 currentMousePosition = castPoint.origin; Vector3 dragVectorDirection = (currentMousePosition - mouseDownPosition).normalized; var draggedDirection = DragHelper.GetDragDirection(dragVectorDirection); GameController.SwipeObject(draggedDirection); gameComponent.objectParams["isDragged"] = false; }); }
public void CreateFallingObject() { var unitPosition = GameController.inst.fallingObjectPlace.gameObject.transform.position; BaseObjectParams objectParams = new BaseObjectParams { path = Const.MODELS_PATH + "Falling_object/", file = "Falling_object", name = "Falling_object", position = unitPosition, rotation = Quaternion.Euler(0f, 0f, 0f), scale = new Vector3(1f, 1f, 1f), component = typeof(FallingObjectComponent) }; CreateObject(objectParams); gameComponent.onStart.AddListener(OnStart); gameComponent.onCollision2DEnter.AddListener((collision) => { GameController.ContactObject(collision); }); }