Ejemplo n.º 1
0
 private void ApplyInput(AIInputData orderInput)
 {
     acceleration         = orderInput.acceleration;
     turningDirection     = orderInput.turn;
     usingActiveEquipment = orderInput.usingEquipment;
     targetedObject       = orderInput.targetObject;
     targetedPosition     = orderInput.targetPosition;
     interacting          = orderInput.interacting;
 }
    public override AIInputData OnOrderInput()
    {
        AIInputData input = new AIInputData();

        if (target != null)
        {
            if (!orbiting)
            {
                Vector2 relationVector = (target.transform.position - controlledShip.transform.position);

                input.acceleration = 1;
                relationVector     = controlledShip.transform.InverseTransformDirection(relationVector);

                if (relationVector.x >= 0)
                {
                    input.turn = -1f;
                }
                else if (relationVector.x < 0)
                {
                    input.turn = 1f;
                }
            }
            else
            {
                Vector2 relationVector = (target.transform.position - controlledShip.transform.position);

                input.acceleration = 1;
                relationVector     = controlledShip.transform.InverseTransformDirection(relationVector);

                if ((relationVector.x > 0 && relationVector.y > 0) || (relationVector.x < 0 && relationVector.y < 0))
                {
                    input.turn = 1f;
                }
                else if (relationVector.x != 1f && relationVector.x != -1f)
                {
                    input.turn = -1f;
                }

                // SHOOOOOOOOT

                Vector2 movementOffset = Vector2.zero;
                if (targetEngines != null)
                {
                    movementOffset = targetEngines.MovementVector * attackRange;
                }

                input.usingEquipment = true;
                input.targetPosition = target.transform.position - controlledShip.transform.position + (Vector3)movementOffset;
                input.targetObject   = target.gameObject;
            }
        }

        return(input);
    }
Ejemplo n.º 3
0
    public override AIInputData OnOrderInput()
    {
        AIInputData input          = new AIInputData();
        Vector2     relationVector = (targetPosition.Value - (Vector2)controlledShip.transform.position);

        input.acceleration = 1f - Mathf.Lerp(0f, 2f, 1f - (relationVector.sqrMagnitude / (arrivalDistance * arrivalDistance) * 2f));
        relationVector     = controlledShip.transform.InverseTransformDirection(relationVector);

        if (relationVector.x >= 0)
        {
            input.turn = -1f;
        }
        else if (relationVector.x < 0)
        {
            input.turn = 1f;
        }

        return(input);
    }