Esempio n. 1
0
    private void ProcessMovement(MovementCMap movementMap, LookPosCMap lookMap, KeypressCMap keyboardMap, float desire, Vector3 currentPos)
    {
        moveDirections.Clear();
        moveWeights.Clear();
        lookDirections.Clear();
        float moveHighest = 1;



        foreach (var res in GameManager.manager.resources)
        {
            if (res.capacity <= 0)
            {
                continue;
            }
            Vector3 resourcePos = res.thisTransform.position;
            MarkLookMap(resourcePos);
            moveHighest = MarkMovementMap(currentPos, resourcePos, moveHighest);
        }


        for (int i = 0; i < moveWeights.Count; i++)
        {
            float strength = 1.01f - (moveWeights[i] / moveHighest);
            strength *= desire;
            // write in
            movementMap.WriteDirection(moveDirections[i], strength);
            lookMap.WriteLookPos(lookDirections[i], strength);
            keyboardMap.WriteKey(BotKeys.PRIMARY_ATTACK, true, strength);
        }
    }
Esempio n. 2
0
    public void Process(MovementCMap contextMap, Minion m)
    {
        directions.Clear();
        weights.Clear();
        float      highest = 1;
        PlayerData enemy   = GameManager.manager.GetOpposingPlayer(m.GetTeam());

        foreach (BaseBuilding building in enemy.buildings)
        {
            highest = MarkMap(m.Position, building.GetPosition(), highest);
        }

        foreach (Minion enemyMinion in enemy.minions)
        {
            highest = MarkMap(m.Position, enemyMinion.Position, highest);
        }

        highest = MarkMap(m.Position, enemy.controller.transform.position, highest);

        for (int i = 0; i < weights.Count; i++)
        {
            float strength = 1.01f - (weights[i] / highest);
            contextMap.WriteDirection(directions[i], strength);
        }
    }
Esempio n. 3
0
    private void ProcessMovement(MovementCMap movementMap, LookPosCMap lookMap, KeypressCMap keyboardMap, PlayerData enemyPlayer, Vector3 currentPos)
    {
        moveDirections.Clear();
        moveWeights.Clear();
        lookDirections.Clear();
        float moveHighest = 1;

        // move towards enemy minions
        foreach (var minion in enemyPlayer.minions)
        {
            float sqrDist = (minion.Position - currentPos).sqrMagnitude;
            // LOOK at the minion
            MarkLookMap(minion.Position);
            float closeSqrRange = 36;
            // possibly MOVE away from it
            if (sqrDist < closeSqrRange)
            {
                moveHighest = MarkMovementMap(minion.Position, currentPos, moveHighest, 2);
            }
            else
            {
                moveHighest = MarkMovementMap(currentPos, minion.Position, moveHighest, 0);
            }
        }

        // move away from towers, but towards other buildings!
        foreach (var building in enemyPlayer.buildings)
        {
            // LOOK at the building
            MarkLookMap(building.GetPosition());

            float sqrDist    = (building.GetPosition() - currentPos).sqrMagnitude;
            float closeRange = Mathf.Max(building.GetAttackRange() + 1, building.blockingRadius);
            bool  tooClose   = sqrDist < (closeRange * closeRange);
            // possibly MOVE away from it
            if (tooClose)
            {
                moveHighest = MarkMovementMap(building.GetPosition(), currentPos, moveHighest, 10);
            }
            else
            {
                moveHighest = MarkMovementMap(currentPos, building.GetPosition(), moveHighest, 0);
            }
        }


        for (int i = 0; i < moveWeights.Count; i++)
        {
            float strength = 1.01f - (moveWeights[i] / moveHighest);
            strength += extraWeights[i];
            movementMap.WriteDirection(moveDirections[i], strength);
            lookMap.WriteLookPos(lookDirections[i], strength);
            keyboardMap.WriteKey(BotKeys.PRIMARY_ATTACK, true, strength);
        }
    }