Exemplo n.º 1
0
    public CapturableBase GetSpawnPointFromCaptureBase()
    {
        CapturableBase targetCaptureBase  = null;
        CapturableBase neutralCaptureBase = null;

        foreach (CapturableBase captureBase in _bases)
        {
            if (captureBase.GetCaptureBaseTeam() == _team.CurrentTeamCode)
            {
                targetCaptureBase = captureBase;
                break;
            }

            if (captureBase.GetCaptureBaseTeam() == Team.TeamCode.NEUTRAL)
            {
                neutralCaptureBase = captureBase;
            }
        }

        // If not on same team base, try get a neutral base
        if (targetCaptureBase == null)
        {
            targetCaptureBase = neutralCaptureBase;
        }

        return(targetCaptureBase);
    }
Exemplo n.º 2
0
    public void CheckForCapturableBase()
    {
        CapturableBase capturableBase = _getNextCapturableBase();

        if (capturableBase != null)
        {
            _assignNextCapturableBaseToUnits(capturableBase);
        }
    }
Exemplo n.º 3
0
 private void _assignNextCapturableBaseToUnits(CapturableBase capturableBase)
 {
     foreach (Node node in _unitsContainer.GetChildren())
     {
         if (node.HasMethod(nameof(AIAgent.GetAI)))
         {
             AI agentAI = ((AIAgent)node).GetAI();
             agentAI.SetNextBase(capturableBase);
             if (agentAI.getState() != AI.State.ENGAGE)
             {
                 agentAI.SetState(AI.State.ADVANCE);
             }
         }
     }
 }
Exemplo n.º 4
0
    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++;
        }
    }
Exemplo n.º 5
0
 public void SetNextBase(CapturableBase capturableBase)
 {
     _nextBasePosition = capturableBase.GetRandomPositionWithinCaptureRadius();
 }
Exemplo n.º 6
0
 public void HandleCapturableBaseCaptured(CapturableBase capturable)
 {
     CheckForCapturableBase();
 }