public override void _PhysicsProcess(float delta) { if (Input.IsActionPressed("left_click")) { onProjectileShoot((PackedScene)GD.Load("res://projectiles/RifileBullet.tscn"), GetGlobalMousePosition(), Vector2.Right, null, new Team(), null); } // Update the timeout counter CurrentTime += delta; if (CurrentTime < GameStates.updateDelta) { return; } // "Reset" the time counting CurrentTime -= GameStates.updateDelta; int index = 0; // And update the game state foreach (Agent agent in SpawnBots.Values) { // Locate the bot node Agent enemyNode = (Agent)TeamMapAIs[(int)agent.GetCurrentTeam()].GetUnit(agent.Name); CapturableBase capturableBase = (CapturableBase)(CapaturableBaseManager.GetBases()[_spawnBotTargetBase[agent.GetUnitName()]]); Vector2 randomPosition = capturableBase.GetRandomPositionWithinCaptureRadius(); enemyNode.MoveToward(randomPosition - enemyNode.GlobalPosition, delta); //enemyNode.MoveAndSlide((SpawnBots[AgentPrefix + ((index + 1) % SpawnBots.Count)].GlobalPosition - enemyNode.GlobalPosition) * 0.1f); enemyNode.LookAt(SpawnBots[AgentPrefix + ((index + 1) % SpawnBots.Count)].GlobalPosition); // Always fire enemyNode.Fire(Weapon.WeaponOrder.Right, 1); enemyNode.Fire(Weapon.WeaponOrder.Left, 1); index++; } }
public void SetNextBase(CapturableBase capturableBase) { _nextBasePosition = capturableBase.GetRandomPositionWithinCaptureRadius(); }