public void Fire(List <KeyCode> fireKeyCodes) { foreach (KeyCode element in fireKeyCodes) { if (Input.GetKey(element)) { if (!origin.IsRunningBulletPattern) { origin.StartBulletPattern(); } if (!origin.RootEmitter.enabled) { origin.RootEmitter.enabled = true; } } else if (origin.IsRunningBulletPattern && origin.RootEmitter.enabled) { origin.RootEmitter.enabled = false; origin.ResetRootEmitter(); } } }
private void Update() { // handle movement direction.Set(0f, 0f, 0f); if (Input.GetKey(upKey)) { direction.y = 1f; } else if (Input.GetKey(downKey)) { direction.y = -1f; } if (Input.GetKey(leftKey)) { direction.x = -1f; } else if (Input.GetKey(rightKey)) { direction.x = 1f; } Vector2 newPosition = _transform.position + (moveSpeed * direction.normalized * context.DeltaTime); if (newPosition.x < movementBounds.xMin) { newPosition.x = movementBounds.xMin; } else if (newPosition.x > movementBounds.xMax) { newPosition.x = movementBounds.xMax; } if (newPosition.y < movementBounds.yMin) { newPosition.y = movementBounds.yMin; } else if (newPosition.y > movementBounds.yMax) { newPosition.y = movementBounds.yMax; } _transform.position = newPosition; // handle shooting if (Input.GetKey(fireKey)) { if (!origin.IsRunningBulletPattern) { origin.StartBulletPattern(); } if (!origin.RootEmitter.enabled) { origin.RootEmitter.enabled = true; } } else if (origin.IsRunningBulletPattern && origin.RootEmitter.enabled) { origin.RootEmitter.enabled = false; origin.ResetRootEmitter(); } }