Esempio n. 1
0
    void Think()
    {
        movementMap.Decay();
        keyboardMap.Decay();
        lookMap.Decay();

        inputs.walkDir   = Vector3.forward;
        inputs.strafeDir = Vector3.right;

        PlayerData player = GameManager.manager.GetPlayer(Teams.Team.AI);

        attackBehaviour.Process(movementMap, keyboardMap, lookMap, player.controller);
        resourceBehaviour.Process(movementMap, keyboardMap, lookMap, player.controller);
        buildBehaviour.Process(movementMap, keyboardMap, lookMap, player.controller);

        // evaluate keys
        inputs.primaryAttack = keyboardMap.GetKeyPress(BotKeys.PRIMARY_ATTACK);
        inputs.buildMode     = keyboardMap.GetKeyPress(BotKeys.BUILD_MODE);

        // evaluate movement
        moveDir = movementMap.Evaluate();
        inputs.forwardBackwardInput = moveDir.z;
        inputs.leftRightInput       = moveDir.x;

        // evaluate look pos
        inputs.lookPos = lookMap.Evaluate();
        // update our inputs with movement behaviours

        PlayerData enemyPlayer = GameManager.manager.GetOpposingPlayer(Teams.Team.AI);
        Vector3    buildAngles = GetBuildingEulers(inputs.lookPos, enemyPlayer);

        inputs.buildingEuler   = buildAngles;
        inputs.desiredBuilding = desiredBuildingType;
    }
Esempio n. 2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        MinionFixedUpdate();
        movementMap.Decay();
        attackMap.Decay();


        desiredDir = movementMap.Evaluate();
        Vector3 vel = desiredDir * speed;

        vel.y = thisRigidbody.velocity.y;
        thisRigidbody.velocity        = vel;
        thisRigidbody.angularVelocity = Vector3.zero;

        desiredDir.y = 0;
        Quaternion desiredRot = Quaternion.LookRotation(desiredDir);

        thisRigidbody.rotation = Quaternion.RotateTowards(thisRigidbody.rotation, desiredRot, 360 * Time.deltaTime);

        doAttack = attackMap.Evaluate();
        if (doAttack)
        {
            Attack();
        }

        if (health <= 0)
        {
            OnDeath();
        }
    }