protected override void RunAI() { turn += Time.deltaTime; if (turn > 1f) { turn = 0; if (player.CurrentNode.Position.x < currentNode.Position.x) { if (!currentNode.Up.Occupied) { currentNode.clearOccupied(); currentNode = currentNode.Up; currentNode.Owner = (this); } } else if (player.CurrentNode.Position.x > currentNode.Position.x) { if (!currentNode.Down.Occupied) { currentNode.clearOccupied(); currentNode = currentNode.Down; currentNode.Owner = (this); } } else { Weapons.Projectiles.Bullet b = Instantiate(bullet).GetComponent <Weapons.Projectiles.Bullet>(); b.transform.position = barrel.position; b.Direction = Direction; } } }
void Update() { if (Managers.GameManager.State == Enums.GameStates.Battle) { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Up)) { if (currentNode.panelAllowed(Enums.Direction.Up, Type)) { direction = Enums.Direction.Up; nextNode = currentNode.Up; } } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Down)) { if (currentNode.panelAllowed(Enums.Direction.Down, Type)) { direction = Enums.Direction.Down; nextNode = currentNode.Down; } } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Left)) { if (currentNode.panelAllowed(Enums.Direction.Left, Type)) { direction = Enums.Direction.Left; nextNode = currentNode.Left; } } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Right)) { if (currentNode.panelAllowed(Enums.Direction.Right, Type)) { direction = Enums.Direction.Right; nextNode = currentNode.Right; } } else { direction = Enums.Direction.None; } //get next state currState = machine.update(hit, animDone, direction, hand.GetCurrentType(), hand.Empty()); //state clean up if (prevState != currState) { doOnce = false; animDone = false; hit = false; anim.SetInteger("state", (int)currState); } if (invunTimer > 0) { if (renderTimer > renderTime) { render = !render; renderTimer = 0; //GetComponent<Renderer>().enabled = render; } hit = false; renderTimer += Time.deltaTime; invunTimer -= Time.deltaTime; } else { //GetComponent<Renderer>().enabled = true; invun = false; } //run state doState[(int)currState](); if (move) { move = false; currentNode.clearOccupied(); currentNode = nextNode; currentNode.Owner = (this); transform.position = currentNode.transform.position; } if (useCard) { if (!hand.Empty()) { useCard = false; hand.UseCurrent(this); CardUIEvent(); } } if (basicAttack) { basicAttack = false; Weapons.Projectiles.Bullet b = Instantiate(bullet).GetComponent <Weapons.Projectiles.Bullet>(); b.transform.position = barrel.position; b.Direction = Direction; } if (damage > 0 && takeDamage) { takeDamage = false; TakeDamage(damage); damage = 0; } prevState = currState; } }