private void ExitRetreat() { gameManager.SetState(GameState.Active); rootManager.CreateNewVisual(currentRoot, currentIndex, transform.position); currentRoot = rootManager.GetCurrent(); currentRoot.AddPoint(transform.position); currentRoot.AddPoint(transform.position); SpawnImpact(); TriggerInvincible(); }
private void Awake() { rootManager = FindObjectOfType <RootManager>(); resourceManager = FindObjectOfType <ResourceManager>(); rigidbody = GetComponent <Rigidbody2D>(); this.IsInvincible = false; gameManager = GameManager.GetInstance(); Vector2 start = new Vector2(0, 0); Vector2 target = Vector2.right; targetRotation = rigidbody.rotation; if (currentRoot == null) { currentRoot = rootManager.GetCurrent(); if (currentRoot == null) { rootManager.CreateNewVisual(transform.position); currentRoot = rootManager.GetCurrent(); // Create a second point that will be move to the player's location currentRoot.AddPoint(transform.position); currentIndex = currentRoot.GetPointCount(); lastPosition = transform.position; } } input = new PlayerInput(); input.SeedControls.Movement.performed += (ctx) => movementInput = ctx.ReadValue <Vector2>(); input.SeedControls.Kill.performed += (ctx) => { if (gameManager.ActiveState == GameState.Active) { gameManager.SetState(GameState.Dead); } }; input.SeedControls.Select.performed += (ctx) => { if (gameManager.ActiveState == GameState.Retreat) { if (resourceManager.IsWaterDrained == false) { gameManager.SetState(GameState.Aim); } } else if (gameManager.ActiveState == GameState.Aim) { ExitRetreat(); } }; input.SeedControls.Cancel.performed += (ctx) => { if (gameManager.ActiveState == GameState.Aim) { gameManager.SetState(GameState.Retreat); } }; }