Exemplo n.º 1
0
    public override void _Ready()
    {
        _grid = (TextureRect)GetNode("MarginContainer/Grid");

        _agentMarker  = (Sprite)_grid.GetNode("AgentMarker");
        _baseMarker   = (Sprite)_grid.GetNode("BaseMarker");
        _agents       = new Godot.Collections.Dictionary <String, Agent>();
        _agentMarkers = new Godot.Collections.Dictionary <String, Sprite>();
        _baseMarkers  = new Godot.Collections.Dictionary <String, Sprite>();

        _player = null;
        _capaturableBaseManager = null;
        _gridScale = _grid.RectSize / (GetViewportRect().Size *_zoom);
    }
Exemplo n.º 2
0
    public void Iniitialize(CapaturableBaseManager capaturableBaseManager)
    {
        _capaturableBaseManager = capaturableBaseManager;

        foreach (CapturableBase capturableBase in capaturableBaseManager.GetBases())
        {
            Sprite baseMarker = (Sprite)_baseMarker.Duplicate();
            baseMarker.Name         = capturableBase.Name + "_marker";
            baseMarker.SelfModulate = Team.TeamColor[(int)capturableBase.GetCaptureBaseTeam()];
            baseMarker.Show();

            _grid.AddChild(baseMarker);

            // Add marker to dictionary
            _baseMarkers.Add(capturableBase.Name, baseMarker);
        }
    }
Exemplo n.º 3
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.º 4
0
    private void _changeAgentBehavior()
    {
        foreach (Agent agent in SpawnBots.Values)
        {
            agent.Heal(100);
            // Assign next bases

            _spawnBotTargetBase[agent.GetUnitName()] = (_spawnBotTargetBase[agent.GetUnitName()] + 1) % CapaturableBaseManager.GetBases().Count;
        }
    }
Exemplo n.º 5
0
 protected void InitializeCapaturableBaseManager()
 {
     CapaturableBaseManager = (CapaturableBaseManager)GetNode("CapaturableBaseManager");
     CapaturableBaseManager.Initailize(this);
 }